SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
A sequence of functors whose invocation takes two arguments. More...
#include <rw/functor/list/RWTFunctorList2.h>
Public Member Functions | |
RWTFunctorList2 (void) | |
RWTFunctorList2 (const RWTFunctorList2< S1, S2 > &second) | |
~RWTFunctorList2 (void) | |
RWTFunctorList2< S1, S2 > & | operator= (const RWTFunctorList2< S1, S2 > &second) |
void | operator() (S1 s1, S2 s2) const |
void | add (const RWTFunctor2< S1, S2 > &functor, RWCallbackScope scope) |
void | remove (const RWTFunctor2< S1, S2 > &functor) |
void | update (void) |
RWTFunctorList2Imp< S1, S2 > & | body (void) const |
The RWTFunctorList2 class is a sequence of functors whose invocation takes two arguments.
A function object, or a functor, encapsulates a call to an associated function. When a functor is invoked, it calls the associated function.
A functor list is a sequence of such functors. The list's invocation results in the invocation of all functors contained in the list. This is useful when you wish to connect more that one invocation to a particular action.
void foo(int x, short y) { cout << "x is " << x << " and y is " << y << endl; } void bar(int a, short b) { cout << "a is " << a << " and b is " << b << endl; } int main () { // create new functors RWTFunctor2<int,short> fooFunctor = rwtMakeFunctor2((void(*)(int,short))0, foo); RWTFunctor2<int,short> barFunctor = rwtMakeFunctor2((void(*)(int,short))0, bar); // create a new functor list RWTFunctorList2<int,short> flist; // add the functors to the list flist.add(fooFunctor, RW_CALL_REPEATEDLY); flist.add(barFunctor, RW_CALL_REPEATEDLY); // invoke the list and see that both the functors are called flist(3, 45); return 0; }
Program output:
x is 3 and y is 45 a is 3 and b is 45
RWTFunctorList2< S1, S2 >::RWTFunctorList2 | ( | void | ) | [inline] |
Constructs an empty list instance.
RWTFunctorList2< S1, S2 >::RWTFunctorList2 | ( | const RWTFunctorList2< S1, S2 > & | second | ) | [inline] |
Copy constructor. Creates a new list instance that shares its list representation with second.
RWTFunctorList2< S1, S2 >::~RWTFunctorList2 | ( | void | ) | [inline] |
Destructor.
void RWTFunctorList2< S1, S2 >::add | ( | const RWTFunctor2< S1, S2 > & | functor, | |
RWCallbackScope | scope | |||
) |
Adds the specified functor to the list. Duplicates are allowed, in which case the functor is run each time it appears.
The add request is stored until either the list is invoked, or the update() method is called.
RWTFunctorList2Imp< S1, S2 > & RWTFunctorList2< S1, S2 >::body | ( | void | ) | const [inline] |
Gets a reference for the body instance, if any; otherwise, throws an RWTHRInvalidPointer exception.
Reimplemented from RWTFunctor2< S1, S2 >.
void RWTFunctorList2< S1, S2 >::operator() | ( | S1 | s1, | |
S2 | s2 | |||
) | const |
Invokes the functor list. This includes updating the list with any stored adds or removes, invoking each functor in the list, and removing any functors that were added with the RW_CALL_ONCE flag.
If more than one thread attempts to invoke the list at any one time, throws an RWTHRInternalError exception.
Reimplemented from RWTFunctor2< S1, S2 >.
RWTFunctorList2< S1, S2 > & RWTFunctorList2< S1, S2 >::operator= | ( | const RWTFunctorList2< S1, S2 > & | second | ) | [inline] |
Assignment operator. Binds this list instance to representation of list second.
void RWTFunctorList2< S1, S2 >::remove | ( | const RWTFunctor2< S1, S2 > & | functor | ) |
Removes all entries from the list for the specified functor.
The remove request is stored until either the list is invoked, or the update() method is called.
void RWTFunctorList2< S1, S2 >::update | ( | void | ) |
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.