SourcePro® API Reference Guide

 
List of all members | Public Types | Public Member Functions
RWTFunctorR0< SR > Class Template Reference

Deprecated. A functor that is invoked without any arguments and whose invocation returns a value. More...

#include <rw/functor/RWTFunctorR0.h>

Inherits RWTFunctor< T >.

Public Types

typedef SR(* CallerSignature) (void)
 
typedef SR SRType
 

Public Member Functions

 RWTFunctorR0 (void)
 
 RWTFunctorR0 (RWStaticCtor)
 
 RWTFunctorR0 (RWTFunctorR0Imp< SR > *functorImp)
 
 RWTFunctorR0 (const RWTFunctorR0< SR > &second)
 
 RWTFunctorR0 (const RWTFunctor< SR()> &second)
 
 ~RWTFunctorR0 (void)
 
RWTFunctorR0Imp< SR > & body (void) const
 
RWTFunctorR0< SR > & operator= (const RWTFunctorR0< SR > &second)
 
RWTFunctorR0< SR > & operator= (const RWTFunctor< SR()> &second)
 

Detailed Description

template<class SR>
class RWTFunctorR0< SR >

Deprecated:
As of SourcePro 12.5, use RWTFunctor<R(As...)> instead.

RWTFunctorR0 represents the group of functors that are invoked without any arguments, 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 RWTFunctorR0 act as handles to functor implementations or bodies. Such implementations are created by using either the rwtMakeFunctorR0() 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 no arguments, the encapsulated function may have up to three arguments.

The 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/functorR0.h>
// A function to be encapsulated in a functor.
int flag = 0;
int getFlag()
{
return flag;
}
int main()
{
// Create a handle ('functor'), and assign a body to it.
rwtMakeFunctorR0((int(*)(void))0, getFlag);
// Invoking the functor will return the value of flag
int flag_value = functor();
return 0;
}
See also
rwtMakeFunctorR0()

Member Typedef Documentation

template<class SR>
typedef SR(* RWTFunctorR0< SR >::CallerSignature) (void)

The signature of the functor invocation.

template<class SR>
typedef SR RWTFunctorR0< SR >::SRType

The return type of the functor.

Constructor & Destructor Documentation

template<class SR>
RWTFunctorR0< SR >::RWTFunctorR0 ( void  )

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

template<class SR>
RWTFunctorR0< SR >::RWTFunctorR0 ( 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.

template<class SR>
RWTFunctorR0< SR >::~RWTFunctorR0 ( void  )

Destructor.

template<class SR>
RWTFunctorR0< SR >::RWTFunctorR0 ( RWTFunctorR0Imp< SR > *  functorImp)

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

template<class SR>
RWTFunctorR0< SR >::RWTFunctorR0 ( const RWTFunctorR0< SR > &  second)

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

template<class SR>
RWTFunctorR0< SR >::RWTFunctorR0 ( const RWTFunctor< SR()> &  second)

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

Member Function Documentation

template<class SR >
RWTFunctorR0Imp< SR > & RWTFunctorR0< SR >::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 RWTFunctorR0Imp.
template<class SR>
RWTFunctorR0<SR>& RWTFunctorR0< SR >::operator= ( const RWTFunctorR0< SR > &  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.

template<class SR>
RWTFunctorR0<SR>& RWTFunctorR0< SR >::operator= ( const RWTFunctor< SR()> &  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 © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.