dynamic-graph  4.1.0-8-gdab7-dirty
Dynamic graph library
SignalCaster Class Reference

#include <dynamic-graph/signal-caster.h>

Public Types

typedef boost::function1< boost::any, std::istringstream & > caster_type
 
typedef boost::function2< void, const boost::any &, std::ostream & > displayer_type
 
typedef boost::function2< void, const boost::any &, std::ostream & > tracer_type
 

Public Member Functions

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.
 
bool existsCast (const std::type_info &type) const
 Checks if there is a displayer registered with type_name.
 
std::vector< std::string > listTypenames () const
 Return the list of type names registered.
 
void registerCast (const std::type_info &type, displayer_type displayer, caster_type caster, tracer_type tracer)
 Registers a cast.
 
void trace (const boost::any &object, std::ostream &os)
 Traces an object using a registered trace function.
 
void unregisterCast (const std::type_info &type)
 Unregister a cast.
 

Static Public Member Functions

static void destroy ()
 Destroy the unique instance.
 
static SignalCastergetInstance (void)
 Get a reference to the unique object of the class.
 

Detailed Description

This singleton class allows serialization of a number of objects into (disp) and from (cast) std i/o streams.

The transformation is done at run-time, i.e. SignalCaster doesn't know about the type of objects it casts to.

It also allows registering of user-defined casts. A cast is identified by the compiler. The mapping from a type to a serialization function is dynamic, hence it is more complex than a typical template-based compile-time resolve. So disp, cast and trace are costly functions and should be used as such.

Definition at line 33 of file signal-caster.h.

Member Typedef Documentation

◆ displayer_type

typedef boost::function2<void, const boost::any &, std::ostream &> displayer_type

Typedef of displayer functions that take an encapsulated 'any' object and displays, cast, or trace it on an output stream (serialization).

Definition at line 42 of file signal-caster.h.


The documentation for this class was generated from the following file: