SourcePro® API Reference Guide

 
Macros | Functions
rwtMakeFunctorR2 Macros and Functions

Module Description

Header File
#include <rw/functor/functorR2.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 rwtMakeFunctorR2() functions and macros are provided to construct functors based on the RWTFunctorR2 class. The RWTFunctorR2 class acts as the handle for a family of functor implementation classes based on the RWTFunctorR2Imp class. A functor based on RWTFunctorR2 is invoked with one argument and returns a value of type SR, while the implementation classes can accept functions with up to two additional 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 rwtMakeFunctorR2() function or macro instantiates and constructs an appropriate functor implementation class instance and returns an RWTFunctorR2 handle that is bound to that instance.

rwtMakeFunctorR2() 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 rwtMakeFunctorR2(), 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 additional arguments. Otherwise we add one of A1 or A2 for functions with 1 or 2 additional arguments respectively. For example, you will use macro rwtMakeFunctorR2G() to create a functor that calls a global function that takes no additional arguments. The macro rwtMakeFunctorR2MA2() will create a functor that calls a member function that takes two additional arguments.

Example

Example Using Templates

#include <rw/functor/functorR2.h>
class A {
public:
int bar(char,int); // Member function with 2 args
// (no additional)
};
int main()
{
A a; // an instance of class A
float s1;
int s2;
char c1, c2;
// Global function with 3 args (1 additional):
int foo(double, long, char);
// Create an RWTFunctorR2 set to call foo(s1,s2,11):
= rwtMakeFunctorR2((int(*)(float,int))NULL, foo, 11);
// Create an RWTFunctorR2 set to call a.bar(c1,c2):
= rwtMakeFunctorR2((int(*)(char,char))NULL, a, &A::bar);
s1 = 3.14; s2 = 1.41;
c1 = 'x'; c2 = 'y';
int result1 = t1(s1,s2); // calls foo(s1,s2,11);
int result2 = t2(c1,c2); // calls a.bar(c1,c2);
return 0;
}

Example Using Macros

#include <rw/functor/functorR2.h>
class A {
public:
int bar(char,int); // Member function with 2 args
// (no additional)
};
int main()
{
A a; // an instance of class A
float s1;
int s2;
char c1, c2;
// Global function with 3 args (1 additional):
int foo(double, long, char);
// Create an RWTFunctorR2 set to call foo(s1,s2,11):
= rwtMakeFunctorR2GA1(int,float,int,int,foo,
double,long,char,11);
// Create an RWTFunctorR2 set to call a.bar(c1,c2):
= rwtMakeFunctorR2M(int,char,char,A,a,int,&A::bar,char,int);
s1 = 3.14; s2 = 1.41;
c1 = 'x'; c2 = 'y';
int result1 = t1(s1,s2); // calls foo(s1,s2,11);
int result2 = t2(c1,c2); // calls a.bar(c1,c2);
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 RWTFunctorR2.
S1 Type name of the first argument that will be expected when invoking the functor via RWTFunctorR2<SR,S1,S2>::operator()(S1,S2). S1 must be convertible to D1.
S2 Type name of the second argument that will be expected when invoking the functor via RWTFunctorR2<SR,S1,S2>::operator()(S1,S2). S2 must be convertible to D2.
DR Type name of the function return value. DR must be convertible to SR.
function Global function pointer.
D1 Type name of the first argument of the function.
D2 Type name of the second argument of the function.
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.
s1 Argument of type S1 that will be passed when invoking the functor.
s2 Argument of type S2 that will be passed when invoking the functor.

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 RWTFunctorR2.
S1 Type name of the first argument that will be expected when invoking the functor via RWTFunctorR2<SR,S1,S2>::operator()(S1,S2). S1 must be convertible to D1.
S2 Type name of the second argument that will be expected when invoking the functor via RWTFunctorR2<SR,S1,S2>::operator()(S1,S2). S2 must be convertible to D2.
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
D1 Type name of the first argument of the function.
D2 Type name of the second argument of the function.
D1 Type name of the first argument of the function.
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.
s1 Argument of type S1 that will be passed when invoking the functor.
s2 Argument of type S2 that will be passed when invoking the functor.
See also
RWTFunctorR2, RWTFunctorR2Imp

Macros

#define rwtMakeFunctorR2G(SR, S1, S2, DR, function, D1, D2)
 
#define rwtMakeFunctorR2GA1(SR, S1, S2, DR, function, D1, D2, A1, a1)
 
#define rwtMakeFunctorR2GA2(SR, S1, S2, DR, function, D1, D2, A1, a1, A2, a2)
 
#define rwtMakeFunctorR2M(SR, S1, S2, Callee, callee, DR, function, D1, D2)
 
#define rwtMakeFunctorR2MA1(SR, S1, S2, Callee, callee, DR, function, D1, D2, A1, a1)
 
#define rwtMakeFunctorR2MA2(SR, S1, S2, Callee, callee, DR, function, D1, D2, A1, a1, A2, a2)
 

Functions

template<class SR , class S1 , class S2 , class DR , class D1 , class D2 >
RWTFunctorR2< SR, S1, S2 > rwtMakeFunctorR2 (SR(*caller)(S1, S2), DR(*callee)(D1, D2))
 
template<class SR , class S1 , class S2 , class DR , class D1 , class D2 , class A1 , class AA1 >
RWTFunctorR2< SR, S1, S2 > rwtMakeFunctorR2 (SR(*caller)(S1, S2), DR(*callee)(D1, D2, A1), AA1 a1)
 
template<class SR , class S1 , class S2 , class DR , class D1 , class D2 , class A1 , class A2 , class AA1 , class AA2 >
RWTFunctorR2< SR, S1, S2 > rwtMakeFunctorR2 (SR(*caller)(S1, S2), DR(*callee)(D1, D2, A1, A2), AA1 a1, AA2 a2)
 
template<class SR , class S1 , class S2 , class Callee , class DR , class D1 , class D2 >
RWTFunctorR2< SR, S1, S2 > rwtMakeFunctorR2 (SR(*caller)(S1, S2), Callee &callee, DR(Callee::*function)(D1, D2))
 
template<class SR , class S1 , class S2 , class Callee , class DR , class D1 , class D2 , class A1 , class AA1 >
RWTFunctorR2< SR, S1, S2 > rwtMakeFunctorR2 (SR(*caller)(S1, S2), Callee &callee, DR(Callee::*function)(D1, D2, A1), AA1 a1)
 
template<class SR , class S1 , class S2 , class Callee , class DR , class D1 , class D2 , class A1 , class A2 , class AA1 , class AA2 >
RWTFunctorR2< SR, S1, S2 > rwtMakeFunctorR2 (SR(*caller)(S1, S2), Callee &callee, DR(Callee::*function)(D1, D2, A1, A2), AA1 a1, AA2 a2)
 

Macro Definition Documentation

#define rwtMakeFunctorR2G (   SR,
  S1,
  S2,
  DR,
  function,
  D1,
  D2 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, rw1, rw2) instead.

