/*
* Copyright (c) 2001-2007 International Computer Science Institute
* See LICENSE file for licensing, conditions, and warranties on use.
*
* This file is PROGRAMMATICALLY GENERATED.
*
* This instance was generated with:
* callback-gen.py -d -b 6 -l 15
*/
/**
* @libdoc Callbacks
*
* @sect Callback Overview
*
* XORP is an asynchronous programming environment and as a result there
* are many places where callbacks are useful. Callbacks are typically
* invoked to signify the completion or advancement of an asynchronous
* operation.
*
* XORP provides a generic and flexible callback interface that utilizes
* overloaded templatized functions for for generating callbacks
* in conjunction with many small templatized classes. Whilst this makes
* the syntax a little ugly, it provides a great deal of flexibility.
*
* XorpCallbacks are callback objects are created by the callback()
* function which returns a reference pointer to a newly created callback
* object. The callback is invoked by calling dispatch(), eg.
*
#include "libxorp/xorp.h"
#include "libxorp/callback.hh"
static void hello_world() {
cout << "Hello World" << endl;
}
int main() {
// Typedef callback() return type for readability. SimpleCallback
// declares a XorpCallback taking 0 arguments and of return type void.
typedef XorpCallback0::RefPtr SimpleCallback;
// Create XorpCallback object using callback()
SimpleCallback cb = callback(hello_world);
// Invoke callback, results in call to hello_world.
cb->dispatch();
return 0;
}
*
* The callback() method is overloaded and can also be used to create
* callbacks to member functions, eg.
*
#include "libxorp/xorp.h"
#include "libxorp/callback.hh"
class Foo {
public:
void hello_world() {
cout << "Foo::Hello World" << endl;
}
};
int main() {
typedef XorpCallback0::RefPtr SimpleCallback;
Foo f;
// Create a callback to a member function
SimpleCallback cb = callback(&f, &Foo::hello_world);
// Invoke f.hello_world
cb->dispatch();
return 0;
}
*
* In addition, to being able to invoke member functions, callbacks can
* also store arguments to functions. eg.
*
#include "libxorp/xorp.h"
#include "libxorp/callback.hh"
static int sum(int x, int y) {
cout << "sum(x = " << x << ", y = " << y << ")" << endl;
return x + y;
}
int main() {
// Callback to function returning "int"
typedef XorpCallback0::RefPtr NoArgCallback;
NoArgCallback cb1 = callback(sum, 1, 2);
cout << "cb1->dispatch() returns " << cb1->dispatch() << endl; // "3"
cout << endl;
// Callback to function returning int and taking an integer argument
typedef XorpCallback1::RefPtr OneIntArgCallback;
OneIntArgCallback cb2 = callback(sum, 5);
cout << "cb2->dispatch(10) returns " << cb2->dispatch(10) << endl; // 15
cout << endl;
cout << "cb2->dispatch(20) returns " << cb2->dispatch(20) << endl; // 25
cout << endl;
// Callback to function returning int and taking 2 integer arguments
typedef XorpCallback2::RefPtr TwoIntArgCallback;
TwoIntArgCallback cb3 = callback(sum);
cout << "cb3->dispatch() returns " << cb3->dispatch(50, -50) << endl; // 0
return 0;
}
*
* Bound arguments, as with member functions, are implemented by the
* overloading of the callback() method. At dispatch time, the bound
* arguments are last arguments past to the wrappered function. If you
* compile and run the program you will see:
*
sum(x = 10, y = 5)
cb2->dispatch(10) returns 15
*
* and:
*
sum(x = 20, y = 5)
cb2->dispatch(20) returns 25
*
* for the one bound argument cases.
*
* @sect Declaring Callback Types
*
* There are a host of XorpCallbackN types. The N denotes the number
* of arguments that will be passed at dispatch time by the callback
* invoker. The template parameters to XorpCallbackN types are the
* return value followed by the types of arguments that will be passed
* at dispatch time. Thus type:
*
*
XorpCallback1::RefPtr
*
*
* corresponds to callback object returning a double when invoked and
* requiring an integer argument to passed at dispatch time.
*
* When arguments are bound to a callback they are not specified
* in the templatized argument list. So the above declaration is good
* for a function taking an integer argument followed by upto the
* maximum number of bound arguments.
*
* Note: In this header file, support is provided for upto %d bound
* arguments and %d dispatch arguments.
*
* @sect Ref Pointer Helpers
*
* Callback objects may be set to NULL, since they use reference pointers
* to store the objects. Callbacks may be unset using the ref_ptr::release()
* method:
*
cb.release();
* and to tested using the ref_ptr::is_empty() method:
if (! cb.is_empty()) {
cb->dispatch();
}
*
* In many instances, the RefPtr associated with a callback on an object
* will be stored by the object itself. For instance, a class may own a
* timer object and the associated timer expiry callback which is
* a member function of the containing class. Because the containing class
* owns the callback object corresponding the timer callback, there is
* never an opportunity for the callback to be dispatched on a deleted object
* or with invalid data.
*/
#ifndef INCLUDED_FROM_CALLBACK_HH
#error "This file should be included through libxorp/callback.hh"
#endif
#ifndef __XORP_CALLBACK_HH__
#define __XORP_CALLBACK_HH__
#include "minitraits.hh"
#include "ref_ptr.hh"
#include "safe_callback_obj.hh"
#if defined(__GNUC__) && (__GNUC__ < 3)
#define callback(x...) dbg_callback(__FILE__,__LINE__,x)
#else
#define callback(...) dbg_callback(__FILE__,__LINE__,__VA_ARGS__)
#endif
void trace_dispatch_enter(const char* file, int line);
void trace_dispatch_leave();
#define record_dispatch_enter() trace_dispatch_enter( this->file(), this->line() )
#define record_dispatch_leave() trace_dispatch_leave()
///////////////////////////////////////////////////////////////////////////////
//
// Code relating to callbacks with 0 late args
//
/**
* @short Base class for callbacks with 0 dispatch time args.
*/
template
struct XorpCallback0 {
typedef ref_ptr RefPtr;
XorpCallback0(const char* file, int line)
: _file(file), _line(line) {}
virtual ~XorpCallback0() {}
virtual R dispatch() = 0;
const char* file() const { return _file; }
int line() const { return _line; }
private:
const char* _file;
int _line;
};
/**
* @short Callback object for functions with 0 dispatch time
* arguments and 0 bound (stored) arguments.
*/
template
struct XorpFunctionCallback0B0 : public XorpCallback0 {
typedef R (*F)();
XorpFunctionCallback0B0(const char* file, int line, F f)
: XorpCallback0(file, line),
_f(f)
{}
R dispatch() {
record_dispatch_enter();
R r = (*_f)();
record_dispatch_leave();
return r;
}
protected:
F _f;
};
/**
* @short Callback object for void functions with 0 dispatch time
* arguments and 0 bound (stored) arguments.
*/
template <>
struct XorpFunctionCallback0B0 : public XorpCallback0 {
typedef void (*F)();
XorpFunctionCallback0B0(const char* file, int line, F f)
: XorpCallback0(file, line),
_f(f)
{}
void dispatch() {
record_dispatch_enter();
(*_f)();
record_dispatch_leave();
}
protected:
F _f;
};
/**
* Factory function that creates a callback object targetted at a
* function with 0 dispatch time arguments and 0 bound arguments.
*/
template
typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, R (*f)()) {
return typename XorpCallback0::RefPtr(new XorpFunctionCallback0B0(file, line, f));
}
/**
* @short Callback object for member methods with 0 dispatch time
* arguments and 0 bound (stored) arguments.
*/
template
struct XorpMemberCallback0B0 : public XorpCallback0 {
typedef R (O::*M)() ;
XorpMemberCallback0B0(const char* file, int line, O* o, M m)
: XorpCallback0(file, line),
_o(o), _m(m) {}
R dispatch() {
record_dispatch_enter();
R r = ((*_o).*_m)();
record_dispatch_leave();
return r;
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
};
/**
* @short Callback object for void member methods with 0 dispatch time
* arguments and 0 bound (stored) arguments.
*/
template
struct XorpMemberCallback0B0
: public XorpCallback0 {
typedef void (O::*M)() ;
XorpMemberCallback0B0(const char* file, int line, O* o, M m)
: XorpCallback0(file, line),
_o(o), _m(m) {}
void dispatch() {
record_dispatch_enter();
((*_o).*_m)();
record_dispatch_leave();
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
};
/**
* @short Callback object for safe member methods with 0 dispatch time
* arguments and 0 bound (stored) arguments.
*/
template
struct XorpSafeMemberCallback0B0
: public XorpMemberCallback0B0,
public SafeCallbackBase {
typedef typename XorpMemberCallback0B0::M M;
XorpSafeMemberCallback0B0(const char* file, int line, O* o, M m)
: XorpMemberCallback0B0(file, line, o, m),
SafeCallbackBase(o) {}
~XorpSafeMemberCallback0B0() {}
R dispatch() {
if (valid()) {
record_dispatch_enter();
R r = XorpMemberCallback0B0::dispatch();
record_dispatch_leave();
return r;
}
}
};
/**
* @short Callback object for void safe member methods with 0 dispatch time
* arguments and 0 bound (stored) arguments.
*/
template
struct XorpSafeMemberCallback0B0
: public XorpMemberCallback0B0,
public SafeCallbackBase {
typedef typename XorpMemberCallback0B0::M M;
XorpSafeMemberCallback0B0(const char* file, int line, O* o, M m)
: XorpMemberCallback0B0(file, line, o, m),
SafeCallbackBase(o) {}
~XorpSafeMemberCallback0B0() {}
void dispatch() {
if (valid()) {
record_dispatch_enter();
XorpMemberCallback0B0::dispatch();
record_dispatch_leave();
}
}
};
template
struct XorpMemberCallbackFactory0B0
{
inline static XorpMemberCallback0B0*
make(const char* file, int line, O* o, R (O::*p)())
{
return new XorpSafeMemberCallback0B0(file, line, o, p);
}
};
template
struct XorpMemberCallbackFactory0B0
{
inline static XorpMemberCallback0B0*
make(const char* file, int line, O* o, R (O::*p)())
{
return new XorpMemberCallback0B0(file, line, o, p);
};
};
/**
* Factory function that creates a callback object targetted at a
* member function with 0 dispatch time arguments and 0 bound arguments.
*/
template typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, O* o, R (O::*p)())
{
return XorpMemberCallbackFactory0B0::True>::make(file, line, o, p);
}
/**
* Factory function that creates a callback object targetted at a
* member function with 0 dispatch time arguments and 0 bound arguments.
*/
template typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, O& o, R (O::*p)())
{
return XorpMemberCallbackFactory0B0::True>::make(file, line, &o, p);
}
/**
* @short Callback object for const member methods with 0 dispatch time
* arguments and 0 bound (stored) arguments.
*/
template
struct XorpConstMemberCallback0B0 : public XorpCallback0 {
typedef R (O::*M)() const;
XorpConstMemberCallback0B0(const char* file, int line, O* o, M m)
: XorpCallback0(file, line),
_o(o), _m(m) {}
R dispatch() {
record_dispatch_enter();
R r = ((*_o).*_m)();
record_dispatch_leave();
return r;
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
};
/**
* @short Callback object for void const member methods with 0 dispatch time
* arguments and 0 bound (stored) arguments.
*/
template
struct XorpConstMemberCallback0B0
: public XorpCallback0 {
typedef void (O::*M)() const;
XorpConstMemberCallback0B0(const char* file, int line, O* o, M m)
: XorpCallback0(file, line),
_o(o), _m(m) {}
void dispatch() {
record_dispatch_enter();
((*_o).*_m)();
record_dispatch_leave();
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
};
/**
* @short Callback object for const safe member methods with 0 dispatch time
* arguments and 0 bound (stored) arguments.
*/
template
struct XorpConstSafeMemberCallback0B0
: public XorpConstMemberCallback0B0,
public SafeCallbackBase {
typedef typename XorpConstMemberCallback0B0::M M;
XorpConstSafeMemberCallback0B0(const char* file, int line, O* o, M m)
: XorpConstMemberCallback0B0(file, line, o, m),
SafeCallbackBase(o) {}
~XorpConstSafeMemberCallback0B0() {}
R dispatch() {
if (valid()) {
record_dispatch_enter();
R r = XorpConstMemberCallback0B0::dispatch();
record_dispatch_leave();
return r;
}
}
};
/**
* @short Callback object for void const safe member methods with 0 dispatch time
* arguments and 0 bound (stored) arguments.
*/
template
struct XorpConstSafeMemberCallback0B0
: public XorpConstMemberCallback0B0,
public SafeCallbackBase {
typedef typename XorpConstMemberCallback0B0::M M;
XorpConstSafeMemberCallback0B0(const char* file, int line, O* o, M m)
: XorpConstMemberCallback0B0(file, line, o, m),
SafeCallbackBase(o) {}
~XorpConstSafeMemberCallback0B0() {}
void dispatch() {
if (valid()) {
record_dispatch_enter();
XorpConstMemberCallback0B0::dispatch();
record_dispatch_leave();
}
}
};
template
struct XorpConstMemberCallbackFactory0B0
{
inline static XorpConstMemberCallback0B0*
make(const char* file, int line, O* o, R (O::*p)() const)
{
return new XorpConstSafeMemberCallback0B0(file, line, o, p);
}
};
template
struct XorpConstMemberCallbackFactory0B0
{
inline static XorpConstMemberCallback0B0*
make(const char* file, int line, O* o, R (O::*p)() const)
{
return new XorpConstMemberCallback0B0(file, line, o, p);
};
};
/**
* Factory function that creates a callback object targetted at a
* const member function with 0 dispatch time arguments and 0 bound arguments.
*/
template typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, const O* o, R (O::*p)() const)
{
return XorpConstMemberCallbackFactory0B0::True>::make(file, line, o, p);
}
/**
* Factory function that creates a callback object targetted at a
* const member function with 0 dispatch time arguments and 0 bound arguments.
*/
template typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, const O& o, R (O::*p)() const)
{
return XorpConstMemberCallbackFactory0B0::True>::make(file, line, &o, p);
}
/**
* @short Callback object for functions with 0 dispatch time
* arguments and 1 bound (stored) arguments.
*/
template
struct XorpFunctionCallback0B1 : public XorpCallback0 {
typedef R (*F)(BA1);
XorpFunctionCallback0B1(const char* file, int line, F f, BA1 ba1)
: XorpCallback0(file, line),
_f(f), _ba1(ba1)
{}
R dispatch() {
record_dispatch_enter();
R r = (*_f)(_ba1);
record_dispatch_leave();
return r;
}
protected:
F _f;
BA1 _ba1;
};
/**
* @short Callback object for void functions with 0 dispatch time
* arguments and 1 bound (stored) arguments.
*/
template
struct XorpFunctionCallback0B1 : public XorpCallback0 {
typedef void (*F)(BA1);
XorpFunctionCallback0B1(const char* file, int line, F f, BA1 ba1)
: XorpCallback0(file, line),
_f(f), _ba1(ba1)
{}
void dispatch() {
record_dispatch_enter();
(*_f)(_ba1);
record_dispatch_leave();
}
protected:
F _f;
BA1 _ba1;
};
/**
* Factory function that creates a callback object targetted at a
* function with 0 dispatch time arguments and 1 bound arguments.
*/
template
typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, R (*f)(BA1), BA1 ba1) {
return typename XorpCallback0::RefPtr(new XorpFunctionCallback0B1(file, line, f, ba1));
}
/**
* @short Callback object for member methods with 0 dispatch time
* arguments and 1 bound (stored) arguments.
*/
template
struct XorpMemberCallback0B1 : public XorpCallback0 {
typedef R (O::*M)(BA1) ;
XorpMemberCallback0B1(const char* file, int line, O* o, M m, BA1 ba1)
: XorpCallback0(file, line),
_o(o), _m(m), _ba1(ba1) {}
R dispatch() {
record_dispatch_enter();
R r = ((*_o).*_m)(_ba1);
record_dispatch_leave();
return r;
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
BA1 _ba1; // Bound argument
};
/**
* @short Callback object for void member methods with 0 dispatch time
* arguments and 1 bound (stored) arguments.
*/
template
struct XorpMemberCallback0B1
: public XorpCallback0 {
typedef void (O::*M)(BA1) ;
XorpMemberCallback0B1(const char* file, int line, O* o, M m, BA1 ba1)
: XorpCallback0(file, line),
_o(o), _m(m), _ba1(ba1) {}
void dispatch() {
record_dispatch_enter();
((*_o).*_m)(_ba1);
record_dispatch_leave();
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
BA1 _ba1; // Bound argument
};
/**
* @short Callback object for safe member methods with 0 dispatch time
* arguments and 1 bound (stored) arguments.
*/
template
struct XorpSafeMemberCallback0B1
: public XorpMemberCallback0B1,
public SafeCallbackBase {
typedef typename XorpMemberCallback0B1::M M;
XorpSafeMemberCallback0B1(const char* file, int line, O* o, M m, BA1 ba1)
: XorpMemberCallback0B1(file, line, o, m, ba1),
SafeCallbackBase(o) {}
~XorpSafeMemberCallback0B1() {}
R dispatch() {
if (valid()) {
record_dispatch_enter();
R r = XorpMemberCallback0B1::dispatch();
record_dispatch_leave();
return r;
}
}
};
/**
* @short Callback object for void safe member methods with 0 dispatch time
* arguments and 1 bound (stored) arguments.
*/
template
struct XorpSafeMemberCallback0B1
: public XorpMemberCallback0B1,
public SafeCallbackBase {
typedef typename XorpMemberCallback0B1::M M;
XorpSafeMemberCallback0B1(const char* file, int line, O* o, M m, BA1 ba1)
: XorpMemberCallback0B1(file, line, o, m, ba1),
SafeCallbackBase(o) {}
~XorpSafeMemberCallback0B1() {}
void dispatch() {
if (valid()) {
record_dispatch_enter();
XorpMemberCallback0B1::dispatch();
record_dispatch_leave();
}
}
};
template
struct XorpMemberCallbackFactory0B1
{
inline static XorpMemberCallback0B1*
make(const char* file, int line, O* o, R (O::*p)(BA1), BA1 ba1)
{
return new XorpSafeMemberCallback0B1(file, line, o, p, ba1);
}
};
template
struct XorpMemberCallbackFactory0B1
{
inline static XorpMemberCallback0B1*
make(const char* file, int line, O* o, R (O::*p)(BA1), BA1 ba1)
{
return new XorpMemberCallback0B1(file, line, o, p, ba1);
};
};
/**
* Factory function that creates a callback object targetted at a
* member function with 0 dispatch time arguments and 1 bound arguments.
*/
template typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, O* o, R (O::*p)(BA1), BA1 ba1)
{
return XorpMemberCallbackFactory0B1::True>::make(file, line, o, p, ba1);
}
/**
* Factory function that creates a callback object targetted at a
* member function with 0 dispatch time arguments and 1 bound arguments.
*/
template typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, O& o, R (O::*p)(BA1), BA1 ba1)
{
return XorpMemberCallbackFactory0B1::True>::make(file, line, &o, p, ba1);
}
/**
* @short Callback object for const member methods with 0 dispatch time
* arguments and 1 bound (stored) arguments.
*/
template
struct XorpConstMemberCallback0B1 : public XorpCallback0 {
typedef R (O::*M)(BA1) const;
XorpConstMemberCallback0B1(const char* file, int line, O* o, M m, BA1 ba1)
: XorpCallback0(file, line),
_o(o), _m(m), _ba1(ba1) {}
R dispatch() {
record_dispatch_enter();
R r = ((*_o).*_m)(_ba1);
record_dispatch_leave();
return r;
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
BA1 _ba1; // Bound argument
};
/**
* @short Callback object for void const member methods with 0 dispatch time
* arguments and 1 bound (stored) arguments.
*/
template
struct XorpConstMemberCallback0B1
: public XorpCallback0 {
typedef void (O::*M)(BA1) const;
XorpConstMemberCallback0B1(const char* file, int line, O* o, M m, BA1 ba1)
: XorpCallback0(file, line),
_o(o), _m(m), _ba1(ba1) {}
void dispatch() {
record_dispatch_enter();
((*_o).*_m)(_ba1);
record_dispatch_leave();
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
BA1 _ba1; // Bound argument
};
/**
* @short Callback object for const safe member methods with 0 dispatch time
* arguments and 1 bound (stored) arguments.
*/
template
struct XorpConstSafeMemberCallback0B1
: public XorpConstMemberCallback0B1,
public SafeCallbackBase {
typedef typename XorpConstMemberCallback0B1::M M;
XorpConstSafeMemberCallback0B1(const char* file, int line, O* o, M m, BA1 ba1)
: XorpConstMemberCallback0B1(file, line, o, m, ba1),
SafeCallbackBase(o) {}
~XorpConstSafeMemberCallback0B1() {}
R dispatch() {
if (valid()) {
record_dispatch_enter();
R r = XorpConstMemberCallback0B1::dispatch();
record_dispatch_leave();
return r;
}
}
};
/**
* @short Callback object for void const safe member methods with 0 dispatch time
* arguments and 1 bound (stored) arguments.
*/
template
struct XorpConstSafeMemberCallback0B1
: public XorpConstMemberCallback0B1,
public SafeCallbackBase {
typedef typename XorpConstMemberCallback0B1::M M;
XorpConstSafeMemberCallback0B1(const char* file, int line, O* o, M m, BA1 ba1)
: XorpConstMemberCallback0B1(file, line, o, m, ba1),
SafeCallbackBase(o) {}
~XorpConstSafeMemberCallback0B1() {}
void dispatch() {
if (valid()) {
record_dispatch_enter();
XorpConstMemberCallback0B1::dispatch();
record_dispatch_leave();
}
}
};
template
struct XorpConstMemberCallbackFactory0B1
{
inline static XorpConstMemberCallback0B1*
make(const char* file, int line, O* o, R (O::*p)(BA1) const, BA1 ba1)
{
return new XorpConstSafeMemberCallback0B1(file, line, o, p, ba1);
}
};
template
struct XorpConstMemberCallbackFactory0B1
{
inline static XorpConstMemberCallback0B1*
make(const char* file, int line, O* o, R (O::*p)(BA1) const, BA1 ba1)
{
return new XorpConstMemberCallback0B1(file, line, o, p, ba1);
};
};
/**
* Factory function that creates a callback object targetted at a
* const member function with 0 dispatch time arguments and 1 bound arguments.
*/
template typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, const O* o, R (O::*p)(BA1) const, BA1 ba1)
{
return XorpConstMemberCallbackFactory0B1::True>::make(file, line, o, p, ba1);
}
/**
* Factory function that creates a callback object targetted at a
* const member function with 0 dispatch time arguments and 1 bound arguments.
*/
template typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, const O& o, R (O::*p)(BA1) const, BA1 ba1)
{
return XorpConstMemberCallbackFactory0B1::True>::make(file, line, &o, p, ba1);
}
/**
* @short Callback object for functions with 0 dispatch time
* arguments and 2 bound (stored) arguments.
*/
template
struct XorpFunctionCallback0B2 : public XorpCallback0 {
typedef R (*F)(BA1, BA2);
XorpFunctionCallback0B2(const char* file, int line, F f, BA1 ba1, BA2 ba2)
: XorpCallback0(file, line),
_f(f), _ba1(ba1), _ba2(ba2)
{}
R dispatch() {
record_dispatch_enter();
R r = (*_f)(_ba1, _ba2);
record_dispatch_leave();
return r;
}
protected:
F _f;
BA1 _ba1;
BA2 _ba2;
};
/**
* @short Callback object for void functions with 0 dispatch time
* arguments and 2 bound (stored) arguments.
*/
template
struct XorpFunctionCallback0B2 : public XorpCallback0 {
typedef void (*F)(BA1, BA2);
XorpFunctionCallback0B2(const char* file, int line, F f, BA1 ba1, BA2 ba2)
: XorpCallback0(file, line),
_f(f), _ba1(ba1), _ba2(ba2)
{}
void dispatch() {
record_dispatch_enter();
(*_f)(_ba1, _ba2);
record_dispatch_leave();
}
protected:
F _f;
BA1 _ba1;
BA2 _ba2;
};
/**
* Factory function that creates a callback object targetted at a
* function with 0 dispatch time arguments and 2 bound arguments.
*/
template
typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, R (*f)(BA1, BA2), BA1 ba1, BA2 ba2) {
return typename XorpCallback0::RefPtr(new XorpFunctionCallback0B2(file, line, f, ba1, ba2));
}
/**
* @short Callback object for member methods with 0 dispatch time
* arguments and 2 bound (stored) arguments.
*/
template
struct XorpMemberCallback0B2 : public XorpCallback0 {
typedef R (O::*M)(BA1, BA2) ;
XorpMemberCallback0B2(const char* file, int line, O* o, M m, BA1 ba1, BA2 ba2)
: XorpCallback0(file, line),
_o(o), _m(m), _ba1(ba1), _ba2(ba2) {}
R dispatch() {
record_dispatch_enter();
R r = ((*_o).*_m)(_ba1, _ba2);
record_dispatch_leave();
return r;
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
BA1 _ba1; // Bound argument
BA2 _ba2; // Bound argument
};
/**
* @short Callback object for void member methods with 0 dispatch time
* arguments and 2 bound (stored) arguments.
*/
template
struct XorpMemberCallback0B2
: public XorpCallback0 {
typedef void (O::*M)(BA1, BA2) ;
XorpMemberCallback0B2(const char* file, int line, O* o, M m, BA1 ba1, BA2 ba2)
: XorpCallback0(file, line),
_o(o), _m(m), _ba1(ba1), _ba2(ba2) {}
void dispatch() {
record_dispatch_enter();
((*_o).*_m)(_ba1, _ba2);
record_dispatch_leave();
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
BA1 _ba1; // Bound argument
BA2 _ba2; // Bound argument
};
/**
* @short Callback object for safe member methods with 0 dispatch time
* arguments and 2 bound (stored) arguments.
*/
template
struct XorpSafeMemberCallback0B2
: public XorpMemberCallback0B2,
public SafeCallbackBase {
typedef typename XorpMemberCallback0B2::M M;
XorpSafeMemberCallback0B2(const char* file, int line, O* o, M m, BA1 ba1, BA2 ba2)
: XorpMemberCallback0B2(file, line, o, m, ba1, ba2),
SafeCallbackBase(o) {}
~XorpSafeMemberCallback0B2() {}
R dispatch() {
if (valid()) {
record_dispatch_enter();
R r = XorpMemberCallback0B2::dispatch();
record_dispatch_leave();
return r;
}
}
};
/**
* @short Callback object for void safe member methods with 0 dispatch time
* arguments and 2 bound (stored) arguments.
*/
template
struct XorpSafeMemberCallback0B2
: public XorpMemberCallback0B2,
public SafeCallbackBase {
typedef typename XorpMemberCallback0B2::M M;
XorpSafeMemberCallback0B2(const char* file, int line, O* o, M m, BA1 ba1, BA2 ba2)
: XorpMemberCallback0B2(file, line, o, m, ba1, ba2),
SafeCallbackBase(o) {}
~XorpSafeMemberCallback0B2() {}
void dispatch() {
if (valid()) {
record_dispatch_enter();
XorpMemberCallback0B2::dispatch();
record_dispatch_leave();
}
}
};
template
struct XorpMemberCallbackFactory0B2
{
inline static XorpMemberCallback0B2*
make(const char* file, int line, O* o, R (O::*p)(BA1, BA2), BA1 ba1, BA2 ba2)
{
return new XorpSafeMemberCallback0B2(file, line, o, p, ba1, ba2);
}
};
template
struct XorpMemberCallbackFactory0B2
{
inline static XorpMemberCallback0B2*
make(const char* file, int line, O* o, R (O::*p)(BA1, BA2), BA1 ba1, BA2 ba2)
{
return new XorpMemberCallback0B2(file, line, o, p, ba1, ba2);
};
};
/**
* Factory function that creates a callback object targetted at a
* member function with 0 dispatch time arguments and 2 bound arguments.
*/
template typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, O* o, R (O::*p)(BA1, BA2), BA1 ba1, BA2 ba2)
{
return XorpMemberCallbackFactory0B2::True>::make(file, line, o, p, ba1, ba2);
}
/**
* Factory function that creates a callback object targetted at a
* member function with 0 dispatch time arguments and 2 bound arguments.
*/
template typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, O& o, R (O::*p)(BA1, BA2), BA1 ba1, BA2 ba2)
{
return XorpMemberCallbackFactory0B2::True>::make(file, line, &o, p, ba1, ba2);
}
/**
* @short Callback object for const member methods with 0 dispatch time
* arguments and 2 bound (stored) arguments.
*/
template
struct XorpConstMemberCallback0B2 : public XorpCallback0 {
typedef R (O::*M)(BA1, BA2) const;
XorpConstMemberCallback0B2(const char* file, int line, O* o, M m, BA1 ba1, BA2 ba2)
: XorpCallback0(file, line),
_o(o), _m(m), _ba1(ba1), _ba2(ba2) {}
R dispatch() {
record_dispatch_enter();
R r = ((*_o).*_m)(_ba1, _ba2);
record_dispatch_leave();
return r;
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
BA1 _ba1; // Bound argument
BA2 _ba2; // Bound argument
};
/**
* @short Callback object for void const member methods with 0 dispatch time
* arguments and 2 bound (stored) arguments.
*/
template
struct XorpConstMemberCallback0B2
: public XorpCallback0 {
typedef void (O::*M)(BA1, BA2) const;
XorpConstMemberCallback0B2(const char* file, int line, O* o, M m, BA1 ba1, BA2 ba2)
: XorpCallback0(file, line),
_o(o), _m(m), _ba1(ba1), _ba2(ba2) {}
void dispatch() {
record_dispatch_enter();
((*_o).*_m)(_ba1, _ba2);
record_dispatch_leave();
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
BA1 _ba1; // Bound argument
BA2 _ba2; // Bound argument
};
/**
* @short Callback object for const safe member methods with 0 dispatch time
* arguments and 2 bound (stored) arguments.
*/
template
struct XorpConstSafeMemberCallback0B2
: public XorpConstMemberCallback0B2,
public SafeCallbackBase {
typedef typename XorpConstMemberCallback0B2::M M;
XorpConstSafeMemberCallback0B2(const char* file, int line, O* o, M m, BA1 ba1, BA2 ba2)
: XorpConstMemberCallback0B2(file, line, o, m, ba1, ba2),
SafeCallbackBase(o) {}
~XorpConstSafeMemberCallback0B2() {}
R dispatch() {
if (valid()) {
record_dispatch_enter();
R r = XorpConstMemberCallback0B2::dispatch();
record_dispatch_leave();
return r;
}
}
};
/**
* @short Callback object for void const safe member methods with 0 dispatch time
* arguments and 2 bound (stored) arguments.
*/
template
struct XorpConstSafeMemberCallback0B2
: public XorpConstMemberCallback0B2,
public SafeCallbackBase {
typedef typename XorpConstMemberCallback0B2::M M;
XorpConstSafeMemberCallback0B2(const char* file, int line, O* o, M m, BA1 ba1, BA2 ba2)
: XorpConstMemberCallback0B2(file, line, o, m, ba1, ba2),
SafeCallbackBase(o) {}
~XorpConstSafeMemberCallback0B2() {}
void dispatch() {
if (valid()) {
record_dispatch_enter();
XorpConstMemberCallback0B2::dispatch();
record_dispatch_leave();
}
}
};
template
struct XorpConstMemberCallbackFactory0B2
{
inline static XorpConstMemberCallback0B2*
make(const char* file, int line, O* o, R (O::*p)(BA1, BA2) const, BA1 ba1, BA2 ba2)
{
return new XorpConstSafeMemberCallback0B2(file, line, o, p, ba1, ba2);
}
};
template
struct XorpConstMemberCallbackFactory0B2
{
inline static XorpConstMemberCallback0B2*
make(const char* file, int line, O* o, R (O::*p)(BA1, BA2) const, BA1 ba1, BA2 ba2)
{
return new XorpConstMemberCallback0B2(file, line, o, p, ba1, ba2);
};
};
/**
* Factory function that creates a callback object targetted at a
* const member function with 0 dispatch time arguments and 2 bound arguments.
*/
template typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, const O* o, R (O::*p)(BA1, BA2) const, BA1 ba1, BA2 ba2)
{
return XorpConstMemberCallbackFactory0B2::True>::make(file, line, o, p, ba1, ba2);
}
/**
* Factory function that creates a callback object targetted at a
* const member function with 0 dispatch time arguments and 2 bound arguments.
*/
template typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, const O& o, R (O::*p)(BA1, BA2) const, BA1 ba1, BA2 ba2)
{
return XorpConstMemberCallbackFactory0B2::True>::make(file, line, &o, p, ba1, ba2);
}
/**
* @short Callback object for functions with 0 dispatch time
* arguments and 3 bound (stored) arguments.
*/
template
struct XorpFunctionCallback0B3 : public XorpCallback0 {
typedef R (*F)(BA1, BA2, BA3);
XorpFunctionCallback0B3(const char* file, int line, F f, BA1 ba1, BA2 ba2, BA3 ba3)
: XorpCallback0(file, line),
_f(f), _ba1(ba1), _ba2(ba2), _ba3(ba3)
{}
R dispatch() {
record_dispatch_enter();
R r = (*_f)(_ba1, _ba2, _ba3);
record_dispatch_leave();
return r;
}
protected:
F _f;
BA1 _ba1;
BA2 _ba2;
BA3 _ba3;
};
/**
* @short Callback object for void functions with 0 dispatch time
* arguments and 3 bound (stored) arguments.
*/
template
struct XorpFunctionCallback0B3 : public XorpCallback0 {
typedef void (*F)(BA1, BA2, BA3);
XorpFunctionCallback0B3(const char* file, int line, F f, BA1 ba1, BA2 ba2, BA3 ba3)
: XorpCallback0(file, line),
_f(f), _ba1(ba1), _ba2(ba2), _ba3(ba3)
{}
void dispatch() {
record_dispatch_enter();
(*_f)(_ba1, _ba2, _ba3);
record_dispatch_leave();
}
protected:
F _f;
BA1 _ba1;
BA2 _ba2;
BA3 _ba3;
};
/**
* Factory function that creates a callback object targetted at a
* function with 0 dispatch time arguments and 3 bound arguments.
*/
template
typename XorpCallback0::RefPtr
dbg_callback(const char* file, int line, R (*f)(BA1, BA2, BA3), BA1 ba1, BA2 ba2, BA3 ba3) {
return typename XorpCallback0::RefPtr(new XorpFunctionCallback0B3(file, line, f, ba1, ba2, ba3));
}
/**
* @short Callback object for member methods with 0 dispatch time
* arguments and 3 bound (stored) arguments.
*/
template
struct XorpMemberCallback0B3 : public XorpCallback0 {
typedef R (O::*M)(BA1, BA2, BA3) ;
XorpMemberCallback0B3(const char* file, int line, O* o, M m, BA1 ba1, BA2 ba2, BA3 ba3)
: XorpCallback0(file, line),
_o(o), _m(m), _ba1(ba1), _ba2(ba2), _ba3(ba3) {}
R dispatch() {
record_dispatch_enter();
R r = ((*_o).*_m)(_ba1, _ba2, _ba3);
record_dispatch_leave();
return r;
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
BA1 _ba1; // Bound argument
BA2 _ba2; // Bound argument
BA3 _ba3; // Bound argument
};
/**
* @short Callback object for void member methods with 0 dispatch time
* arguments and 3 bound (stored) arguments.
*/
template
struct XorpMemberCallback0B3
: public XorpCallback0 {
typedef void (O::*M)(BA1, BA2, BA3) ;
XorpMemberCallback0B3(const char* file, int line, O* o, M m, BA1 ba1, BA2 ba2, BA3 ba3)
: XorpCallback0(file, line),
_o(o), _m(m), _ba1(ba1), _ba2(ba2), _ba3(ba3) {}
void dispatch() {
record_dispatch_enter();
((*_o).*_m)(_ba1, _ba2, _ba3);
record_dispatch_leave();
}
protected:
O* _o; // Callback's target object
M _m; // Callback's target method
BA1 _ba1; // Bound argument
BA2 _ba2; // Bound argument
BA3 _ba3; // Bound argument
};
/**
* @short Callback object for safe member methods with 0 dispatch time
* arguments and 3 bound (stored) arguments.
*/
template
struct XorpSafeMemberCallback0B3
: public XorpMemberCallback0B3,
public SafeCallbackBase {
typedef typename XorpMemberCallback0B3::M M;
XorpSafeMemberCallback0B3(const char* file, int line, O* o, M m, BA1 ba1, BA2 ba2, BA3 ba3)
: XorpMemberCallback0B3(file, line, o, m, ba1, ba2, ba3),
SafeCallbackBase(o) {}
~XorpSafeMemberCallback0B3() {}
R dispatch() {
if (valid()) {
record_dispatch_enter();
R r = XorpMemberCallback0B3::dispatch();
record_dispatch_leave();
return r;
}
}
};
/**
* @short Callback object for void safe member methods with 0 dispatch time
* arguments and 3 bound (stored) arguments.
*/
template
struct XorpSafeMemberCallback0B3
: public XorpMemberCallback0B3,
public SafeCallbackBase {
typedef typename XorpMemberCallback0B3::M M;
XorpSafeMemberCallback0B3(const char* file, int line, O* o, M m, BA1 ba1, BA2 ba2, BA3 ba3)
: XorpMemberCallback0B3(file, line, o, m, ba1, ba2, ba3),
SafeCallbackBase(o) {}
~XorpSafeMemberCallback0B3() {}
void dispatch() {
if (valid()) {
record_dispatch_enter();
XorpMemberCallback0B3::dispatch();
record_dispatch_leave();
}
}
};
template
struct XorpMemberCallbackFactory0B3
{
inline static XorpMemberCallback0B3*
make(const char* file, int line, O* o, R (O::*p)(BA1, BA2, BA3), BA1 ba1, BA2 ba2, BA3 ba3)
{
return new XorpSafeMemberCallback0B3(file, line, o, p, ba1, ba2, ba3);
}
};
template
struct XorpMemberCallbackFactory0B3