SourcePro® API Reference Guide

 
List of all members | Public Types | Public Member Functions
RWTFunctor1< S1 > Class Template Reference

Deprecated. A functor that is invoked with one argument, and whose invocation returns no value. More...

#include <rw/functor/RWTFunctor1.h>

Inheritance diagram for RWTFunctor1< S1 >:
RWTFunctorList1< S1 >

Public Types

typedef void(* CallerSignature) (S1)
 
typedef S1 S1Type
 

Public Member Functions

 RWTFunctor1 (void)
 
 RWTFunctor1 (RWStaticCtor)
 
 RWTFunctor1 (RWTFunctor1Imp< S1 > *functorImp)
 
 RWTFunctor1 (const RWTFunctor1< S1 > &second)
 
 RWTFunctor1 (const RWTFunctor< void(S1)> &second)
 
 ~RWTFunctor1 (void)
 
RWTFunctor1Imp< S1 > & body (void) const
 
RWTFunctor1< S1 > & operator= (const RWTFunctor1< S1 > &second)
 
RWTFunctor1< S1 > & operator= (const RWTFunctor< void(S1)> &second)
 

Detailed Description

template<class S1>
class RWTFunctor1< S1 >

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

RWTFunctor1 represents the group of functors that are invoked with one argument, and whose invocation returns no 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 class RWTFunctor1 act as handles to functor implementations or bodies. Such implementations are created by using either the rwtMakeFunctor1() 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 and returns no value, the encapsulated function may have more arguments and a return value.

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.

Any return value that the function may have is ignored by the functor, and hence not passed back to the user. If you are interested in the function's return value, see the RWTFunctorR2 group of classes.

Example
#include <iostream>
#include <rw/functor/functor1.h>
void foo(int x)
{
std::cout << "x is " << x << std::endl;
}
int main()
{
// Create a handle, and assign a new body to it.
RWTFunctor1<int> functor =
rwtMakeFunctor1((void(*)(int))0, foo);
// Invoke the functor with one caller argument.
functor(42);
return 0;
}

OUTPUT:

x is 42
See also
rwtMakeFunctor1()

Member Typedef Documentation

template<class S1>
typedef void(* RWTFunctor1< S1 >::CallerSignature) (S1)

The signature of the functor invocation.

template<class S1>
typedef S1 RWTFunctor1< S1 >::S1Type

The type of the caller argument.

Constructor & Destructor Documentation

template<class S1>
RWTFunctor1< S1 >::~RWTFunctor1 ( void  )

Destructor.

template<class S1>
RWTFunctor1< S1 >::RWTFunctor1 ( void  )

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

template<class S1>
RWTFunctor1< S1 >::RWTFunctor1 ( RWStaticCtor  )

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

template<class S1>
RWTFunctor1< S1 >::RWTFunctor1 ( RWTFunctor1Imp< S1 > *  functorImp)

Body constructor. Constructs a new RWTFunctor1 handle from an existing body.

template<class S1>
RWTFunctor1< S1 >::RWTFunctor1 ( const RWTFunctor1< S1 > &  second)

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

template<class S1>
RWTFunctor1< S1 >::RWTFunctor1 ( const RWTFunctor< void(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

template<class S1 >
RWTFunctor1Imp< S1 > & RWTFunctor1< 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 RWTFunctor1Imp.
template<class S1>
RWTFunctor1<S1>& RWTFunctor1< S1 >::operator= ( const RWTFunctor1< 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.

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