SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWTFunctorR1< SR, S1 > Class Template Reference

Deprecated. Represents the group of functors that are invoked with one argument, and whose invocation returns a value. More...

#include <rw/functor/RWTFunctorR1.h>

Inherits RWTFunctor< T >.

Public Types

typedef SR(* CallerSignature) (S1)
 
typedef S1 S1Type
 
typedef SR SRType
 

Public Member Functions

 RWTFunctorR1 (const RWTFunctor< SR(S1)> &second)
 
 RWTFunctorR1 (const RWTFunctorR1< SR, S1 > &second)
 
 RWTFunctorR1 (RWStaticCtor)
 
 RWTFunctorR1 (RWTFunctorR1Imp< SR, S1 > *functorImp)
 
 RWTFunctorR1 (void)
 
 ~RWTFunctorR1 (void)
 
RWTFunctorR1Imp< SR, S1 > & body (void) const
 
RWTFunctorR1< SR, S1 > & operator= (const RWTFunctor< SR(S1)> &second)
 
RWTFunctorR1< SR, S1 > & operator= (const RWTFunctorR1< SR, S1 > &second)
 

Detailed Description

template<class SR, class S1>
class RWTFunctorR1< SR, S1 >
Deprecated
As of SourcePro 12.5, use RWTFunctor<R(As...)> instead.

RWTFunctorR1 represents the group of functors that are invoked with one argument, and whose invocation returns a value.

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

Instances of RWTFunctorR1 act as handles to functor implementations or bodies. Such implementations are created by using either the rwtMakeFunctorR1() global functions or macros. Each of these methods creates a new body instance, and returns the handle to that instance. See the example below.

Note that although an instance of this class is invoked with one argument, the encapsulated function may have more arguments.

The additional arguments to be passed to the encapsulated function are provided to the functor at the time of creation. They are stored within the functor object, and are retrieved at the time of invocation.

Example
#include <rw/functor/functorR1.h>
// A function to be encapsulated in a functor.
int flag = 0;
int setFlag(short f) { return flag = f; }
int main() {
// Create a new handle (functor) and assign a new body to it.
rwtMakeFunctorR1((int (*)(short))0, setFlag);
// Invoking the functor with '32' will set the global flag to
// 32 and return the value '32'
int new_value = functor(32);
return 0;
}
Deprecated. Represents the group of functors that are invoked with one argument, and whose invocation...
Definition RWTFunctorR1.h:134
RWTFunctorR1< SR, S1 > rwtMakeFunctorR1(SR(*caller)(S1), DR(*callee)(D1))
Definition rwtMakeFunctorR1.h:87
See also
rwtMakeFunctorR1()

Member Typedef Documentation

◆ CallerSignature

template<class SR , class S1 >
typedef SR(* RWTFunctorR1< SR, S1 >::CallerSignature) (S1)

The signature of the functor invocation.

◆ S1Type

template<class SR , class S1 >
typedef S1 RWTFunctorR1< SR, S1 >::S1Type

The type of the first caller argument.

◆ SRType

template<class SR , class S1 >
typedef SR RWTFunctorR1< SR, S1 >::SRType

The type of the functor's return value.

Constructor & Destructor Documentation

◆ ~RWTFunctorR1()

template<class SR , class S1 >
RWTFunctorR1< SR, S1 >::~RWTFunctorR1 ( void )

Destructor.

◆ RWTFunctorR1() [1/5]

template<class SR , class S1 >
RWTFunctorR1< SR, S1 >::RWTFunctorR1 ( void )

Constructs an empty, invalid, handle instance. To create a viable handle, use the rwtMakeFunctor1() global functions or macros.

◆ RWTFunctorR1() [2/5]

template<class SR , class S1 >
RWTFunctorR1< SR, S1 >::RWTFunctorR1 ( RWStaticCtor )

Constructs a global static handle instance. The constructor does not reset any values that may have been set in invocations prior to the constructor call.

◆ RWTFunctorR1() [3/5]

template<class SR , class S1 >
RWTFunctorR1< SR, S1 >::RWTFunctorR1 ( RWTFunctorR1Imp< SR, S1 > * functorImp)

Body constructor. Binds a new handle instance to an existing functor body instance.

◆ RWTFunctorR1() [4/5]

template<class SR , class S1 >
RWTFunctorR1< SR, S1 >::RWTFunctorR1 ( const RWTFunctorR1< SR, S1 > & second)

Copy constructor. Binds a new handle instance to the functor body instance, if any, associated with the second handle instance.

◆ RWTFunctorR1() [5/5]

template<class SR , class S1 >
RWTFunctorR1< SR, S1 >::RWTFunctorR1 ( const RWTFunctor< SR(S1)> & second)

Conversion constructor. Binds a new handle instance to the functor body instance, if any, associated with the second handle instance.

Member Function Documentation

◆ body()

template<class SR , class S1 >
RWTFunctorR1Imp< SR, S1 > & RWTFunctorR1< SR, S1 >::body ( void ) const
inline

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

Exceptions
RWTHRInvalidPointerThrown if the handle has no associated body.
std::bad_castThrown if the body is not of type RWTFunctorR1Imp.

◆ operator=() [1/2]

template<class SR , class S1 >
RWTFunctorR1< SR, S1 > & RWTFunctorR1< SR, S1 >::operator= ( const RWTFunctor< SR(S1)> & second)

Assignment operator. Detaches this handle instance from any functor body instance it currently references, and binds it to the functor body instance, if any, associated with the second handle instance.

◆ operator=() [2/2]

template<class SR , class S1 >
RWTFunctorR1< SR, S1 > & RWTFunctorR1< SR, S1 >::operator= ( const RWTFunctorR1< SR, S1 > & second)

Assignment operator. Detaches this handle instance from any functor body instance it currently references, and binds it to the functor body instance, if any, associated with the second handle instance.

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