rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWFunctorList0 Class Reference
[Functor List]

A sequence of functors whose invocation takes no arguments. More...

#include <rw/functor/list/RWFunctorList0.h>

Inheritance diagram for RWFunctorList0:
RWFunctor0 RWHandleBase

List of all members.

Public Member Functions

 RWFunctorList0 (void)
 RWFunctorList0 (const RWFunctorList0 &second)
 ~RWFunctorList0 (void)
RWFunctorList0operator= (const RWFunctorList0 &second)
void operator() (void) const
void add (const RWFunctor0 &functor, RWCallbackScope scope)
void remove (const RWFunctor0 &functor)
void update (void)
RWFunctorList0Imp & body (void) const

Detailed Description

The RWFunctorList0 class is a sequence of functors whose invocation takes no 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.

Examples

 void foo(int x)
    { cout << "foo was called with " << x << endl; }
 void bar()
    { cout << "bar was called" << endl; }
 
 int main () {
   // create new functors
   RWFunctor0 fooFunctor = rwtMakeFunctor0(0, foo, 4);
   RWFunctor0 barFunctor = rwtMakeFunctor0(0, bar);
 
   // create a new functor list
   RWFunctorList0 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();
 
   return 0;
 }

Program output:

 foo was called with 4
 bar was called

Constructor & Destructor Documentation

RWFunctorList0::RWFunctorList0 ( void   ) 

Constructs an empty list instance.

RWFunctorList0::RWFunctorList0 ( const RWFunctorList0 second  ) 

Copy constructor. Creates a new list instance that shares its list representation with second.

RWFunctorList0::~RWFunctorList0 ( void   ) 

Destructor.


Member Function Documentation

void RWFunctorList0::add ( const RWFunctor0 functor,
RWCallbackScope  scope 
)

Adds the specified functor to the list. Duplicates are allowed in the list. In such cases the functor is 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.

RWFunctorList0Imp & RWFunctorList0::body ( void   )  const [inline]

Gets a reference for the body instance, if any, otherwise throws an exception.

Exceptions:
RWTHRInvalidPointer Thrown if the handle has no associated body.

Reimplemented from RWFunctor0.

void RWFunctorList0::operator() ( void   )  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.

Exceptions:
RWTHRInternalError Thrown if more than one thread attempts to invoke the list at a time.

Reimplemented from RWFunctor0.

RWFunctorList0& RWFunctorList0::operator= ( const RWFunctorList0 second  ) 

Assignment operator. Binds this list instance to representation of list second.

void RWFunctorList0::remove ( const RWFunctor0 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 RWFunctorList0::update ( void   ) 

Updates the list with any add() or remove() requests that have occurred since the last invocation.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© 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.