Macro to create an RWTFunctorR2 set to call function(s1,s2). function must have signature DR (*)(D1,D2)

#define rwtMakeFunctorR2GA1 (   SR,
  S1,
  S2,
  DR,
  function,
  D1,
  D2,
  A1,
  a1 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, rw1, rw2, a1) instead.

Macro to create an RWTFunctorR2 set to call function(s1,s2,a1). function must have signature DR (*)(D1,D2,A1)

#define rwtMakeFunctorR2GA2 (   SR,
  S1,
  S2,
  DR,
  function,
  D1,
  D2,
  A1,
  a1,
  A2,
  a2 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, rw1, rw2, a1, a2) instead.

Macro to create an RWTFunctorR2 set to call function(s1,s2,a1,a2). function must have signature DR (*)(D1,D2,A1,A2)

#define rwtMakeFunctorR2M (   SR,
  S1,
  S2,
  Callee,
  callee,
  DR,
  function,
  D1,
  D2 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee, rw1, rw2) instead.

Macro to create an RWTFunctorR2 set to call callee.function(s1,s2). function must have signature DR (Caller::*)(D1,D2)

#define rwtMakeFunctorR2MA1 (   SR,
  S1,
  S2,
  Callee,
  callee,
  DR,
  function,
  D1,
  D2,
  A1,
  a1 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee, rw1, rw2, a1) instead.

Macro to create an RWTFunctorR2 set to call callee.function(s1,s2,a1). function must have signature DR (Caller::*)(D1,D2,A1)

#define rwtMakeFunctorR2MA2 (   SR,
  S1,
  S2,
  Callee,
  callee,
  DR,
  function,
  D1,
  D2,
  A1,
  a1,
  A2,
  a2 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee, rw1, rw2, a1, a2) instead.

Macro to create an RWTFunctorR2 set to call callee.function(s1,s2,a1,a2). function must have signature DR (Caller::*)(D1,D2,A1,A2)

Function Documentation

template<class SR , class S1 , class S2 , class DR , class D1 , class D2 >
RWTFunctorR2<SR, S1, S2> rwtMakeFunctorR2 ( SR(*)(S1, S2)  caller,
DR(*)(D1, D2)  callee 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, rw1, rw2) instead.

Template function to create an RWTFunctorR2 set to call callee(s1,s2).

