Hello all,
i am still trying to handle my own signal. For a better understanding i post an
example.
Problem: The method update() has to be called each update to emit a existing
signal. The virtual method WApplication::notify(..) is called less frequent and
therefore not suitable.
note: I cannot emit the signal by a direct call, because of a page can cause a
pagechange by its own and delete the own page object during the call.
Call
------
-Page: Application->performNextPage( "nextPage");
--Application: delete Page; // delete the object, where the call comes from
-Page: do other things // object is deleted yet
--------------------------------------------------------
class MyApplication : public WApplication
{
public:
MyApplication( const Wt::WEnvironment& env);
~MyApplication();
void nextPage( const std::string& rstrNextPageName)
{
Signal<> mySignal = new Signal();
mySignal.connect( this, boost::bind( &CWtApplication::performNextPage,
this,
rstrNextPageName));
m_pcNextPageSignal = mySignal;
}
void performNextPage( const std::string& rstrNextPageNam)
{
delete m_pcCurrentPage;
pcCurrentPage = AbstractFactory<MyPage>::produce( rstrNextPageNam);
}
void update()
{
if( m_pcNextPageSignal)
{
m_pcNextPageSignal->emit();
delete m_pcNextPageSignal;
}
}
private:
MyPage* m_pcCurrentPage;
Wt::Signal<>* m_pcNextPageSignal;
};
--------------------------------------------------------
Thanks in advance,
Sven
-------- Original-Nachricht --------
> Datum: Sat, 24 Apr 2010 15:09:54 +0300
> Von: omer katz <[email protected]>
> An: [email protected]
> Betreff: Re: [Wt-interest] signal / slot
> You need to use boost's custom combinator.
> See here:
> http://stackoverflow.com/questions/2009605/is-there-a-way-to-stop-a-boostsignal-from-calling-its-slots-if-one-of-them-retu/2011983#2011983
>
> 2010/4/24 Sven Knoblich <[email protected]>
>
> > Hello Dmitry,
> > at first, i need a place where i can store my signals. The second is a
> > method which is called each update. This method have to check the flags
> of
> > the signals and emit the signals which are set to true. Therefore i need
> an
> > access to link my method to the loop mechanism. If "notify" is a method
> > which is called each update, then this is a way to hook my method to
> that
> > mexhanism (by overload notify).
> >
> > Thanks, Sven
> >
> >
> >
> > Am 23.04.2010 um 22:12 schrieb Dmitriy Igrishin <[email protected]>:
> >
> > Sorry, I didn't clearly understand what do you want to implement,
> > but if you want to have some control on event propagation to
> > you application besides the contructor you may want to
> > reimplement WApplication::notify() method.
> > But as I understand, all that you want is to implement
> > pagination?
> >
> > Regards,
> > Dmitriy Igrishin
> >
> > 2010/4/23 Sven Knoblich < <[email protected]>[email protected]>
> >
> >> Hallo Dmitry,
> >> thanks for your suggestion. Do you also know how i can connect a update
> >> method with the loop mechanism from wt.The emit call has to be only on
> one
> >> place of the mainloop. Each nextPage-Call only set the update Flag of a
> >> signal. The check method which is called each update check the Flag and
> emit
> >> the signals. Any idea, where i can implement or override such a method?
> >>
> >> Thanks, Sven
> >>
> >>
> >>
> >> Am 23.04.2010 um 17:48 schrieb Dmitriy Igrishin < <[email protected]>
> >> [email protected]>:
> >>
> >> You may do it by implementing the widget (container) with a slot
> >> inside, which will replace the current widget ("page") with next widget
> >> ("page") in some place on the page where you want.
> >>
> >> class MyWidget : public Wt::WContainerWidget {
> >> // code
> >> private:
> >> Wt::WContainerWidget* page_;
> >> Wt::WContainerWidget* paginator_; // emits the signal, e.g.,
> >> "internalPathChanged", or clicked....
> >> void nextPage(); // slot. Loads new page to the page_
> >> // code
> >> };
> >>
> >> Regards,
> >> Dmitriy Igrishin
> >>
> >> 2010/4/23 Sven Knoblich < <[email protected]> <[email protected]>
> >> [email protected]>
> >>
> >>> Thanks for your response. I was wrong by using The internal
> EventSignal.
> >>> Are there possibilities to register my Signals on the existing signal
> >>> handler of WApplication or WContainerWidget? I want to handle my own
> Signals
> >>> on à Central place. Currently i have a pagehandler which inherits
> from
> >>> WApplication an Pages which inherit from WContainerWidget. When i want
> to
> >>> load the next page, i want to call a method from my pagehandler
> >>> "nextpage()". To avoid a selfdestruction by a call from a page i want
> to
> >>> set the updateflag of The Signal to true. When now The Signal handler
> ask
> >>> for this flag, the signal will be called by call emit.
> >>>
> >>> Any idea where to integrate ore which handler i can use?
> >>>
> >>> Many thanks in advance,
> >>> Sven
> >>>
> >>>
> >>>
> ------------------------------------------------------------------------------
> >>> _______________________________________________
> >>> witty-interest mailing list
> >>>
> <[email protected]><[email protected]>
> >>> [email protected]
> >>>
> <https://lists.sourceforge.net/lists/listinfo/witty-interest><https://lists.sourceforge.net/lists/listinfo/witty-interest>
> >>> https://lists.sourceforge.net/lists/listinfo/witty-interest
> >>>
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> witty-interest mailing list
> >> <[email protected]>
> >> [email protected]
> >> <https://lists.sourceforge.net/lists/listinfo/witty-interest>
> >> https://lists.sourceforge.net/lists/listinfo/witty-interest
> >>
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> witty-interest mailing list
> >> <[email protected]>
> >> [email protected]
> >> <https://lists.sourceforge.net/lists/listinfo/witty-interest>
> >> https://lists.sourceforge.net/lists/listinfo/witty-interest
> >>
> >>
> >
> >
> ------------------------------------------------------------------------------
> >
> > _______________________________________________
> > witty-interest mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/witty-interest
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> >
> > _______________________________________________
> > witty-interest mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/witty-interest
> >
> >
------------------------------------------------------------------------------
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest