SourcePro® API Reference Guide

 
List of all members | Public Types | Public Member Functions
RWFunctor0 Class Reference

Deprecated. Represents the group of functors that are invoked without any arguments and whose invocation returns no value. More...

#include <rw/functor/RWFunctor0.h>

Inheritance diagram for RWFunctor0:
RWFunctorList0

Public Types

typedef void(* CallerSignature) (void)
 

Public Member Functions

 RWFunctor0 (void)
 
 RWFunctor0 (RWStaticCtor)
 
 RWFunctor0 (RWFunctor0Imp *functorImp)
 
 RWFunctor0 (const RWFunctor0 &second)
 
 RWFunctor0 (const RWTFunctor< void()> &second)
 
 ~RWFunctor0 (void)
 
RWFunctor0Impbody (void) const
 
RWFunctor0operator= (const RWFunctor0 &second)
 
RWFunctor0operator= (const RWTFunctor< void()> &second)
 

Detailed Description

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

RWFunctor0 represents the group of functors that are invoked without any arguments 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 RWFunctor0 act as handles to functor implementations or bodies. Such implementations are created by using either the rwtMakeFunctor0() 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 and returns no value, the encapsulated function may have both arguments and a return value.

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.

Any function return value 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 RWTFunctorR0 group of classes.

Example
#include <iostream>
#include <rw/functor/functor0.h>
// A function to be encapsulated in a functor.
void print()
{
std::cout << "Hello World" << std::endl;
}
int main()
{
// Create a handle ('functor'), and
// assign a new body to it.
RWFunctor0 functor = rwtMakeFunctor0((void(*)())0, print);
// Invoking the functor will print "Hello World."
functor();
return 0;
}

OUTPUT:

Hello World
See also
rwtMakeFunctor0()

Member Typedef Documentation

typedef void(* RWFunctor0::CallerSignature) (void)

The signature of the functor invocation.

Constructor & Destructor Documentation

RWFunctor0::RWFunctor0 ( void  )

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

RWFunctor0::RWFunctor0 ( 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.

RWFunctor0::RWFunctor0 ( RWFunctor0Imp functorImp)

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

RWFunctor0::RWFunctor0 ( const RWFunctor0 second)

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

RWFunctor0::RWFunctor0 ( const RWTFunctor< void()> &  second)

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

RWFunctor0::~RWFunctor0 ( void  )

Destructor.

Member Function Documentation

RWFunctor0Imp & RWFunctor0::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 RWFunctor0Imp.
RWFunctor0& RWFunctor0::operator= ( const RWFunctor0 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.

RWFunctor0& RWFunctor0::operator= ( const RWTFunctor< void()> &  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.