Skip to content
Snippets Groups Projects
Commit 9cba6ea9 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Remove method trace from DefaultCastRegisterer

parent 0131dbda
Branches
Tags
No related merge requests found
......@@ -33,17 +33,13 @@ template <typename T>
class DefaultCastRegisterer : public SignalCastRegisterer {
public:
DefaultCastRegisterer()
: SignalCastRegisterer(typeid(T), disp, cast, trace) {}
: SignalCastRegisterer(typeid(T), disp, cast) {}
static boost::any cast(std::istringstream &iss);
static void disp(const boost::any &object, std::ostream &os) {
os << boost::any_cast<T>(object) << std::endl;
}
static void trace(const boost::any &object, std::ostream &os) {
disp(object, os);
}
};
/// A default version of the caster, to serialize directly from
......@@ -81,7 +77,6 @@ template <class T> class SignalCast {
public:
static T cast(std::istringstream &) { throw 1; }
static void disp(const T &, std::ostream &) { throw 1; }
static void trace(const T &t, std::ostream &os) { disp(t, os); }
public:
// adapter functions for SignalCast
......@@ -91,9 +86,6 @@ public:
static void disp_(const boost::any &t, std::ostream &os) {
disp(boost::any_cast<T>(t), os);
}
static void trace_(const boost::any &t, std::ostream &os) {
trace(boost::any_cast<T>(t), os);
}
private:
SignalCast() {}
......
......@@ -42,20 +42,16 @@ public:
typedef boost::function2<void, const boost::any &, std::ostream &>
displayer_type;
typedef boost::function1<boost::any, std::istringstream &> caster_type;
typedef boost::function2<void, const boost::any &, std::ostream &>
tracer_type;
/// Get a reference to the unique object of the class.
static SignalCaster *getInstance(void);
/// Displays an object using a registered displayer function.
void disp(const boost::any &object, std::ostream &os);
/// Traces an object using a registered trace function.
void trace(const boost::any &object, std::ostream &os);
/// Casts an object using a registered cast function.
boost::any cast(const std::type_info &, std::istringstream &iss);
/// Registers a cast.
void registerCast(const std::type_info &type, displayer_type displayer,
caster_type caster, tracer_type tracer);
caster_type caster);
/// Unregister a cast.
void unregisterCast(const std::type_info &type);
/// Checks if there is a displayer registered with type_name.
......@@ -65,7 +61,7 @@ public:
private:
/// Container for the three cast functions.
typedef boost::tuple<displayer_type, caster_type, tracer_type>
typedef boost::tuple<displayer_type, caster_type>
cast_functions_type;
/// \brief Retrieve cast structure from its name.
......@@ -92,9 +88,8 @@ class DYNAMIC_GRAPH_DLLAPI SignalCastRegisterer {
public:
inline SignalCastRegisterer(const std::type_info &type,
SignalCaster::displayer_type displayer,
SignalCaster::caster_type caster,
SignalCaster::tracer_type tracer) {
SignalCaster::getInstance()->registerCast(type, displayer, caster, tracer);
SignalCaster::caster_type caster) {
SignalCaster::getInstance()->registerCast(type, displayer, caster);
}
};
......
......@@ -28,8 +28,7 @@ void SignalCaster::destroy() {
void SignalCaster::registerCast(const std::type_info &type,
SignalCaster::displayer_type displayer,
SignalCaster::caster_type caster,
SignalCaster::tracer_type tracer) {
SignalCaster::caster_type caster) {
if (existsCast(type)) {
// If type name has already been registered for same type, do not throw.
if (type_info_[type.name()] != &type) {
......@@ -45,7 +44,7 @@ void SignalCaster::registerCast(const std::type_info &type,
throw ExceptionSignal(ExceptionSignal::GENERIC, os.str());
}
}
functions_[type.name()] = cast_functions_type(displayer, caster, tracer);
functions_[type.name()] = cast_functions_type(displayer, caster);
type_info_[type.name()] = &type;
}
......@@ -75,10 +74,6 @@ void SignalCaster::disp(const boost::any &object, std::ostream &os) {
getCast(object.type().name()).get<0>()(object, os);
}
void SignalCaster::trace(const boost::any &object, std::ostream &os) {
getCast(object.type().name()).get<2>()(object, os);
}
std::vector<std::string> SignalCaster::listTypenames() const {
std::vector<std::string> typeList;
for (std::map<std::string, cast_functions_type>::const_iterator iter =
......
......@@ -35,8 +35,7 @@ struct EigenCastRegisterer_V : public dynamicgraph::SignalCastRegisterer {
typedef Vector bnuVector;
EigenCastRegisterer_V()
: SignalCastRegisterer(typeid(bnuVector), dispVector, castVector,
traceVector) {}
: SignalCastRegisterer(typeid(bnuVector), dispVector, castVector) {}
static boost::any castVector(std::istringstream &iss) {
bnuVector res;
......@@ -51,13 +50,6 @@ struct EigenCastRegisterer_V : public dynamicgraph::SignalCastRegisterer {
os << v(i) << " ";
os << " ];" << std::endl;
}
static void traceVector(const boost::any &object, std::ostream &os) {
const bnuVector &v = boost::any_cast<bnuVector>(object);
for (int i = 0; i < v.size(); ++i)
os << v(i) << " ";
os << std::endl;
}
};
template <typename Derived>
......@@ -65,8 +57,7 @@ struct EigenCastRegisterer_M : public dynamicgraph::SignalCastRegisterer {
typedef Matrix bnuMatrix;
EigenCastRegisterer_M()
: SignalCastRegisterer(typeid(bnuMatrix), dispMatrix, castMatrix,
traceMatrix) {}
: SignalCastRegisterer(typeid(bnuMatrix), dispMatrix, castMatrix) {}
static boost::any castMatrix(std::istringstream &iss) {
bnuMatrix res;
......@@ -78,11 +69,6 @@ struct EigenCastRegisterer_M : public dynamicgraph::SignalCastRegisterer {
const bnuMatrix &m = boost::any_cast<bnuMatrix>(object);
os << m << std::endl;
}
static void traceMatrix(const boost::any &object, std::ostream &os) {
const bnuMatrix &m = boost::any_cast<bnuMatrix>(object);
os << m << std::endl;
}
};
EigenCastRegisterer_V myVectorCast;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment