Skip to content

Commit 9cba6ea

Browse files
committed
Remove method trace from DefaultCastRegisterer
1 parent 0131dbd commit 9cba6ea

File tree

4 files changed

+9
-41
lines changed

4 files changed

+9
-41
lines changed

include/dynamic-graph/signal-cast-helper.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,13 @@ template <typename T>
3333
class DefaultCastRegisterer : public SignalCastRegisterer {
3434
public:
3535
DefaultCastRegisterer()
36-
: SignalCastRegisterer(typeid(T), disp, cast, trace) {}
36+
: SignalCastRegisterer(typeid(T), disp, cast) {}
3737

3838
static boost::any cast(std::istringstream &iss);
3939

4040
static void disp(const boost::any &object, std::ostream &os) {
4141
os << boost::any_cast<T>(object) << std::endl;
4242
}
43-
44-
static void trace(const boost::any &object, std::ostream &os) {
45-
disp(object, os);
46-
}
4743
};
4844

4945
/// A default version of the caster, to serialize directly from
@@ -81,7 +77,6 @@ template <class T> class SignalCast {
8177
public:
8278
static T cast(std::istringstream &) { throw 1; }
8379
static void disp(const T &, std::ostream &) { throw 1; }
84-
static void trace(const T &t, std::ostream &os) { disp(t, os); }
8580

8681
public:
8782
// adapter functions for SignalCast
@@ -91,9 +86,6 @@ template <class T> class SignalCast {
9186
static void disp_(const boost::any &t, std::ostream &os) {
9287
disp(boost::any_cast<T>(t), os);
9388
}
94-
static void trace_(const boost::any &t, std::ostream &os) {
95-
trace(boost::any_cast<T>(t), os);
96-
}
9789

9890
private:
9991
SignalCast() {}

include/dynamic-graph/signal-caster.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,16 @@ class DYNAMIC_GRAPH_DLLAPI SignalCaster {
4242
typedef boost::function2<void, const boost::any &, std::ostream &>
4343
displayer_type;
4444
typedef boost::function1<boost::any, std::istringstream &> caster_type;
45-
typedef boost::function2<void, const boost::any &, std::ostream &>
46-
tracer_type;
4745

4846
/// Get a reference to the unique object of the class.
4947
static SignalCaster *getInstance(void);
5048
/// Displays an object using a registered displayer function.
5149
void disp(const boost::any &object, std::ostream &os);
52-
/// Traces an object using a registered trace function.
53-
void trace(const boost::any &object, std::ostream &os);
5450
/// Casts an object using a registered cast function.
5551
boost::any cast(const std::type_info &, std::istringstream &iss);
5652
/// Registers a cast.
5753
void registerCast(const std::type_info &type, displayer_type displayer,
58-
caster_type caster, tracer_type tracer);
54+
caster_type caster);
5955
/// Unregister a cast.
6056
void unregisterCast(const std::type_info &type);
6157
/// Checks if there is a displayer registered with type_name.
@@ -65,7 +61,7 @@ class DYNAMIC_GRAPH_DLLAPI SignalCaster {
6561

6662
private:
6763
/// Container for the three cast functions.
68-
typedef boost::tuple<displayer_type, caster_type, tracer_type>
64+
typedef boost::tuple<displayer_type, caster_type>
6965
cast_functions_type;
7066

7167
/// \brief Retrieve cast structure from its name.
@@ -92,9 +88,8 @@ class DYNAMIC_GRAPH_DLLAPI SignalCastRegisterer {
9288
public:
9389
inline SignalCastRegisterer(const std::type_info &type,
9490
SignalCaster::displayer_type displayer,
95-
SignalCaster::caster_type caster,
96-
SignalCaster::tracer_type tracer) {
97-
SignalCaster::getInstance()->registerCast(type, displayer, caster, tracer);
91+
SignalCaster::caster_type caster) {
92+
SignalCaster::getInstance()->registerCast(type, displayer, caster);
9893
}
9994
};
10095

src/signal/signal-caster.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ void SignalCaster::destroy() {
2828

2929
void SignalCaster::registerCast(const std::type_info &type,
3030
SignalCaster::displayer_type displayer,
31-
SignalCaster::caster_type caster,
32-
SignalCaster::tracer_type tracer) {
31+
SignalCaster::caster_type caster) {
3332
if (existsCast(type)) {
3433
// If type name has already been registered for same type, do not throw.
3534
if (type_info_[type.name()] != &type) {
@@ -45,7 +44,7 @@ void SignalCaster::registerCast(const std::type_info &type,
4544
throw ExceptionSignal(ExceptionSignal::GENERIC, os.str());
4645
}
4746
}
48-
functions_[type.name()] = cast_functions_type(displayer, caster, tracer);
47+
functions_[type.name()] = cast_functions_type(displayer, caster);
4948
type_info_[type.name()] = &type;
5049
}
5150

@@ -75,10 +74,6 @@ void SignalCaster::disp(const boost::any &object, std::ostream &os) {
7574
getCast(object.type().name()).get<0>()(object, os);
7675
}
7776

78-
void SignalCaster::trace(const boost::any &object, std::ostream &os) {
79-
getCast(object.type().name()).get<2>()(object, os);
80-
}
81-
8277
std::vector<std::string> SignalCaster::listTypenames() const {
8378
std::vector<std::string> typeList;
8479
for (std::map<std::string, cast_functions_type>::const_iterator iter =

tests/signal-cast-registerer.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ struct EigenCastRegisterer_V : public dynamicgraph::SignalCastRegisterer {
3535
typedef Vector bnuVector;
3636

3737
EigenCastRegisterer_V()
38-
: SignalCastRegisterer(typeid(bnuVector), dispVector, castVector,
39-
traceVector) {}
38+
: SignalCastRegisterer(typeid(bnuVector), dispVector, castVector) {}
4039

4140
static boost::any castVector(std::istringstream &iss) {
4241
bnuVector res;
@@ -51,22 +50,14 @@ struct EigenCastRegisterer_V : public dynamicgraph::SignalCastRegisterer {
5150
os << v(i) << " ";
5251
os << " ];" << std::endl;
5352
}
54-
55-
static void traceVector(const boost::any &object, std::ostream &os) {
56-
const bnuVector &v = boost::any_cast<bnuVector>(object);
57-
for (int i = 0; i < v.size(); ++i)
58-
os << v(i) << " ";
59-
os << std::endl;
60-
}
6153
};
6254

6355
template <typename Derived>
6456
struct EigenCastRegisterer_M : public dynamicgraph::SignalCastRegisterer {
6557
typedef Matrix bnuMatrix;
6658

6759
EigenCastRegisterer_M()
68-
: SignalCastRegisterer(typeid(bnuMatrix), dispMatrix, castMatrix,
69-
traceMatrix) {}
60+
: SignalCastRegisterer(typeid(bnuMatrix), dispMatrix, castMatrix) {}
7061

7162
static boost::any castMatrix(std::istringstream &iss) {
7263
bnuMatrix res;
@@ -78,11 +69,6 @@ struct EigenCastRegisterer_M : public dynamicgraph::SignalCastRegisterer {
7869
const bnuMatrix &m = boost::any_cast<bnuMatrix>(object);
7970
os << m << std::endl;
8071
}
81-
82-
static void traceMatrix(const boost::any &object, std::ostream &os) {
83-
const bnuMatrix &m = boost::any_cast<bnuMatrix>(object);
84-
os << m << std::endl;
85-
}
8672
};
8773

8874
EigenCastRegisterer_V myVectorCast;

0 commit comments

Comments
 (0)