SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWTFunctorList1< S1 > Class Template Reference

Deprecated. A sequence of functors whose invocation takes one argument. More...

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

Inheritance diagram for RWTFunctorList1< S1 >:
RWTFunctor1< S1 >

Public Member Functions

 RWTFunctorList1 (void)
 
 RWTFunctorList1 (const RWTFunctorList1< S1 > &second)
 
 ~RWTFunctorList1 (void)
 
void add (const RWTFunctor1< S1 > &functor, RWCallbackScope scope)
 
void operator() (S1 s1) const
 
RWTFunctorList1< S1 > & operator= (const RWTFunctorList1< S1 > &second)
 
void remove (const RWTFunctor1< S1 > &functor)
 
void update (void)
 
- Public Member Functions inherited from RWTFunctor1< S1 >
 RWTFunctor1 (void)
 
 RWTFunctor1 (RWStaticCtor)
 
 RWTFunctor1 (RWTFunctor1Imp< S1 > *functorImp)
 
 RWTFunctor1 (const RWTFunctor1< S1 > &second)
 
 RWTFunctor1 (const RWTFunctor< void(S1)> &second)
 
 ~RWTFunctor1 (void)
 
RWTFunctor1Imp< S1 > & body (void) const
 
RWTFunctor1< S1 > & operator= (const RWTFunctor1< S1 > &second)
 
RWTFunctor1< S1 > & operator= (const RWTFunctor< void(S1)> &second)
 

Additional Inherited Members

- Public Types inherited from RWTFunctor1< S1 >
typedef void(* CallerSignature) (S1)
 
typedef S1 S1Type
 

Detailed Description

template<class S1>
class RWTFunctorList1< S1 >

Deprecated:
As of SourcePro 12.5, use RWTValSlist<RWTFunctor<void(S1)>> instead.

The RWTFunctorList1 class is a sequence of functors whose invocation takes one argument.

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.

Example
#include <iostream>
#include <rw/functor/rwtMakeFunctor1.h>
#include <rw/functor/list/RWTFunctorList1.h>
void foo(int x, short y)
{
std::cout << "x is " << x << " and y is " << y << std::endl;
}
void bar(int a)
{
std::cout << "a is " << a << std::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
// 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

Constructor & Destructor Documentation

template<class S1>
RWTFunctorList1< S1 >::RWTFunctorList1 ( void  )

Constructs an empty list instance.

template<class S1 >
RWTFunctorList1< S1 >::~RWTFunctorList1 ( void  )
inline

Destructor.

template<class S1 >
RWTFunctorList1< S1 >::RWTFunctorList1 ( const RWTFunctorList1< S1 > &  second)
inline

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

Member Function Documentation

template<class S1>
void RWTFunctorList1< S1 >::add ( const RWTFunctor1< S1 > &  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.

template<class S1>
void RWTFunctorList1< S1 >::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, the method throws an RWTHRInternalError exception.

template<class S1 >
RWTFunctorList1< S1 > & RWTFunctorList1< S1 >::operator= ( const RWTFunctorList1< S1 > &  second)
inline

Assignment operator. Binds this list instance to another list's representation.

template<class S1>
void RWTFunctorList1< S1 >::remove ( const RWTFunctor1< S1 > &  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.

template<class S1>
void RWTFunctorList1< S1 >::update ( void  )

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

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.