5 #ifndef DYNAMIC_GRAPH_SIGNAL_CASTER_HH 6 #define DYNAMIC_GRAPH_SIGNAL_CASTER_HH 11 #include <boost/any.hpp> 12 #include <boost/format.hpp> 13 #include <boost/function/function1.hpp> 14 #include <boost/function/function2.hpp> 15 #include <boost/lexical_cast.hpp> 16 #include <boost/tuple/tuple.hpp> 18 #include "dynamic-graph/exception-signal.h" 19 #include <dynamic-graph/dynamic-graph-api.h> 37 static void destroy();
41 typedef boost::function2<void, const boost::any &, std::ostream &>
43 typedef boost::function1<boost::any, std::istringstream &> caster_type;
44 typedef boost::function2<void, const boost::any &, std::ostream &>
50 void disp(
const boost::any &
object, std::ostream &os);
52 void trace(
const boost::any &
object, std::ostream &os);
54 boost::any cast(
const std::type_info &, std::istringstream &iss);
56 void registerCast(
const std::type_info &type,
displayer_type displayer,
57 caster_type caster, tracer_type tracer);
59 void unregisterCast(
const std::type_info &type);
61 bool existsCast(
const std::type_info &type)
const;
63 std::vector<std::string> listTypenames()
const;
67 typedef boost::tuple<displayer_type, caster_type, tracer_type>
71 cast_functions_type &getCast(
const std::string &type_name);
75 std::map<std::string, cast_functions_type> functions_;
77 std::map<std::string, const std::type_info *> type_info_;
94 SignalCaster::caster_type caster,
95 SignalCaster::tracer_type tracer) {
104 template <
typename T>
void signal_disp(
const T &value, std::ostream &os) {
108 template <
typename T> T signal_cast(std::istringstream &iss) {
112 template <
typename T>
void signal_trace(
const T &value, std::ostream &os) {
void trace(const boost::any &object, std::ostream &os)
Traces an object using a registered trace function.
void signal_disp(const T &value, std::ostream &os)
static SignalCaster * getInstance(void)
Get a reference to the unique object of the class.
boost::function2< void, const boost::any &, std::ostream & > displayer_type
boost::any cast(const std::type_info &, std::istringstream &iss)
Casts an object using a registered cast function.
void disp(const boost::any &object, std::ostream &os)
Displays an object using a registered displayer function.
void registerCast(const std::type_info &type, displayer_type displayer, caster_type caster, tracer_type tracer)
Registers a cast.