SourcePro® API Reference Guide

 
Macros | Functions
rwtMakeFunctorR0 Macros and Functions

Module Description

Header File
#include <rw/functor/functorR0.h>

A function object, or functor, is an object that encapsulates a call to an associated global or member function. When a functor is invoked, it calls the associated function.

The rwtMakeFunctorR0() functions and macros are provided to construct functors based on the RWTFunctorR0 class. The RWTFunctorR0 class acts as the handle for a family of functor implementation classes based on the RWTFunctorR0Imp class. A functor based on RWTFunctorR0 is invoked with no arguments and returns a value of type SR, but the implementation classes can accept functions with up to three arguments. The values for the additional arguments are defined when an implementation class instance is constructed, and are passed to the function each time the functor is invoked.

Each rwtMakeFunctorR0() function or macro instantiates and constructs an appropriate functor implementation class instance and returns an RWTFunctorR0 handle that is bound to that instance.

rwtMakeFunctorR0() comes in two flavors. First, there is a set of overloaded global function templates. Since not all compilers are able to handle templates to the degree required by these functions, we also provide a corresponding set of macros. The template functions are slightly easier to use and you only have to remember one name. The macros are more portable but they do require more arguments; and because we cannot overload macros, each must have a unique name.

In naming the macros, we have employed a convention to make the names easier to remember. Each name begins with rwtMakeFunctorR0(), which will be followed by either a G if the macro is expecting a global function, or an M if it is expecting a member function. At that point, the name is complete if the associated global or member function takes no arguments. Otherwise we add one of A1, A2, or A3 for functions with 1, 2, or 3 arguments respectively. For example, you will use macro rwtMakeFunctorR0G() to create a functor that calls a global function that takes no arguments. The macro rwtMakeFunctorR0MA2() will create a functor that calls a member function that takes two arguments.

Example

Example Using Templates

#include <rw/functor/functorR0.h>
class A {
public:
int bar(char); // Member function with 1 argument
};
int main()
{
A a; // an instance of class A
int foo(double, long); // Global function with 2 arguments
// Create an RWTFunctorR0 set to call foo(3.14,11):
= rwtMakeFunctorR0((int(*)(void))NULL, foo, 3.14, 11);
// Create an RWTFunctorR0 set to call a.bar('x'):
= rwtMakeFunctorR0((int(*)(void))NULL, a, &A::bar, 'x');
int result1 = t1();
int result2 = t2();
return 0;
}

Example Using Macros

#include <rw/functor/functorR0.h>
class A {
public:
int bar(char); // Member function with 1 argument
};
int main()
{
A a; // an instance of class A
int foo(double, long); // Global function with 2 arguments
// Create an RWTFunctorR0 set to call foo(3.14,11):
= rwtMakeFunctorR0GA2(int, int, foo, double, 3.14, long, 11);
// Create an RWTFunctorR0 set to call a.bar('x'):
= rwtMakeFunctorR0MA1(int, A, a, int, &A::bar, char, 'x');
int result1 = t1();
int result2 = t2();
return 0;
}

Macros (for Use With Global Functions)

The macros in this section use the following naming conventions for the macro arguments:

SR The actual type name to be used to instantiate the RWTFunctorR0.
DR Type name of the function return value. DR must be convertible to SR.
function Global function pointer.
A1 Type name of the first argument.
a1 Expression that can be converted to an instance of A1.
A2 Type name of the second argument.
a2 Expression that can be converted to an instance of A2.
A3 Type name of the third argument.
a3 Expression that can be converted to an instance of A3.

Macros (for Use With Member Functions)

The macros in this section use the following naming conventions for the macro arguments:

SR The actual type name to be used to instantiate the RWTFunctorR0.
Callee Type name of the function's class.
callee Expression that results in a reference to a Callee instance.
DR Type name of the function return value. DR must be convertible to SR.
function Pointer to member function of class Callee
A1 Type name of the first argument.
a1 Expression that can be converted to an instance of A1.
A2 Type name of the second argument.
a2 Expression that can be converted to an instance of A2.
A3 Type name of the third argument.
a3 Expression that can be converted to an instance of A3.
See also
RWTFunctorR0, RWTFunctorR0Imp

Macros

#define rwtMakeFunctorR0G(SR, DR, function)
 
#define rwtMakeFunctorR0GA1(SR, DR, function, A1, a1)
 
#define rwtMakeFunctorR0GA2(SR, DR, function, A1, a1, A2, a2)
 
#define rwtMakeFunctorR0GA3(SR, DR, function, A1, a1, A2, a2, A3, a3)
 
#define rwtMakeFunctorR0M(SR, Callee, callee, DR, function)
 
#define rwtMakeFunctorR0MA1(SR, Callee, callee, DR, function, A1, a1)
 
