Pothos  0.7.0-gf7fbae99
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 call (ArgsType &&... args) const
 Call a bound method/function with an Object return and variable args. More...
 
template<typename... ArgsType>
Object callObject (ArgsType &&... args) const
 
template<typename... ArgsType>
void callVoid (ArgsType &&... args) const
 

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

◆ Callable() [1/4]

Pothos::Callable::Callable ( void  )

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

◆ Callable() [2/4]

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

Create a Callable for a class method with variable args.

◆ Callable() [3/4]

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.

◆ Callable() [4/4]

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

Create a Callable for a function with variable args.

Member Function Documentation

◆ bind() [1/2]

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

◆ bind() [2/2]

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

◆ factory()

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.

◆ factoryNew()

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.

◆ factoryShared()

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.

◆ getNumArgs()

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

◆ make() [1/3]

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.

◆ make() [2/3]

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.

◆ make() [3/3]

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.

◆ opaqueCall()

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.

◆ operator bool()

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

Does the Callable hold a bound function?

Returns
true if callable holds a bound function

◆ toString()

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

◆ type()

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

◆ unbind()

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

◆ operator==

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: