CodePlea icon
CodePlea
Random thoughts on programming

PlusCallback Reference


PlusCallback is contained in the namespace cb. Each class and function is defined multiple times, once for each number of parameters.

Class CallbackX<R, A, B, C, etc>

where X is the number of parameters, R is the return type, and A, B, C, etc are the parameter types.

Constructors:

Method Description Example
CallbackX(Object, Method) Constructs a new callback to point to an object's method. cb::Callback2<float, float, float> test(&Object, &Class::Method);
CallbackX(Function) Constructs a new callback to point to a free function. cb::Callback0 test(std::rand);
CallbackX() Constructs a new callback pointing to null for use later. cb::Callback2<float, float, float> test();
CallbackX(const CallbackX& rhs) Copy constructor. cb::Callback2<float, float, float> test2(test1);

Operators:

Note that comparisons operators may not work for callbacks that point to virtual methods.

Method Description Example
operator=(const CallbackX& rhs) Assignment operator. test1 = test2; test = std::rand;
bool operator==(const CallbackX& rhs) Equality operator. test1 == test2;
bool operator=!(const CallbackX& rhs) Inequality operator. test1 != test2;
bool operator<(const CallbackX& rhs) Less than operator. test1 < test2;
R operator()(Parameters) Function call operator. Equivalent to the Call method. test1(); a = test2(1.4, 1.8);

Methods:

Method Description Example
R Call(Parameters) Function call operator. Equivalent to the function call operator. test1.Call(); a = test2.Call(1.4, 1.8);
bool IsSet() Returns true if the callback is set to a function or method. Returns false if the callback is set to null. test.IsSet();
Reset(Object, Method) Points the callback to an object's method. test.Reset(&Object, &Class::Method);
Reset(Function) Points the callback to a free function. test.Reset(std::rand);
Reset() Points the callback to null for use later. test.Reset();

Function MakeX

where X is the number of parameters. Types are automatically inferred. These functions can be very convenient for constructing a callback to immediately pass to another function.

Function Description Example
MakeX(Object, Method) Returns a new callback to point to an object's method. test = Make0(&Object, &Class::Method);
MakeX(Function) Returns a new callback to point to a free function. test = Make0(std::rand);

Back to summary