Boost logo

Boost :

From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2006-07-13 17:02:54


Hi Everyone,

Uploaded to the vault [0] is the implementation of the dispatcher
library. If there is enough interest, I would like to propose this
library for inclusion into the Boost C++ Library. The documentation is
yet unfinished, though I am not very sure about the contents of the
documentation. However, I have put enough documentation with regards
to how the library is designed, and used.

A synopsis on how it can be used can be summed up in the following example code:

[start code]

#include <boost/dispatch.hpp>

using boost::dispatch;

//...
dispatcher<int()> d;
d[0] = int_function_1;
d[1] = int_function_2;
d[0]() // calls `int_function_1'
d[1]() // calls `inf_function_2'
d.unset(1);
try {
  d[1]() // throws an unregistered_handler exception
} catch (unregistered_handler & e) {
  // .. do nothing
};
dispatcher<int()>::invoke_ d;

d[1] = int_function_2;

d << 0 << 1 ; // calls d[0] and d[1] in specified order.

[end code]

It also supports multiple argument callback registration (ala Signals):

[start code]

dispatcher<int (double, int, std::string)> d;
d[0] = function_returns_int_and_takes_double_int_and_string;

[end code]

It also allows for parameterized index type definition:

[start code]

dispatcher<int(int), std::string> d;
d["zero"] = function_returns_int_and_takes_int;

[end code]

The included documentation (doc/html) contains more information on the
uses of the library, while the unit test (test/dispatch_test.cpp) can
be referred to regarding the actual details on the usage.

The project is currently hosted in sourceforge [1] and has been
tested/built against RC_1_34_0 using MSVC 8.0 -- this is configured to
be built only with BBv2.

Have a great day everyone! Your comments and insights will be most appreciated.

References:

[0] Dispatcher Initial Implementation
http://tinyurl.com/q9oux

[1] Sourceforge.net project page
http://tinyurl.com/mo2ds

-- 
Dean Michael C. Berris
C/C++ Software Architect
Orange and Bronze Software Labs
http://3w-agility.blogspot.com/
http://cplusplus-soup.blogspot.com/
Mobile: +639287291459
Email: dean [at] orangeandbronze [dot] com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk