Pothos  0.4.3-gabce2ce6
The Pothos dataflow programming software suite
Public Member Functions | Static Public Member Functions | Friends | List of all members
Pothos::Callable Class Reference

#include <Callable.hpp>

Inheritance diagram for Pothos::Callable:
Inheritance graph
[legend]

Public Member Functions

 Callable (void)
 
 operator bool (void) const
 
Object opaqueCall (const Object *inputArgs, const size_t numArgs) const
 
size_t getNumArgs (void) const
 
const std::type_info & type (const int argNo) const
 
template<typename ValueType >
Callablebind (ValueType &&val, const size_t argNo)
 
Callablebind (Object &&val, const size_t argNo)
 
Callableunbind (const size_t argNo)
 
std::string toString (void) const
 
template<typename ReturnType , typename ClassType , typename... ArgsType>
 Callable (ReturnType(ClassType::*fcn)(ArgsType...))
 Create a Callable for a class method with variable args. More...
 
template<typename ReturnType , typename ClassType , typename... ArgsType>
 Callable (ReturnType(ClassType::*fcn)(ArgsType...) const)
 Create a Callable for a const class method with variable args. More...
 
template<typename ReturnType , typename... ArgsType>
 Callable (ReturnType(*fcn)(ArgsType...))
 Create a Callable for a function with variable args. More...
 
- Public Member Functions inherited from Pothos::CallInterface
virtual ~CallInterface (void)
 
template<typename ReturnType , typename... ArgsType>
ReturnType call (ArgsType &&...args) const
 Call a bound method/function with a return type and variable args. More...
 
template<typename... ArgsType>
Object callObject (ArgsType &&...args) const
 Call a bound method/function with an Object return and variable args. More...
 
template<typename... ArgsType>
void callVoid (ArgsType &&...args) const
 Call a bound method/function with a void return and variable args. More...
 

Static Public Member Functions

template<typename ReturnType , typename ClassType , typename... ArgsType>
static Callable make (ReturnType(ClassType::*fcn)(ArgsType...))
 
template<typename ReturnType , typename ClassType , typename... ArgsType>
static Callable make (ReturnType(ClassType::*fcn)(ArgsType...) const)
 
template<typename ReturnType , typename... ArgsType>
static Callable make (ReturnType(*fcn)(ArgsType...))
 
template<typename ClassType , typename... ArgsType>
static Callable factory (void)
 
template<typename ClassType , typename... ArgsType>
static Callable factoryNew (void)
 
template<typename ClassType , typename... ArgsType>
static Callable factoryShared (void)
 

Friends

POTHOS_API friend bool operator== (const Callable &lhs, const Callable &rhs)
 

Additional Inherited Members

Detailed Description

The Callable class binds a class method or function. The method/function can be called through an opaque Object interface, or through a templated call interface with an arbitrary number of args.

Constructor & Destructor Documentation

Pothos::Callable::Callable ( void  )

Create a null Callable. Calling a null instance will throw CallableNullError.

template<typename ReturnType , typename ClassType , typename... ArgsType>
Pothos::Callable::Callable ( ReturnType(ClassType::*)(ArgsType...)  fcn)

Create a Callable for a class method with variable args.

template<typename ReturnType , typename ClassType , typename... ArgsType>
Pothos::Callable::Callable ( ReturnType(ClassType::*)(ArgsType...) const  fcn)

Create a Callable for a const class method with variable args.

template<typename ReturnType , typename... ArgsType>
Pothos::Callable::Callable ( ReturnType(*)(ArgsType...)  fcn)

Create a Callable for a function with variable args.

Member Function Documentation

template<typename ValueType >
Callable & Pothos::Callable::bind ( ValueType &&  val,
const size_t  argNo 
)

Bind an argument to the given argument index - template version. The user will not specify this argument at call time, the bound argument will be used as a substitute. The bind call does not throw.