Note
  • s1 and s2 refers to the argument passed when invoking the functor via RWTFunctorR2<SR,S1,S2>::operator()(S1,S2). The arguments will be passed through to the associated function.
  • The caller parameter is used only to allow the compiler to deduce types SR, S1, and S2. 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.
  • Types S1 and S2 must be convertible to D1 and D2 respectively.
template<class SR , class S1 , class S2 , class DR , class D1 , class D2 , class A1 , class AA1 >
RWTFunctorR2<SR, S1, S2> rwtMakeFunctorR2 ( SR(*)(S1, S2)  caller,
DR(*)(D1, D2, A1)  callee,
AA1  a1 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, rw1, rw2, a1) instead.

Template function to create an RWTFunctorR2 set to call callee(s1,s2,a1).

Note
  • s1 and s2 refers to the argument passed when invoking the functor via RWTFunctorR2<SR,S1,S2>::operator()(S1,S2). The arguments will be passed through to the associated function.
  • The caller parameter is used only to allow the compiler to deduce types SR, S1, and S2. 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.
  • Types S1 and S2 must be convertible to D1 and D2 respectively.
  • a1 must be convertible to instance of type A1.
template<class SR , class S1 , class S2 , class DR , class D1 , class D2 , class A1 , class A2 , class AA1 , class AA2 >
RWTFunctorR2<SR, S1, S2> rwtMakeFunctorR2 ( SR(*)(S1, S2)  caller,
DR(*)(D1, D2, A1, A2)  callee,
AA1  a1,
AA2  a2 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, rw1, rw2, a1, a2) instead.

Template function to create an RWTFunctorR2 set to call callee(s1,s2,a1,a2).

Note
  • s1 and s2 refers to the argument passed when invoking the functor via RWTFunctorR2<SR,S1,S2>::operator()(S1,S2). The arguments will be passed through to the associated function.
  • The caller parameter is used only to allow the compiler to deduce types SR, S1, and S2. 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.
  • Types S1 and S2 must be convertible to D1 and D2 respectively.
  • a1 and a2 must be convertible to instances of types A1 and A2 respectively.
template<class SR , class S1 , class S2 , class Callee , class DR , class D1 , class D2 >
RWTFunctorR2<SR, S1, S2> rwtMakeFunctorR2 ( SR(*)(S1, S2)  caller,
Callee &  callee,
DR(Callee::*)(D1, D2)  function 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee, rw1, rw2) instead.

Template function to create an RWTFunctorR2 set to call callee.function(s1,s2).

Note
  • s1 and s2 refers to the argument passed when invoking the functor via RWTFunctorR2<SR,S1,S2>::operator()(S1,S2). The arguments will be passed through to the associated function.
  • The caller parameter is used only to allow the compiler to deduce types SR, S1, and S2. 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.
  • Types S1 and S2 must be convertible to D1 and D2 respectively.
template<class SR , class S1 , class S2 , class Callee , class DR , class D1 , class D2 , class A1 , class AA1 >
RWTFunctorR2<SR, S1, S2> rwtMakeFunctorR2 ( SR(*)(S1, S2)  caller,
Callee &  callee,
DR(Callee::*)(D1, D2, A1)  function,
AA1  a1 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee, rw1, rw2, a1) instead.

Template function to create an RWTFunctorR2 set to call callee.function(s1,s2,a1).

Note
  • s1 and s2 refers to the argument passed when invoking the functor via RWTFunctorR2<SR,S1,S2>::operator()(S1,S2). The arguments will be passed through to the associated function.
  • The caller parameter is used only to allow the compiler to deduce types SR, S1, and S2. 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.
  • Types S1 and S2 must be convertible to D1 and D2 respectively.
  • a1 must be convertible to instance of type A1.
template<class SR , class S1 , class S2 , class Callee , class DR , class D1 , class D2 , class A1 , class A2 , class AA1 , class AA2 >
RWTFunctorR2<SR, S1, S2> rwtMakeFunctorR2 ( SR(*)(S1, S2)  caller,
Callee &  callee,
DR(Callee::*)(D1, D2, A1, A2)  function,
AA1  a1,
AA2  a2 
)
Deprecated:
As of SourcePro 12.5, use rwBind(function, callee, rw1, rw2, a1, a2) instead.

Template function to create an RWTFunctorR2 set to call callee.function(s1,s2,a1,a2).

Note
  • s1 and s2 refers to the argument passed when invoking the functor via RWTFunctorR2<SR,S1,S2>::operator()(S1,S2). The arguments will be passed through to the associated function.
  • The caller parameter is used only to allow the compiler to deduce types SR, S1, and S2. 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.
  • Types S1 and S2 must be convertible to D1 and D2 respectively.
  • a1 and a2 must be convertible to instances of types A1 and A2 respectively.

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