SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWTFunctorList2< S1, S2 > Class Template Reference

Deprecated. A sequence of functors whose invocation takes two arguments. More...

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

Inheritance diagram for RWTFunctorList2< S1, S2 >:
RWTFunctor2< S1, S2 >

Public Member Functions

 RWTFunctorList2 (const RWTFunctorList2< S1, S2 > &second)
 
 RWTFunctorList2 (void)
 
 ~RWTFunctorList2 (void)
 
void add (const RWTFunctor2< S1, S2 > &functor, RWCallbackScope scope)
 
void operator() (S1 s1, S2 s2) const
 
RWTFunctorList2< S1, S2 > & operator= (const RWTFunctorList2< S1, S2 > &second)
 
void remove (const RWTFunctor2< S1, S2 > &functor)
 
void update (void)
 
- Public Member Functions inherited from RWTFunctor2< S1, S2 >
 RWTFunctor2 (const RWTFunctor2< S1, S2 > &second)
 
 RWTFunctor2 (const RWTFunctor< void(S1, S2)> &second)
 
 RWTFunctor2 (RWStaticCtor)
 
 RWTFunctor2 (RWTFunctor2Imp< S1, S2 > *functorImp)
 
 RWTFunctor2 (void)
 
 ~RWTFunctor2 (void)
 
RWTFunctor2Imp< S1, S2 > & body (void) const
 
RWTFunctor2< S1, S2 > & operator= (const RWTFunctor2< S1, S2 > &second)
 
RWTFunctor2< S1, S2 > & operator= (const RWTFunctor< void(S1, S2)> &second)
 

Additional Inherited Members

- Public Types inherited from RWTFunctor2< S1, S2 >
typedef void(* CallerSignature) (S1, S2)
 
typedef S1 S1Type
 
typedef S2 S2Type
 

Detailed Description

template<class S1, class S2>
class RWTFunctorList2< S1, S2 >
Deprecated
As of SourcePro 12.5, use RWTValSlist<RWTFunctor<void(S1, S2)>> instead.

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.

Example
#include <rw/functor/list/RWTFunctorList2.h>
#include <rw/functor/rwtMakeFunctor2.h>
#include <iostream>
void foo(int x, short y) {
std::cout << "x is " << x << " and y is " << y << std::endl;
}
void bar(int a, short b) {
std::cout << "a is " << a << " and b is " << b << std::endl;
}
int main() {
// create new functors
rwtMakeFunctor2((void (*)(int, short))0, foo);
rwtMakeFunctor2((void (*)(int, short))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, 45);
return 0;
}
Deprecated. A functor that is invoked with two arguments, and whose invocation returns no value.
Definition RWTFunctor2.h:146
Deprecated. A sequence of functors whose invocation takes two arguments.
Definition RWTFunctorList2.h:97
void add(const RWTFunctor2< S1, S2 > &functor, RWCallbackScope scope)
RWTFunctor2< S1, S2 > rwtMakeFunctor2(void(*caller)(S1, S2), DR(*callee)(D1, D2))
Definition rwtMakeFunctor2.h:88
@ RW_CALL_REPEATEDLY
Definition RWCallbackScope.h:51

OUTPUT:

x is 3 and y is 45
a is 3 and b is 45

Constructor & Destructor Documentation

◆ RWTFunctorList2() [1/2]

template<class S1 , class S2 >
RWTFunctorList2< S1, S2 >::RWTFunctorList2 ( void )

Constructs an empty list instance.

◆ RWTFunctorList2() [2/2]

template<class S1 , class S2 >
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()

template<class S1 , class S2 >
RWTFunctorList2< S1, S2 >::~RWTFunctorList2 ( void )
inline

Destructor.

Member Function Documentation

◆ add()

template<class S1 , class S2 >
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.

◆ operator()()

template<class S1 , class 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.

◆ operator=()

template<class S1 , class 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.

◆ remove()

template<class S1 , class S2 >
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.

◆ update()

template<class S1 , class S2 >
void RWTFunctorList2< S1, S2 >::update ( void )

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

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