OMNI_BIND_EX
MACRO

OMNI_BIND_EX - A helper macro for binding the omni::delegate

SYNOPSIS top

This macro is a framework helper macro. It's purpose is to make binding to an omni::delegate less verbose when needing to bind to a non-static class member function.

This macro is similar to the OMNI_BIND macro except that it allows you to specify a delegate type (either an explicit delegate type or a typedef'd delegate)

This macro is only for non-static class members (i.e. a class/struct member function) since binding to a static function is already less verbose (e.g. you can simply say omni::delegate d = &some_function);

The macro is defined as such:
#define OMNI_BIND_EX(DelegateType, Class, Function, Obj) DelegateType::bind<Class, &Class::Function>(Obj)
Where DelegateType is the delegate type to use, Class is the class type, Function is the member function of the Class specified (only the function name, not the full scope as the macro will expand this), and lastly Obj is the instance object needing to be passed in.

Since OMNI_BIND_EX takes a delegate type as it's first parameter, there are no OMNI_BINDn_EX, that is to say, there is no OMNI_BIND1_EX or OMNI_BIND2_EX and so on.

DESCRIPTION top

When binding a function to an omni::delegate (or an omni::event), you can use the static bind function of the delegate class to attach a non-static class member function by specifying the full delegate signature and the class, it's function and the associated instance to bind to; as an example, using the omni::delegate1 which takes one parameter in the function signature:
my_class obj;
omni::event1<void, int> my_event;
my_event += omni::delegate1<void, int>::bind<my_class, &my_class::class_function>(obj);
// or 
omni::delegate1<void, int> my_delegate = omni::delegate1<void, int>::bind<my_class, &my_class::class_function>(obj);
my_event += my_delegate;
As you can see, this can get very verbose when working with more complex function signatures and class types. To help alleviate some of this verbosity in the code you could elect to use the OMNI_BIND helper macro.

Example:
my_class obj;
omni::event1<void, int> my_event;
my_event += omni_bind(void, int, my_class, class_function, obj);
// or 
omni::delegate1<void, int> my_delegate = omni_bind(void, int, my_class, class_function, obj);
my_event += my_delegate;
Since this is just a helper macro, it's intended use is mostly to help the verbosity of binding a member function. You could alternatively typedef a more complex delegate type and perform similar functionality.

Example:
typedef omni::delegate1<void, int> delegate_t;
typedef omni::event1<void, int> event_t;
my_class obj;
event_t my_event;
my_event += delegate_t::bind<my_class, &my_class::class_function>(obj);
// or 
delegate_t my_delegate = delegate_t::bind<my_class, &my_class::class_function>(obj);
my_event += my_delegate;
In this case you could also use the OMNI_BIND_EX macro to specify the delegate_t delegate type as the specific binding delegate.

Example:
typedef omni::event1<void, int> event_t;
typedef omni::delegate1<void, int> delegate_t;
// or typedef event_t::delegate_t delegate_t;

my_class obj;
event_t my_event;
my_event += OMNI_BIND_EX(delegate_t, my_class, class_function, obj);
// or 
delegate_t my_delegate = OMNI_BIND_EX(delegate_t, my_class, class_function, obj);
my_event += my_delegate;

CONSIDERATIONS top

This macro is only applicable to binding of non-static member functions (namespace functions are not non-static member functions and can be addressed the same as a non-member function).

PLATFORM SPECIFIC top

No platform specific notes.

NOTES top

None.