#define rwtMakeFunctorR0MA2(SR, Callee, callee, DR, function, A1, a1, A2, a2)
 
#define rwtMakeFunctorR0MA3(SR, Callee, callee, DR, function, A1, a1, A2, a2, A3, a3)
 

Functions

template<class SR , class DR >
RWTFunctorR0< SR > rwtMakeFunctorR0 (SR(*caller)(void), DR(*callee)(void))
 
template<class SR , class DR , class A1 , class AA1 >
RWTFunctorR0< SR > rwtMakeFunctorR0 (SR(*caller)(void), DR(*callee)(A1), AA1 a1)
 
template<class SR , class DR , class A1 , class A2 , class AA1 , class AA2 >
RWTFunctorR0< SR > rwtMakeFunctorR0 (SR(*caller)(void), DR(*callee)(A1, A2), AA1 a1, AA2 a2)
 
template<class SR , class DR , class A1 , class A2 , class A3 , class AA1 , class AA2 , class AA3 >
RWTFunctorR0< SR > rwtMakeFunctorR0 (SR(*caller)(void), DR(*callee)(A1, A2, A3), AA1 a1, AA2 a2, AA3 a3)
 
template<class SR , class Callee , class DR >
RWTFunctorR0< SR > rwtMakeFunctorR0 (SR(*caller)(void), Callee &callee, DR(Callee::*function)(void))
 
template<class SR , class Callee , class DR , class A1 , class AA1 >
RWTFunctorR0< SR > rwtMakeFunctorR0 (SR(*caller)(void), Callee &callee, DR(Callee::*function)(A1), AA1 a1)
 
template<class SR , class Callee , class DR , class A1 , class A2 , class AA1 , class AA2 >
RWTFunctorR0< SR > rwtMakeFunctorR0 (SR(*caller)(void), Callee &callee, DR(Callee::*function)(A1, A2), AA1 a1, AA2 a2)
 
template<class SR , class Callee , class DR , class A1 , class A2 , class A3 , class AA1 , class AA2 , class AA3 >
RWTFunctorR0< SR > rwtMakeFunctorR0 (SR(*caller)(void), Callee &callee, DR(Callee::*function)(A1, A2, A3), AA1 a1, AA2 a2, AA3 a3)
 

Macro Definition Documentation

#define rwtMakeFunctorR0G (   SR,
  DR,
  function 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function) instead.

Macro to create an RWTFunctorR0 set to call function(). function must have signature DR (*)(void).

#define rwtMakeFunctorR0GA1 (   SR,
  DR,
  function,
  A1,
  a1 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, a1) instead.

Macro to create an RWTFunctorR0 set to call function(a1). function must have signature DR (*)(A1).

#define rwtMakeFunctorR0GA2 (   SR,
  DR,
  function,
  A1,
  a1,
  A2,
  a2 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, a1, a2) instead.

Macro to create an RWTFunctorR0 set to call function(a1,a2). function must have signature DR (*)(A1,A2).

#define rwtMakeFunctorR0GA3 (   SR,
  DR,
  function,
  A1,
  a1,
  A2,
  a2,
  A3,
  a3 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, a1, a2, a3) instead.

Macro to create an RWTFunctorR0 set to call function(a1,a2,a3). function must have signature DR (*)(A1,A2,A3).

#define rwtMakeFunctorR0M (   SR,
  Callee,
  callee,
  DR,
  function 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee) instead.

Macro to create an RWTFunctorR0 set to call callee.function(). function must have signature DR (Caller::*)(void).

#define rwtMakeFunctorR0MA1 (   SR,
  Callee,
  callee,
  DR,
  function,
  A1,
  a1 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee, a1) instead.

Macro to create an RWTFunctorR0 set to call callee.function(a1). function must have signature DR (Caller::*)(A1).

#define rwtMakeFunctorR0MA2 (   SR,
  Callee,
  callee,
  DR,
  function,
  A1,
  a1,
  A2,
  a2 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee, a1, a2) instead.

Macro to create an RWTFunctorR0 set to call callee.function(a1,a2). function must have signature DR (Caller::*)(A1,A2).

#define rwtMakeFunctorR0MA3 (   SR,
  Callee,
  callee,
  DR,
  function,
  A1,
  a1,
  A2,
  a2,
  A3,
  a3 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee, a1, a2, a3) instead.

Macro to create an RWTFunctorR0 set to call callee.function(a1,a2,a3). function must have signature DR (Caller::*)(A1,A2,A3).

Function Documentation

template<class SR , class DR >
RWTFunctorR0<SR> rwtMakeFunctorR0 ( SR(*)(void)  caller,
DR(*)(void)  callee 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function) instead.

Template function to create an RWTFunctorR0 set to call callee().

