SourceForge.net Logo

eval::fwrap Class Reference

A generic class for wrapping functions, methods and constructors. More...

#include <fwrap.hpp>

Collaboration diagram for eval::fwrap:

Collaboration graph
[legend]

List of all members.

Public Member Functions

template<typename T>
 fwrap (T fp)
 fwrap ()
 fwrap (const fwrap &other)
void swap (fwrap &other)
fwrapoperator= (fwrap rhs)
bool is_null () const
val operator() (fwrap_args &args) const
 Calls the underlying function.
unsigned int arity () const
 Includes object instance for methods.
fwrap_fn_type fn_type () const
arg_info get_rv_info () const
void get_arg_info (std::vector< arg_info > &vec) const
 For methods, type of first argument (object instance) will be pointer.
 ~fwrap ()

Static Public Member Functions

template<typename ObjT, typename T>
static fwrap wrap_ctor ()
 Wrap a constructor.

Private Types

enum  ctor_overload_resolution { USE_PRIVATE_CONSTRUCTOR }

Private Member Functions

 fwrap (const detail::fwrap_store_base *store, const ctor_overload_resolution &)

Private Attributes

const detail::fwrap_store_base_store


Detailed Description

A generic class for wrapping functions, methods and constructors.

fwrap is not a template class. No matter what an fwrap instance wraps, it is called in the same way, by passing in a container (i.e. vector) of eval::val. Similarly, the return value of calling a wrapped function will always be an eval::val.


Member Enumeration Documentation

Enumerator:
USE_PRIVATE_CONSTRUCTOR 


Constructor & Destructor Documentation

template<typename T>
eval::fwrap::fwrap ( fp  )  [inline, explicit]

Wrap a function or method.

Precondition:
fp is a function or method pointer.
Note:
Volatile functions, variadic functions, default argument values and different call types are not supported.
See also:
wrap_ctor()

eval::fwrap::fwrap (  )  [inline]

eval::fwrap::fwrap ( const fwrap other  )  [inline]

eval::fwrap::~fwrap (  )  [inline]

eval::fwrap::fwrap ( const detail::fwrap_store_base store,
const ctor_overload_resolution  
) [inline, explicit, private]


Member Function Documentation

template<typename ObjT, typename T>
static fwrap eval::fwrap::wrap_ctor (  )  [inline, static]

Wrap a constructor.

The fwrap object returned is conceptually equivalent to a factory function. The return value from its invocation (an eval::val) assumes ownership of the actual created instance. ObjT is the type of object the factory should create.

Precondition:
T must be a function pointer, returning void, where the parameter types indicate the parameters of the constructor to be wrapped. e.g.
 void (*)(Param1Type, Param2Type) 

void eval::fwrap::swap ( fwrap other  )  [inline]

fwrap& eval::fwrap::operator= ( fwrap  rhs  )  [inline]

bool eval::fwrap::is_null (  )  const [inline]

Returns:
True iff the object was default constructed or NULL was passed in to the constructor, where a pointer was expected.

val eval::fwrap::operator() ( fwrap_args args  )  const [inline]

Calls the underlying function.

An attempt is made to convert the objects in args to the type required by the underlying function/method. Pass by value, reference or pointer are supported and handled implicitly. E.g. an eval::val may store a const int, in which case it could be used as a const int *, an int or a const int &, depending on what the underlying function requires. The val returned will assume ownership of the actual return value only if the underlying function returns by value. Otherwise, the val object will essentially use eval::UNMANAGED_PTR semantics. This may not be desirable if the function returns a pointer to one of its arguments for example (or a pointer generated using new).

Exceptions:
null_ptr_exception if is_null()
arity_mismatch_exception if the number of arguments is wrong
bad_val_cast if a conversion is not possible
See also:
execution_context::call() fixes some of the shortcomings of this method.
Note:
An empty val may be taken as a NULL pointer.

unsigned int eval::fwrap::arity (  )  const [inline]

Includes object instance for methods.

fwrap_fn_type eval::fwrap::fn_type (  )  const [inline]

arg_info eval::fwrap::get_rv_info (  )  const [inline]

void eval::fwrap::get_arg_info ( std::vector< arg_info > &  vec  )  const [inline]

For methods, type of first argument (object instance) will be pointer.


Member Data Documentation


The documentation for this class was generated from the following file:

Generated on Sat Sep 20 20:02:34 2008 for eval by  doxygen 1.5.6