RWTFunctorLIst1 RWTFunctor1<S1>
Functor List, subpackage of Functor
#include <rw/functor/list/RWTFunctorList1.h>
The RWTFunctorList1 class is a sequence of functors whose invocation takes one argument.
A function object, or a functor, is an object that 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) { cout << "a is " << a << endl; } int main () { // create new functors RWTFunctor1<int> fooFunctor = rwtMakeFunctor1((void(*)(int))0,foo,6); RWTFunctor1<int> barFunctor = rwtMakeFunctor1((void(*)(int))0,bar); // create a new functor list RWTFunctorList1<int> 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); return 0; } OUTPUT: x is 3 and y is 6 a is 3
RWTFunctorList1(void);
Constructs an empty list instance.
RWTFunctorList1(const RWTFunctorList1<S1>& second);
Copy constructor. Creates a new list instance that shares its list representation with another list.
void operator()(S1 s1) 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, an RWTHRInternalError exception is thrown.
void add(const RWTFunctor1<S1>& functor, RWCallbackScope scope);
Adds the specified functor to the list. Duplicates are allowed in the list, in which case the functor will be run once for each time it appears in the list.
The add request is stored until either the list is invoked, or the update() method is called.
void remove(const RWTFunctor1<S1>& functor);
Removes all entries from the list that contain the specified functor.
The remove request is stored until either the list is invoked, or the update() method is called.
void update(void);
Updates the list with any add() or remove() requests that have occurred since the last invocation.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.