Note
  • The caller parameter is used only to allow the compiler to deduce type SR. You may use any function with an appropriate signature or simply pass a NULL pointer cast to the appropriate type as done in the example above.
  • DR must be convertible to SR.
template<class SR , class DR , class A1 , class AA1 >
RWTFunctorR0<SR> rwtMakeFunctorR0 ( SR(*)(void)  caller,
DR(*)(A1)  callee,
AA1  a1 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, a1) instead.

Template function to create an RWTFunctorR0 set to call callee(a1).

Note
  • The caller parameter is used only to allow the compiler to deduce type SR. You may use any function with an appropriate signature or simply pass a NULL pointer cast to the appropriate type as done in the example above.
  • DR must be convertible to SR.
  • a1 must be convertible to instance of type A1.
template<class SR , class DR , class A1 , class A2 , class AA1 , class AA2 >
RWTFunctorR0<SR> rwtMakeFunctorR0 ( SR(*)(void)  caller,
DR(*)(A1, A2)  callee,
AA1  a1,
AA2  a2 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, a1, a2) instead.

Template function to create an RWTFunctorR0 set to call callee(a1, a2).

Note
  • The caller parameter is used only to allow the compiler to deduce type SR. You may use any function with an appropriate signature or simply pass a NULL pointer cast to the appropriate type as done in the example above.
  • DR must be convertible to SR.
  • a1 and a2 must be convertible to instances of types A1 and A2 respectively.
template<class SR , class DR , class A1 , class A2 , class A3 , class AA1 , class AA2 , class AA3 >
RWTFunctorR0<SR> rwtMakeFunctorR0 ( SR(*)(void)  caller,
DR(*)(A1, A2, A3)  callee,
AA1  a1,
AA2  a2,
AA3  a3 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, a1, a2, a3) instead.

Template function to create an RWTFunctorR0 set to call callee(a1, a2, a3).

Note
  • The caller parameter is used only to allow the compiler to deduce type SR. You may use any function with an appropriate signature or simply pass a NULL pointer cast to the appropriate type as done in the example above.
  • DR must be convertible to SR.
  • a1, a2 and a3 must be convertible to instances of types A1, A2 and A3 respectively.
template<class SR , class Callee , class DR >
RWTFunctorR0<SR> rwtMakeFunctorR0 ( SR(*)(void)  caller,
Callee &  callee,
DR(Callee::*)(void)  function 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee) instead.

Template function to create an RWTFunctorR0 set to call callee.function().

Note
  • The caller parameter is used only to allow the compiler to deduce type SR. You may use any function with an appropriate signature or simply pass a NULL pointer cast to the appropriate type as done in the example above.
  • DR must be convertible to SR.
template<class SR , class Callee , class DR , class A1 , class AA1 >
RWTFunctorR0<SR> rwtMakeFunctorR0 ( SR(*)(void)  caller,
Callee &  callee,
DR(Callee::*)(A1)  function,
AA1  a1 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee, a1) instead.

Template function to create an RWTFunctorR0 set to call callee.function(a1).

Note
  • The caller parameter is used only to allow the compiler to deduce type SR. You may use any function with an appropriate signature or simply pass a NULL pointer cast to the appropriate type as done in the example above.
  • DR must be convertible to SR.
  • a1 must be convertible to instance of type A1.
template<class SR , class Callee , class DR , class A1 , class A2 , class AA1 , class AA2 >
RWTFunctorR0<SR> rwtMakeFunctorR0 ( SR(*)(void)  caller,
Callee &  callee,
DR(Callee::*)(A1, A2)  function,
AA1  a1,
AA2  a2 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee, a1, a2) instead.

Template function to create an RWTFunctorR0 set to call callee.function(a1, a2).

Note
  • The caller parameter is used only to allow the compiler to deduce type SR. You may use any function with an appropriate signature or simply pass a NULL pointer cast to the appropriate type as done in the example above.
  • DR must be convertible to SR.
  • a1 and a2 must be convertible to instances of types A1 and A2 respectively.
template<class SR , class Callee , class DR , class A1 , class A2 , class A3 , class AA1 , class AA2 , class AA3 >
RWTFunctorR0<SR> rwtMakeFunctorR0 ( SR(*)(void)  caller,
Callee &  callee,
DR(Callee::*)(A1, A2, A3)  function,
AA1  a1,
AA2  a2,
AA3  a3 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee, a1, a2, a3) instead.

Template function to create an RWTFunctorR0 set to call callee.function(a1,a2,a3).

Note
  • The caller parameter is used only to allow the compiler to deduce type SR. You may use any function with an appropriate signature or simply pass a NULL pointer cast to the appropriate type as done in the example above.
  • DR must be convertible to SR.
  • a1, a2 and a3 must be convertible to instances of types A1, A2 and A3 respectively.

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