Parameters
valthe value to put into the argument list
argNothe argument index to bind to
Returns
this Callable for operator chaining
Callable& Pothos::Callable::bind ( Object &&  val,
const size_t  argNo 
)

Bind an argument to the given argument index - Object version. The user will not specify this argument at call time, the bound argument will be used as a substitute. The bind call does not throw.

Parameters
valthe value to put into the argument list
argNothe argument index to bind to
Returns
this Callable for operator chaining
template<typename ClassType , typename... ArgsType>
Callable Pothos::Callable::factory ( void  )
static

Create a Callable for a constructor with variable args. Template arguments must be explicitly specified.

template<typename ClassType , typename... ArgsType>
Callable Pothos::Callable::factoryNew ( void  )
static

Create a Callable for a constructor with variable args. The callable return type is a pointer to ClassType*. The user is responsible for managing the memory. Template arguments must be explicitly specified.

template<typename ClassType , typename... ArgsType>
Callable Pothos::Callable::factoryShared ( void  )
static

Create a Callable for a constructor with variable args. The callable return type is a std::shared_ptr<ClassType>. Template arguments must be explicitly specified.

size_t Pothos::Callable::getNumArgs ( void  ) const

Get the number of arguments for this call. For methods, the class instance also counts

Returns
the number of arguments
template<typename ReturnType , typename ClassType , typename... ArgsType>
Callable Pothos::Callable::make ( ReturnType(ClassType::*)(ArgsType...)  fcn)
static

Create a Callable for a class method with variable args. Use make to specify explicit template arguments to differentiate overloads with the same name. In this case, the entire pack must be specified.

template<typename ReturnType , typename ClassType , typename... ArgsType>
static Callable Pothos::Callable::make ( ReturnType(ClassType::*)(ArgsType...) const  fcn)
static

Create a Callable for a const class method with variable args. Use make to specify explicit template arguments to differentiate overloads with the same name. In this case, the entire pack must be specified.

template<typename ReturnType , typename... ArgsType>
Callable Pothos::Callable::make ( ReturnType(*)(ArgsType...)  fcn)
static

Create a Callable for a function with variable args. Use make to specify explicit template arguments to differentiate overloads with the same name. In this case, the entire pack must be specified.

Object Pothos::Callable::opaqueCall ( const Object inputArgs,
const size_t  numArgs 
) const
virtual

Call into the function/method with opaque input and return types. For a void return type of call, the returned Object will be null.

Exceptions
CallableNullErrorif the Callable is null
CallableArgumentErrorfor bad arguments in number or type
Parameters
inputArgsan array of call arguments of type Object
numArgsthe number of arguments in inputArgs
Returns
the return value of the call as type Object

Implements Pothos::CallInterface.

Pothos::Callable::operator bool ( void  ) const
explicit

Does the Callable hold a bound function?

Returns
true if callable holds a bound function
std::string Pothos::Callable::toString ( void  ) const

Get a string representation for this Callable. The string holds the return type, and argument types.

Returns
the string with type names
const std::type_info& Pothos::Callable::type ( const int  argNo) const

Get the type info for a particular argument. For the return type, use argNo = -1. For argument 0 use argNo = 0, etc. For methods, argNo = 0 is the class type.

Exceptions
CallableArgumentErrorif the argNo is invalid
Returns
the type info for the argument
Callable& Pothos::Callable::unbind ( const size_t  argNo)

Remove a binding at the given argument index. The unbind call does not throw.

Parameters
argNothe argument index to clear
Returns
this Callable for operator chaining

Friends And Related Function Documentation

POTHOS_API friend bool operator== ( const Callable lhs,
const Callable rhs 
)
friend

The equals operators checks if two Callable represent the same internal data. The actual bound functions/methods cannot be checked for equality. Two callables are only equal if they originated from the same construction.

Parameters
lhsthe left hand object of the comparison
rhsthe right hand object of the comparison
Returns
true if the objects represent the same internal data

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