Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cberge/dynamic-graph
  • ostasse/dynamic-graph
  • gsaurel/dynamic-graph
  • stack-of-tasks/dynamic-graph
4 results
Show changes
Showing
with 348 additions and 331 deletions
......@@ -41,21 +41,22 @@ namespace command {
/// \li T should be a type supported by class Value,
/// \li prototype of E::setParameter should be exactly as specified in this
/// example.
template <class E, typename T> class Setter : public Command {
public:
template <class E, typename T>
class Setter : public Command {
public:
/// Pointer to method that sets parameter of type T
typedef void (E::*SetterMethod)(const T &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
};
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
#include "dynamic-graph/command-setter.t.cpp"
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_H
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_H
......@@ -8,10 +8,12 @@
#define DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
#include "dynamic-graph/command-setter.h"
#include "dynamic-graph/linear-algebra.h"
#include <boost/assign/list_of.hpp>
#include <sstream>
#include "dynamic-graph/linear-algebra.h"
namespace dynamicgraph {
class Entity;
namespace command {
......@@ -19,19 +21,20 @@ namespace command {
//
// Template specialization: bool
//
template <class E> class Setter<E, bool> : public Command {
public:
template <class E>
class Setter<E, bool> : public Command {
public:
/// Pointer to method that sets parameter of type bool
typedef void (E::*SetterMethod)(const bool &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, bool>::Setter(E &entity, SetterMethod setterMethod,
......@@ -39,7 +42,8 @@ Setter<E, bool>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::BOOL), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, bool>::doExecute() {
template <class E>
Value Setter<E, bool>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
bool value = values[0].value();
......@@ -51,19 +55,20 @@ template <class E> Value Setter<E, bool>::doExecute() {
//
// Template specialization: unsigned
//
template <class E> class Setter<E, unsigned> : public Command {
public:
template <class E>
class Setter<E, unsigned> : public Command {
public:
/// Pointer to method that sets parameter of type unsigned
typedef void (E::*SetterMethod)(const unsigned &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, unsigned>::Setter(E &entity, SetterMethod setterMethod,
......@@ -71,7 +76,8 @@ Setter<E, unsigned>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::UNSIGNED), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, unsigned>::doExecute() {
template <class E>
Value Setter<E, unsigned>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
unsigned value = values[0].value();
......@@ -83,19 +89,20 @@ template <class E> Value Setter<E, unsigned>::doExecute() {
//
// Template specialization: int
//
template <class E> class Setter<E, int> : public Command {
public:
template <class E>
class Setter<E, int> : public Command {
public:
/// Pointer to method that sets parameter of type int
typedef void (E::*SetterMethod)(const int &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, int>::Setter(E &entity, SetterMethod setterMethod,
......@@ -103,7 +110,8 @@ Setter<E, int>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::INT), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, int>::doExecute() {
template <class E>
Value Setter<E, int>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
int value = values[0].value();
......@@ -115,19 +123,20 @@ template <class E> Value Setter<E, int>::doExecute() {
//
// Template specialization: float
//
template <class E> class Setter<E, float> : public Command {
public:
template <class E>
class Setter<E, float> : public Command {
public:
/// Pointer to method that sets parameter of type float
typedef void (E::*SetterMethod)(const float &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, float>::Setter(E &entity, SetterMethod setterMethod,
......@@ -135,7 +144,8 @@ Setter<E, float>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::FLOAT), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, float>::doExecute() {
template <class E>
Value Setter<E, float>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
float value = values[0].value();
......@@ -147,19 +157,20 @@ template <class E> Value Setter<E, float>::doExecute() {
//
// Template specialization: double
//
template <class E> class Setter<E, double> : public Command {
public:
template <class E>
class Setter<E, double> : public Command {
public:
/// Pointer to method that sets parameter of type double
typedef void (E::*SetterMethod)(const double &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, double>::Setter(E &entity, SetterMethod setterMethod,
......@@ -167,7 +178,8 @@ Setter<E, double>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::DOUBLE), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, double>::doExecute() {
template <class E>
Value Setter<E, double>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
double value = values[0].value();
......@@ -179,19 +191,20 @@ template <class E> Value Setter<E, double>::doExecute() {
//
// Template specialization: std::string
//
template <class E> class Setter<E, std::string> : public Command {
public:
template <class E>
class Setter<E, std::string> : public Command {
public:
/// Pointer to method that sets parameter of type std::string
typedef void (E::*SetterMethod)(const std::string &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, std::string>::Setter(E &entity, SetterMethod setterMethod,
......@@ -199,7 +212,8 @@ Setter<E, std::string>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::STRING), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, std::string>::doExecute() {
template <class E>
Value Setter<E, std::string>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
std::string value = values[0].value();
......@@ -211,19 +225,20 @@ template <class E> Value Setter<E, std::string>::doExecute() {
//
// Template specialization: Vector
//
template <class E> class Setter<E, Vector> : public Command {
public:
template <class E>
class Setter<E, Vector> : public Command {
public:
/// Pointer to method that sets parameter of type Vector
typedef void (E::*SetterMethod)(const Vector &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, Vector>::Setter(E &entity, SetterMethod setterMethod,
......@@ -231,7 +246,8 @@ Setter<E, Vector>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::VECTOR), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, Vector>::doExecute() {
template <class E>
Value Setter<E, Vector>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
Vector value = values[0].value();
......@@ -243,19 +259,20 @@ template <class E> Value Setter<E, Vector>::doExecute() {
//
// Template specialization: Matrix
//
template <class E> class Setter<E, Matrix> : public Command {
public:
template <class E>
class Setter<E, Matrix> : public Command {
public:
/// Pointer to method that sets parameter of type Matrix
typedef void (E::*SetterMethod)(const Matrix &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, Matrix>::Setter(E &entity, SetterMethod setterMethod,
......@@ -263,7 +280,8 @@ Setter<E, Matrix>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::MATRIX), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, Matrix>::doExecute() {
template <class E>
Value Setter<E, Matrix>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
Matrix value = values[0].value();
......@@ -272,7 +290,7 @@ template <class E> Value Setter<E, Matrix>::doExecute() {
return Value();
}
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
......@@ -7,9 +7,10 @@
#ifndef DYNAMIC_GRAPH_COMMAND_H
#define DYNAMIC_GRAPH_COMMAND_H
#include <vector>
#include "dynamic-graph/dynamic-graph-api.h"
#include "dynamic-graph/value.h"
#include <vector>
namespace dynamicgraph {
class Entity;
......@@ -32,7 +33,7 @@ namespace command {
/// vector of Values the types of which should fit the vector specified
/// at construction.
class DYNAMIC_GRAPH_DLLAPI Command {
public:
public:
virtual ~Command();
/// Store the owner entity and a vector of value types
/// \param entity reference to Entity owning this command.
......@@ -53,20 +54,20 @@ public:
/// Get documentation string
std::string getDocstring() const;
protected:
protected:
/// Specific action performed by the command
virtual Value doExecute() = 0;
private:
private:
Entity &owner_;
std::vector<Value::Type> valueTypeVector_;
std::vector<Value> valueVector_;
std::string docstring_;
public:
public:
static const std::vector<Value::Type> EMPTY_ARG;
};
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_COMMAND_H
#endif // DYNAMIC_GRAPH_COMMAND_H
......@@ -5,29 +5,29 @@
#ifndef DYNAMIC_GRAPH_DEBUG_HH
#define DYNAMIC_GRAPH_DEBUG_HH
#include <dynamic-graph/dynamic-graph-api.h>
#include <cstdarg>
#include <cstdio>
#include <dynamic-graph/fwd.hh>
#include <fstream>
#include <sstream>
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/fwd.hh>
#ifndef VP_DEBUG_MODE
#define VP_DEBUG_MODE 0
#endif //! VP_DEBUG_MODE
#endif //! VP_DEBUG_MODE
#ifndef VP_TEMPLATE_DEBUG_MODE
#define VP_TEMPLATE_DEBUG_MODE 0
#endif //! VP_TEMPLATE_DEBUG_MODE
#define DG_COMMON_TRACES \
do { \
va_list arg; \
va_start(arg, format); \
vsnprintf(charbuffer, SIZE, format, arg); \
va_end(arg); \
outputbuffer << tmpbuffer.str() << charbuffer << std::endl; \
#endif //! VP_TEMPLATE_DEBUG_MODE
#define DG_COMMON_TRACES \
do { \
va_list arg; \
va_start(arg, format); \
vsnprintf(charbuffer, SIZE, format, arg); \
va_end(arg); \
outputbuffer << tmpbuffer.str() << charbuffer << std::endl; \
} while (0)
namespace dynamicgraph {
......@@ -38,7 +38,7 @@ namespace dynamicgraph {
/// This class should never be used directly, please use the
/// debugging macro instead.
class DYNAMIC_GRAPH_DLLAPI DebugTrace {
public:
public:
static const int SIZE = 512;
std::stringstream tmpbuffer;
......@@ -50,8 +50,7 @@ public:
DebugTrace(std::ostream &os) : outputbuffer(os) {}
inline void trace(const int level, const char *format, ...) {
if (level <= traceLevel)
DG_COMMON_TRACES;
if (level <= traceLevel) DG_COMMON_TRACES;
tmpbuffer.str("");
}
......@@ -68,8 +67,7 @@ public:
}
inline void traceTemplate(const int level, const char *format, ...) {
if (level <= traceLevelTemplate)
DG_COMMON_TRACES;
if (level <= traceLevelTemplate) DG_COMMON_TRACES;
tmpbuffer.str("");
}
......@@ -92,57 +90,57 @@ public:
DYNAMIC_GRAPH_DLLAPI extern DebugTrace dgDEBUGFLOW;
DYNAMIC_GRAPH_DLLAPI extern DebugTrace dgERRORFLOW;
} // end of namespace dynamicgraph
} // end of namespace dynamicgraph
#ifdef VP_DEBUG
#define dgPREDEBUG __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") :"
#define dgPREERROR \
#define dgPREERROR \
"\t!! " << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") :"
#define dgDEBUG(level) \
if ((level > VP_DEBUG_MODE) || (!dgDEBUGFLOW.outputbuffer.good())) \
; \
else \
#define dgDEBUG(level) \
if ((level > VP_DEBUG_MODE) || (!dgDEBUGFLOW.outputbuffer.good())) \
; \
else \
dgDEBUGFLOW.outputbuffer << dgPREDEBUG
#define dgDEBUGMUTE(level) \
if ((level > VP_DEBUG_MODE) || (!dgDEBUGFLOW.outputbuffer.good())) \
; \
else \
#define dgDEBUGMUTE(level) \
if ((level > VP_DEBUG_MODE) || (!dgDEBUGFLOW.outputbuffer.good())) \
; \
else \
dgDEBUGFLOW.outputbuffer
#define dgERROR \
if (!dgDEBUGFLOW.outputbuffer.good()) \
; \
else \
#define dgERROR \
if (!dgDEBUGFLOW.outputbuffer.good()) \
; \
else \
dgERRORFLOW.outputbuffer << dgPREERROR
#define dgDEBUGF \
if (!dgDEBUGFLOW.outputbuffer.good()) \
; \
else \
#define dgDEBUGF \
if (!dgDEBUGFLOW.outputbuffer.good()) \
; \
else \
dgDEBUGFLOW.pre(dgDEBUGFLOW.tmpbuffer << dgPREDEBUG, VP_DEBUG_MODE).trace
#define dgERRORF \
if (!dgDEBUGFLOW.outputbuffer.good()) \
; \
else \
#define dgERRORF \
if (!dgDEBUGFLOW.outputbuffer.good()) \
; \
else \
dgERRORFLOW.pre(dgERRORFLOW.tmpbuffer << dgPREERROR).trace
// TEMPLATE
#define dgTDEBUG(level) \
if ((level > VP_TEMPLATE_DEBUG_MODE) || (!dgDEBUGFLOW.outputbuffer.good())) \
; \
else \
#define dgTDEBUG(level) \
if ((level > VP_TEMPLATE_DEBUG_MODE) || (!dgDEBUGFLOW.outputbuffer.good())) \
; \
else \
dgDEBUGFLOW.outputbuffer << dgPREDEBUG
#define dgTDEBUGF \
if (!dgDEBUGFLOW.outputbuffer.good()) \
; \
else \
dgDEBUGFLOW \
.pre(dgDEBUGFLOW.tmpbuffer << dgPREDEBUG, VP_TEMPLATE_DEBUG_MODE) \
#define dgTDEBUGF \
if (!dgDEBUGFLOW.outputbuffer.good()) \
; \
else \
dgDEBUGFLOW \
.pre(dgDEBUGFLOW.tmpbuffer << dgPREDEBUG, VP_TEMPLATE_DEBUG_MODE) \
.trace
inline bool dgDEBUG_ENABLE(const int &level) { return level <= VP_DEBUG_MODE; }
......@@ -151,19 +149,19 @@ inline bool dgTDEBUG_ENABLE(const int &level) {
return level <= VP_TEMPLATE_DEBUG_MODE;
}
#else // VP_DEBUG
#else // VP_DEBUG
#define dgPREERROR \
#define dgPREERROR \
"\t!! " << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") :"
#define dgDEBUG(level) \
if (1) \
; \
else \
#define dgDEBUG(level) \
if (1) \
; \
else \
::dynamicgraph::__null_stream()
#define dgDEBUGMUTE \
(level) if (1); \
#define dgDEBUGMUTE \
(level) if (1); \
else ::dynamicgraph::__null_stream()
#define dgERROR dgERRORFLOW.outputbuffer << dgPREERROR
......@@ -183,13 +181,13 @@ inline std::ostream &__null_stream() {
static std::ostream os(NULL);
return os;
}
} // namespace dynamicgraph
} // namespace dynamicgraph
// TEMPLATE
#define dgTDEBUG(level) \
if (1) \
; \
else \
#define dgTDEBUG(level) \
if (1) \
; \
else \
::dynamicgraph::__null_stream()
inline void dgTDEBUGF(const int, const char *, ...) { return; }
......@@ -199,7 +197,7 @@ inline void dgTDEBUGF(const char *, ...) { return; }
#define dgDEBUG_ENABLE(level) false
#define dgTDEBUG_ENABLE(level) false
#endif //! VP_DEBUG
#endif //! VP_DEBUG
#define dgDEBUGIN(level) dgDEBUG(level) << "# In {" << std::endl
......@@ -213,4 +211,4 @@ inline void dgTDEBUGF(const char *, ...) { return; }
#define dgTDEBUGINOUT(level) dgTDEBUG(level) << "# In/Out { }" << std::endl
#endif //! DYNAMIC_GRAPH_DEBUG_HH
#endif //! DYNAMIC_GRAPH_DEBUG_HH
......@@ -6,4 +6,4 @@
#ifndef DYNAMIC_GRAPH_API_H
#define DYNAMIC_GRAPH_API_H
#include <dynamic-graph/config.hh>
#endif //! DYNAMIC_GRAPH_API_H
#endif //! DYNAMIC_GRAPH_API_H
......@@ -7,15 +7,13 @@
#ifndef DYNAMIC_GRAPH_EIGEN_IO_H
#define DYNAMIC_GRAPH_EIGEN_IO_H
#include <boost/format.hpp>
#include <boost/numeric/conversion/cast.hpp>
#pragma GCC diagnostic push
#pragma GCC system_header
#include <Eigen/Geometry>
#pragma GCC diagnostic pop
#include <dynamic-graph/exception-signal.h>
#include <dynamic-graph/linear-algebra.h>
#include <Eigen/Geometry>
#include <boost/format.hpp>
#include <boost/numeric/conversion/cast.hpp>
using dynamicgraph::ExceptionSignal;
// TODO: Eigen 3.3 onwards has a global Eigen::Index definition.
......@@ -34,8 +32,9 @@ inline std::istringstream &operator>>(std::istringstream &iss,
unsigned int _size;
double _dbl_val;
char _ch;
boost::format fmt("Failed to enter %s as vector."
" Reenter as [N](val1,val2,val3,...,valN)");
boost::format fmt(
"Failed to enter %s as vector."
" Reenter as [N](val1,val2,val3,...,valN)");
fmt % iss.str();
if (iss >> _ch && _ch != '[') {
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
......@@ -52,8 +51,7 @@ inline std::istringstream &operator>>(std::istringstream &iss,
else {
for (unsigned int i = 0; i < _size; i++) {
iss >> _dbl_val;
if (iss.peek() == ',' || iss.peek() == ' ')
iss.ignore();
if (iss.peek() == ',' || iss.peek() == ' ') iss.ignore();
inst(i) = _dbl_val;
}
if (iss >> _ch && _ch != ')')
......@@ -78,17 +76,17 @@ inline std::istringstream &operator>>(std::istringstream &iss,
unsigned int _rowsize;
double _dbl_val;
char _ch;
boost::format fmt("Failed to enter %s as matrix. Reenter as "
"((val11,val12,val13,...,val1N),"
"...,(valM1,valM2,...,valMN))");
boost::format fmt(
"Failed to enter %s as matrix. Reenter as "
"((val11,val12,val13,...,val1N),"
"...,(valM1,valM2,...,valMN))");
MatrixXd _tmp_matrix;
fmt % iss.str();
if (iss >> _ch && _ch != '[') {
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
} else {
iss >> _rowsize;
if (iss.peek() == ',' || iss.peek() == ' ')
iss.ignore();
if (iss.peek() == ',' || iss.peek() == ' ') iss.ignore();
iss >> _colsize;
if (iss.fail())
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
......@@ -105,14 +103,12 @@ inline std::istringstream &operator>>(std::istringstream &iss,
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
for (unsigned int i = 0; i < _colsize; i++) {
iss >> _dbl_val;
if (iss.peek() == ',' || iss.peek() == ' ')
iss.ignore();
if (iss.peek() == ',' || iss.peek() == ' ') iss.ignore();
_tmp_matrix(j, i) = _dbl_val;
}
if (iss >> _ch && _ch != ')')
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
if (iss.peek() == ',' || iss.peek() == ' ')
iss.ignore();
if (iss.peek() == ',' || iss.peek() == ' ') iss.ignore();
}
if (iss >> _ch && _ch != ')')
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
......@@ -165,6 +161,6 @@ inline std::istringstream &operator>>(std::istringstream &iss,
return iss;
}
} // namespace Eigen
} // namespace Eigen
#endif // DYNAMIC_GRAPH_EIGEN_IO_H
#endif // DYNAMIC_GRAPH_EIGEN_IO_H
......@@ -8,11 +8,12 @@
namespace dynamicgraph {
template <typename Ent> struct EntityHelper {
template <typename Ent>
struct EntityHelper {
typedef Ent EntityClassName;
// static const std::string CLASS_NAME; TO BE ADDED IN DG DIRECTLY
};
} // namespace dynamicgraph
} // namespace dynamicgraph
#endif // __sot_core_entity_helper_H__
#endif // __sot_core_entity_helper_H__
......@@ -5,20 +5,19 @@
#ifndef DYNAMIC_GRAPH_ENTITY_H
#define DYNAMIC_GRAPH_ENTITY_H
#include <iosfwd>
#include <map>
#include <sstream>
#include <string>
#include <boost/noncopyable.hpp>
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/fwd.hh>
#include <dynamic-graph/logger.h>
#include <dynamic-graph/signal-array.h>
#include <dynamic-graph/signal-base.h>
#include <boost/noncopyable.hpp>
#include <dynamic-graph/fwd.hh>
#include <iosfwd>
#include <map>
#include <sstream>
#include <string>
/// \brief Helper macro for entity declaration.
///
/// This macro should be called in the declaration of all entities.
......@@ -36,9 +35,9 @@
/// Caution: you *MUST* call DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN in the
/// associated source file to ensure that the attributes generated by
/// this macro are correctly initialized.
#define DYNAMIC_GRAPH_ENTITY_DECL() \
public: \
virtual const std::string &getClassName() const { return CLASS_NAME; } \
#define DYNAMIC_GRAPH_ENTITY_DECL() \
public: \
virtual const std::string &getClassName() const { return CLASS_NAME; } \
static const std::string CLASS_NAME
namespace dynamicgraph {
......@@ -51,7 +50,7 @@ namespace dynamicgraph {
/// computation graph. To declare a new entity, please see the
/// DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN macro in factory.h.
class DYNAMIC_GRAPH_DLLAPI Entity : private boost::noncopyable {
public:
public:
typedef std::map<std::string, SignalBase<int> *> SignalMap;
typedef std::map<const std::string, command::Command *> CommandMap_t;
......@@ -163,7 +162,7 @@ public:
/// \}
protected:
protected:
void addCommand(const std::string &name, command::Command *command);
void entityRegistration();
......@@ -180,6 +179,6 @@ protected:
DYNAMIC_GRAPH_DLLAPI std::ostream &operator<<(std::ostream &os,
const dynamicgraph::Entity &ent);
} // end of namespace dynamicgraph
} // end of namespace dynamicgraph
#endif //! DYNAMIC_GRAPH_ENTITY_H
#endif //! DYNAMIC_GRAPH_ENTITY_H
......@@ -5,42 +5,47 @@
#ifndef DYNAMIC_GRAPH_EXCEPTION_ABSTRACT_H
#define DYNAMIC_GRAPH_EXCEPTION_ABSTRACT_H
#include <string>
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/fwd.hh>
#include <string>
// Uncomment this macros to have lines parameter on the throw display
// #define DYNAMIC-GRAPH_EXCEPTION_PASSING_PARAM
#define DG_RETHROW \
#define DG_RETHROW \
(const ::dynamicgraph::ExceptionAbstract &err) { throw err; }
#ifdef DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
#define DG_THROW \
throw ::dynamicgraph::ExceptionAbstract::Param(__LINE__, __FUNCTION__, \
#define DG_THROW \
throw ::dynamicgraph::ExceptionAbstract::Param(__LINE__, __FUNCTION__, \
__FILE__) +
#else
#define DG_THROW throw
#endif // DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
#endif // DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
namespace dynamicgraph {
/// \ingroup error
///
/// \brief Abstract root class for all dynamic-graph exceptions.
class DYNAMIC_GRAPH_DLLAPI ExceptionAbstract : public std::exception {
public:
public:
/// \ingroup error
///
/// \brief Class owned by exceptions to store error locations.
class Param {
public:
public:
static const int BUFFER_SIZE = 80;
Param(const int &_line, const char *_function, const char *_file);
Param()
: functionPTR(), function(), line(), filePTR(), file(),
pointersSet(false), set(false) {}
: functionPTR(),
function(),
line(),
filePTR(),
file(),
pointersSet(false),
set(false) {}
Param &initCopy(const Param &p);
const char *functionPTR;
......@@ -91,10 +96,10 @@ public:
}
/// \brief Print the error structure.
DYNAMIC_GRAPH_DLLAPI friend std::ostream &
operator<<(std::ostream &os, const ExceptionAbstract &err);
DYNAMIC_GRAPH_DLLAPI friend std::ostream &operator<<(
std::ostream &os, const ExceptionAbstract &err);
protected:
protected:
/// \brief Error code.
/// \sa ErrorCodeEnum
int code;
......@@ -121,12 +126,12 @@ protected:
return e;
}
#endif // DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
#endif // DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
private:
private:
/// \brief Forbid the empty constructor (private).
ExceptionAbstract();
};
} // end of namespace dynamicgraph
} // end of namespace dynamicgraph
#endif //! DYNAMIC_GRAPH_EXCEPTION_ABSTRACT_H
#endif //! DYNAMIC_GRAPH_EXCEPTION_ABSTRACT_H
......@@ -5,18 +5,18 @@
#ifndef DYNAMIC_GRAPH_EXCEPTION_FACTORY_H
#define DYNAMIC_GRAPH_EXCEPTION_FACTORY_H
#include <string>
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/exception-abstract.h>
#include <dynamic-graph/fwd.hh>
#include <string>
namespace dynamicgraph {
/// \ingroup error
///
/// \brief Generic error class.
class DYNAMIC_GRAPH_DLLAPI ExceptionFactory : public ExceptionAbstract {
public:
public:
enum ErrorCodeEnum {
GENERIC = ExceptionAbstract::FACTORY,
UNREFERED_OBJECT,
......@@ -44,6 +44,6 @@ public:
return ExceptionFactory::EXCEPTION_NAME;
}
};
} // end of namespace dynamicgraph
} // end of namespace dynamicgraph
#endif //! DYNAMIC_GRAPH_EXCEPTION_FACTORY_H
#endif //! DYNAMIC_GRAPH_EXCEPTION_FACTORY_H
......@@ -8,6 +8,7 @@
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/exception-abstract.h>
#include <dynamic-graph/fwd.hh>
namespace dynamicgraph {
......@@ -16,7 +17,7 @@ namespace dynamicgraph {
/// \brief Exceptions raised when an error related to signals
/// happen.
class DYNAMIC_GRAPH_DLLAPI ExceptionSignal : public ExceptionAbstract {
public:
public:
enum ErrorCodeEnum {
GENERIC = ExceptionAbstract::SIGNAL,
READWRITE_LOCK,
......@@ -38,6 +39,6 @@ public:
virtual const std::string &getExceptionName() const { return EXCEPTION_NAME; }
};
} // end of namespace dynamicgraph
} // end of namespace dynamicgraph
#endif //! DYNAMIC_GRAPH_EXCEPTION_SIGNAL_H
#endif //! DYNAMIC_GRAPH_EXCEPTION_SIGNAL_H
......@@ -5,18 +5,18 @@
#ifndef DYNAMIC_GRAPH_EXCEPTION_TRACES_H
#define DYNAMIC_GRAPH_EXCEPTION_TRACES_H
#include <string>
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/exception-abstract.h>
#include <dynamic-graph/fwd.hh>
#include <string>
namespace dynamicgraph {
/// \ingroup error
///
/// \brief Exceptions raised when an error related to traces happen.
class DYNAMIC_GRAPH_DLLAPI ExceptionTraces : public ExceptionAbstract {
public:
public:
enum ErrorCodeEnum { GENERIC = ExceptionAbstract::TRACES, NOT_OPEN };
static const std::string EXCEPTION_NAME;
......@@ -29,6 +29,6 @@ public:
virtual const std::string &getExceptionName() const { return EXCEPTION_NAME; }
};
} // end of namespace dynamicgraph.
} // end of namespace dynamicgraph.
#endif //! DYNAMIC_GRAPH_EXCEPTION_TRACES_H
#endif //! DYNAMIC_GRAPH_EXCEPTION_TRACES_H
......@@ -5,15 +5,14 @@
#ifndef DYNAMIC_GRAPH_FACTORY_HH
#define DYNAMIC_GRAPH_FACTORY_HH
#include <map>
#include <string>
#include <vector>
#include <boost/noncopyable.hpp>
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/exception-factory.h>
#include <boost/noncopyable.hpp>
#include <dynamic-graph/fwd.hh>
#include <map>
#include <string>
#include <vector>
/// \ingroup dgraph
///
......@@ -24,16 +23,16 @@
/// \param CLASSNAME the name of the Entity to be registered (this must
/// be a std::string or a type implicitly castable into a std::string
/// such as classic C string delimited by double quotes).
#define DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CLASSTYPE, CLASSNAME) \
const std::string CLASSTYPE::CLASS_NAME = CLASSNAME; \
extern "C" { \
::dynamicgraph::Entity * \
EntityMaker_##CLASSTYPE(const std::string &objname) { \
return new CLASSTYPE(objname); \
} \
::dynamicgraph::EntityRegisterer reg_##CLASSTYPE(CLASSNAME, \
&EntityMaker_##CLASSTYPE); \
} \
#define DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CLASSTYPE, CLASSNAME) \
const std::string CLASSTYPE::CLASS_NAME = CLASSNAME; \
extern "C" { \
::dynamicgraph::Entity *EntityMaker_##CLASSTYPE( \
const std::string &objname) { \
return new CLASSTYPE(objname); \
} \
::dynamicgraph::EntityRegisterer reg_##CLASSTYPE(CLASSNAME, \
&EntityMaker_##CLASSTYPE); \
} \
struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
namespace dynamicgraph {
......@@ -80,7 +79,7 @@ namespace dynamicgraph {
/// instance of this class enforces this behavior, instantiating one
/// yourself would break this property.
class DYNAMIC_GRAPH_DLLAPI FactoryStorage : private boost::noncopyable {
public:
public:
/// \brief Function pointer providing an entity instance from its
/// name.
typedef Entity *(*EntityConstructor_ptr)(const std::string &);
......@@ -151,7 +150,7 @@ public:
/// \param list Available entities will be appended to list.
void listEntities(std::vector<std::string> &list) const;
private:
private:
/// \brief Constructor the factory.
///
/// After the initialization, no entities will be available.
......@@ -183,7 +182,7 @@ private:
/// DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN macro and is of little interest
/// by itself.
class DYNAMIC_GRAPH_DLLAPI EntityRegisterer : private boost::noncopyable {
public:
public:
/// \brief Register entity to the global factory.
explicit EntityRegisterer(const std::string &entityClassName,
FactoryStorage::EntityConstructor_ptr maker);
......@@ -191,13 +190,13 @@ public:
/// \brief Unregister entity to the global factory.
~EntityRegisterer();
private:
private:
/// \brief Name of the entity registered when the instance has
/// been initialized.
const std::string entityName;
};
} // end of namespace dynamicgraph
} // end of namespace dynamicgraph
#endif //! DYNAMIC_GRAPH_FACTORY_HH
#endif //! DYNAMIC_GRAPH_FACTORY_HH
// LocalWords: unregister
......@@ -10,12 +10,12 @@
namespace dynamicgraph {
// to be replace by std:: when we switch to C++11 and later
using boost::shared_ptr;
using boost::weak_ptr;
using boost::static_pointer_cast;
using boost::dynamic_pointer_cast;
using boost::const_pointer_cast;
using boost::dynamic_pointer_cast;
using boost::make_shared;
using boost::shared_ptr;
using boost::static_pointer_cast;
using boost::weak_ptr;
class DebugTrace;
......@@ -38,22 +38,29 @@ class PoolStorage;
class Tracer;
class TracerRealTime;
template <typename T, typename Time> class Signal;
template <typename T, typename Time>
class Signal;
template <typename Time> class SignalArray;
template <typename Time>
class SignalArray;
template <typename Time> class SignalArray_const;
template <typename Time>
class SignalArray_const;
template <typename Time> class SignalBase;
template <typename Time>
class SignalBase;
template <typename T, typename Time> class SignalPtr;
template <typename T, typename Time> class SignalTimeDependent;
template <typename Time> class TimeDependency;
template <typename T, typename Time>
class SignalPtr;
template <typename T, typename Time>
class SignalTimeDependent;
template <typename Time>
class TimeDependency;
namespace command {
class Command;
} // end of namespace command.
} // end of namespace command.
} // end of namespace dynamicgraph.
} // end of namespace dynamicgraph.
#endif //! DYNAMIC_GRAPH_FWD_HH
#endif //! DYNAMIC_GRAPH_FWD_HH
......@@ -6,15 +6,12 @@
#ifndef DYNAMIC_GRAPH_LINEAR_ALGEBRA_H
#define DYNAMIC_GRAPH_LINEAR_ALGEBRA_H
#pragma GCC diagnostic push
#pragma GCC system_header
#include <Eigen/Core>
#include <Eigen/Geometry>
#pragma GCC diagnostic pop
namespace dynamicgraph {
typedef Eigen::MatrixXd Matrix;
typedef Eigen::VectorXd Vector;
} // namespace dynamicgraph
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_LINEAR_ALGEBRA_H
#endif // DYNAMIC_GRAPH_LINEAR_ALGEBRA_H
......@@ -27,19 +27,19 @@ namespace dynamicgraph {
/** Enum representing the different kind of messages.
*/
enum MsgType {
MSG_TYPE_TYPE_BITS = 1 << 0 | 1 << 1 | 1 << 2 | 1 << 3, // 15
MSG_TYPE_STREAM_BIT = 1 << 4, // 16
MSG_TYPE_DEBUG = 1 << 3, // 1
MSG_TYPE_INFO = 1 << 2, // 2
MSG_TYPE_WARNING = 1 << 1, // 4
MSG_TYPE_ERROR = 1 << 0, // 8
MSG_TYPE_DEBUG_STREAM = MSG_TYPE_DEBUG | MSG_TYPE_STREAM_BIT, // 17
MSG_TYPE_INFO_STREAM = MSG_TYPE_INFO | MSG_TYPE_STREAM_BIT, // 18
MSG_TYPE_WARNING_STREAM = MSG_TYPE_WARNING | MSG_TYPE_STREAM_BIT, // 20
MSG_TYPE_ERROR_STREAM = MSG_TYPE_ERROR | MSG_TYPE_STREAM_BIT // 24
MSG_TYPE_TYPE_BITS = 1 << 0 | 1 << 1 | 1 << 2 | 1 << 3, // 15
MSG_TYPE_STREAM_BIT = 1 << 4, // 16
MSG_TYPE_DEBUG = 1 << 3, // 1
MSG_TYPE_INFO = 1 << 2, // 2
MSG_TYPE_WARNING = 1 << 1, // 4
MSG_TYPE_ERROR = 1 << 0, // 8
MSG_TYPE_DEBUG_STREAM = MSG_TYPE_DEBUG | MSG_TYPE_STREAM_BIT, // 17
MSG_TYPE_INFO_STREAM = MSG_TYPE_INFO | MSG_TYPE_STREAM_BIT, // 18
MSG_TYPE_WARNING_STREAM = MSG_TYPE_WARNING | MSG_TYPE_STREAM_BIT, // 20
MSG_TYPE_ERROR_STREAM = MSG_TYPE_ERROR | MSG_TYPE_STREAM_BIT // 24
};
} // namespace dynamicgraph
} // namespace dynamicgraph
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
......@@ -47,23 +47,22 @@ enum MsgType {
#include <map>
/// \todo These 3 headers should be removed.
#include <fstream>
#include <iomanip> // std::setprecision
#include <sstream>
#include <dynamic-graph/linear-algebra.h>
#include <dynamic-graph/real-time-logger-def.h>
#include <boost/assign.hpp>
#include <boost/preprocessor/stringize.hpp>
#include <dynamic-graph/deprecated.hh>
#include <dynamic-graph/linear-algebra.h>
#include <dynamic-graph/real-time-logger-def.h>
#include <fstream>
#include <iomanip> // std::setprecision
#include <sstream>
namespace dynamicgraph {
//#define LOGGER_VERBOSITY_INFO_WARNING_ERROR
#define LOGGER_VERBOSITY_ALL
#define SEND_MSG(msg, type) \
#define SEND_MSG(msg, type) \
sendMsg(msg, type, __FILE__ ":" BOOST_PP_STRINGIZE(__LINE__))
#define SEND_DEBUG_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_DEBUG_STREAM)
......@@ -71,25 +70,25 @@ namespace dynamicgraph {
#define SEND_WARNING_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_WARNING_STREAM)
#define SEND_ERROR_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_ERROR_STREAM)
#define _DYNAMIC_GRAPH_ENTITY_MSG(entity, type) \
#define _DYNAMIC_GRAPH_ENTITY_MSG(entity, type) \
(entity).logger().stream(type, __FILE__ BOOST_PP_STRINGIZE(__LINE__))
#define DYNAMIC_GRAPH_ENTITY_DEBUG(entity) \
#define DYNAMIC_GRAPH_ENTITY_DEBUG(entity) \
_DYNAMIC_GRAPH_ENTITY_MSG(entity, MSG_TYPE_DEBUG)
#define DYNAMIC_GRAPH_ENTITY_INFO(entity) \
#define DYNAMIC_GRAPH_ENTITY_INFO(entity) \
_DYNAMIC_GRAPH_ENTITY_MSG(entity, MSG_TYPE_INFO)
#define DYNAMIC_GRAPH_ENTITY_WARNING(entity) \
#define DYNAMIC_GRAPH_ENTITY_WARNING(entity) \
_DYNAMIC_GRAPH_ENTITY_MSG(entity, MSG_TYPE_WARNING)
#define DYNAMIC_GRAPH_ENTITY_ERROR(entity) \
#define DYNAMIC_GRAPH_ENTITY_ERROR(entity) \
_DYNAMIC_GRAPH_ENTITY_MSG(entity, MSG_TYPE_ERROR)
#define DYNAMIC_GRAPH_ENTITY_DEBUG_STREAM(entity) \
#define DYNAMIC_GRAPH_ENTITY_DEBUG_STREAM(entity) \
_DYNAMIC_GRAPH_ENTITY_MSG(entity, MSG_TYPE_DEBUG_STREAM)
#define DYNAMIC_GRAPH_ENTITY_INFO_STREAM(entity) \
#define DYNAMIC_GRAPH_ENTITY_INFO_STREAM(entity) \
_DYNAMIC_GRAPH_ENTITY_MSG(entity, MSG_TYPE_INFO_STREAM)
#define DYNAMIC_GRAPH_ENTITY_WARNING_STREAM(entity) \
#define DYNAMIC_GRAPH_ENTITY_WARNING_STREAM(entity) \
_DYNAMIC_GRAPH_ENTITY_MSG(entity, MSG_TYPE_WARNING_STREAM)
#define DYNAMIC_GRAPH_ENTITY_ERROR_STREAM(entity) \
#define DYNAMIC_GRAPH_ENTITY_ERROR_STREAM(entity) \
_DYNAMIC_GRAPH_ENTITY_MSG(entity, MSG_TYPE_ERROR_STREAM)
template <typename T>
......@@ -185,7 +184,7 @@ enum LoggerVerbosity {
/// integer counting the number of calls. This will achieve exactly the
/// same behaviour without rouding numerical errors.
class Logger {
public:
public:
/** Constructor */
Logger(double timeSample = 0.001, double streamPrintPeriod = 1.0);
......@@ -211,8 +210,7 @@ public:
*/
RTLoggerStream stream(MsgType type, const std::string &lineId = "") {
RealTimeLogger &rtlogger = ::dynamicgraph::RealTimeLogger::instance();
if (acceptMsg(type, lineId))
return rtlogger.front();
if (acceptMsg(type, lineId)) return rtlogger.front();
return rtlogger.emptyStream();
}
......@@ -221,15 +219,16 @@ public:
* stream(type, lineId) << msg << '\n';
* \endcode
*/
void sendMsg(std::string msg, MsgType type, const std::string &lineId = "");
[[deprecated("use stream(type, lineId) << msg")]] void sendMsg(
std::string msg, MsgType type, const std::string &lineId = "");
/** \deprecated instead, use
* \code
* stream(type, lineId) << msg << '\n';
* \endcode
*/
void sendMsg(std::string msg, MsgType type, const std::string &file,
int line) DYNAMIC_GRAPH_DEPRECATED;
[[deprecated("use stream(type, lineId) << msg")]] void sendMsg(
std::string msg, MsgType type, const std::string &file, int line);
/** Set the sampling time at which the method countdown()
* is going to be called. */
......@@ -251,11 +250,11 @@ public:
/** Get the verbosity level of the logger. */
LoggerVerbosity getVerbosity();
protected:
LoggerVerbosity m_lv; /// verbosity of the logger
protected:
LoggerVerbosity m_lv; /// verbosity of the logger
double m_timeSample;
/// specify the period of call of the countdown method
double m_streamPrintPeriod; /// specify the time period of the stream prints
double m_streamPrintPeriod; /// specify the time period of the stream prints
double m_printCountdown;
/// every time this is < 0 (i.e. every _streamPrintPeriod sec) print stuff
......@@ -272,12 +271,10 @@ protected:
*/
bool acceptMsg(MsgType m, const std::string &lineId) {
// If more verbose than the current verbosity level
if ((m & MSG_TYPE_TYPE_BITS) > m_lv)
return false;
if ((m & MSG_TYPE_TYPE_BITS) > m_lv) return false;
// if print is allowed by current verbosity level
if (isStreamMsg(m))
return checkStreamPeriod(lineId);
if (isStreamMsg(m)) return checkStreamPeriod(lineId);
return true;
}
......@@ -287,6 +284,6 @@ protected:
bool checkStreamPeriod(const std::string &lineId);
};
} // namespace dynamicgraph
} // namespace dynamicgraph
#endif // #ifndef __sot_torque_control_logger_H__
#endif // #ifndef __sot_torque_control_logger_H__
......@@ -5,15 +5,15 @@
#ifndef DYNAMIC_GRAPH_POOL_H
#define DYNAMIC_GRAPH_POOL_H
#include <map>
#include <sstream>
#include <string>
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/fwd.hh>
#include <dynamic-graph/signal-base.h>
#include <dynamic-graph/fwd.hh>
#include <map>
#include <sstream>
#include <string>
namespace dynamicgraph {
/*! @ingroup dgraph
\brief Singleton that keeps track of all the entities.
......@@ -31,7 +31,7 @@ namespace dynamicgraph {
*/
class DYNAMIC_GRAPH_DLLAPI PoolStorage {
public:
public:
/*! \name Define types to simplify the writing
@{
*/
......@@ -98,7 +98,7 @@ public:
void writeGraph(const std::string &aFileName);
void writeCompletionList(std::ostream &os);
protected:
protected:
/*! \name Fields of the class to manage the three entities.
Also the name is singular, those are true sets.
@{
......@@ -106,13 +106,13 @@ protected:
/*! \brief Set of basic objects of the SoT */
Entities entityMap;
private:
private:
PoolStorage() {}
static PoolStorage *instance_;
};
inline PoolStorage &g_pool() { return *PoolStorage::getInstance(); }
} // end of namespace dynamicgraph.
} // end of namespace dynamicgraph.
#endif //! DYNAMIC_GRAPH_POOL_H
#endif //! DYNAMIC_GRAPH_POOL_H
......@@ -6,11 +6,11 @@
#ifndef DYNAMIC_GRAPH_PROCESS_LIST_H_
#define DYNAMIC_GRAPH_PROCESS_LIST_H_
#include <dynamic-graph/dynamic-graph-api.h>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/vector.hpp>
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/fwd.hh>
namespace dynamicgraph {
......@@ -18,14 +18,14 @@ namespace CPU {
class DYNAMIC_GRAPH_DLLAPI ProcessData {};
class DYNAMIC_GRAPH_DLLAPI ProcessList {
public:
public:
ProcessList();
};
/// This class gather information on a specific CPU.
///
class DYNAMIC_GRAPH_DLLAPI CPUData {
public:
public:
CPUData();
int cpu_id_;
......@@ -126,10 +126,10 @@ public:
/// This class gathers information on a computer.
/// This includes a list of CPU
class DYNAMIC_GRAPH_DLLAPI System {
private:
private:
bool init_;
public:
public:
System();
/// Read /proc/state file to extract CPU count.
......@@ -160,7 +160,7 @@ public:
ar &vCPUData_;
}
};
} // namespace CPU
} // namespace dynamicgraph
} // namespace CPU
} // namespace dynamicgraph
#endif /* DYNAMIC_GRAPH_PROCESS_LIST_H_ */
......@@ -4,13 +4,11 @@
#ifndef DYNAMIC_GRAPH_LOGGER_REAL_TIME_DEF_H
#define DYNAMIC_GRAPH_LOGGER_REAL_TIME_DEF_H
#include <sstream>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include <dynamic-graph/config.hh>
#include <sstream>
#include <vector>
namespace dynamicgraph {
/// \ingroup debug
......@@ -21,7 +19,7 @@ namespace dynamicgraph {
/// want.
/// \sa LoggerIOStream
class LoggerStream {
public:
public:
virtual void write(const char *c) = 0;
};
......@@ -30,12 +28,12 @@ public:
/// The easieast is to use the macro dgADD_OSTREAM_TO_RTLOG(ostr) where
/// `ostr` can be `std::cout` or an std::ofstream...
class LoggerIOStream : public LoggerStream {
public:
public:
LoggerIOStream(std::ostream &os) : os_(os) {}
virtual ~LoggerIOStream() {}
virtual void write(const char *c) { os_ << c; }
private:
private:
std::ostream &os_;
};
typedef boost::shared_ptr<LoggerStream> LoggerStreamPtr_t;
......@@ -48,17 +46,16 @@ class RealTimeLogger;
/// The entry starts when an instance is created and ends when is is deleted.
/// This class is only used by RealTimeLogger.
class RTLoggerStream {
public:
public:
inline RTLoggerStream(RealTimeLogger *logger, std::ostream &os)
: ok_(logger != NULL), logger_(logger), os_(os) {}
template <typename T> inline RTLoggerStream &operator<<(T t) {
if (ok_)
os_ << t;
template <typename T>
inline RTLoggerStream &operator<<(T t) {
if (ok_) os_ << t;
return *this;
}
inline RTLoggerStream &operator<<(std::ostream &(*pf)(std::ostream &)) {
if (ok_)
os_ << pf;
if (ok_) os_ << pf;
return *this;
}
......@@ -66,7 +63,7 @@ public:
inline bool isNull() { return !ok_; }
private:
private:
const bool ok_;
RealTimeLogger *logger_;
std::ostream &os_;
......@@ -97,7 +94,7 @@ private:
/// - one writer at a time. Writing to the logs is **never** a blocking
/// operation. If the resource is busy, the log entry is discarded.
class DYNAMIC_GRAPH_DLLAPI RealTimeLogger {
public:
public:
static RealTimeLogger &instance();
static void destroy();
......@@ -146,7 +143,7 @@ public:
~RealTimeLogger();
private:
private:
struct Data {
std::stringbuf buf;
};
......@@ -177,6 +174,6 @@ RTLoggerStream::~RTLoggerStream() {
}
}
} // end of namespace dynamicgraph
} // end of namespace dynamicgraph
#endif //! DYNAMIC_GRAPH_LOGGER_REAL_TIME_DEF_H
#endif //! DYNAMIC_GRAPH_LOGGER_REAL_TIME_DEF_H
......@@ -6,21 +6,21 @@
#define DYNAMIC_GRAPH_LOGGER_REAL_TIME_H
#ifdef ENABLE_RT_LOG
#define dgADD_OSTREAM_TO_RTLOG(ostr) \
::dynamicgraph::RealTimeLogger::instance().addOutputStream( \
::dynamicgraph::LoggerStreamPtr_t( \
#define dgADD_OSTREAM_TO_RTLOG(ostr) \
::dynamicgraph::RealTimeLogger::instance().addOutputStream( \
::dynamicgraph::LoggerStreamPtr_t( \
new ::dynamicgraph::LoggerIOStream(ostr)))
#define dgRTLOG() ::dynamicgraph::RealTimeLogger::instance().front()
#else // ENABLE_RT_LOG
#else // ENABLE_RT_LOG
#define dgADD_OSTREAM_TO_RTLOG(ostr) struct __end_with_semicolon
#define dgRTLOG() \
if (1) \
; \
else \
#define dgRTLOG() \
if (1) \
; \
else \
__null_stream()
#endif
#include <dynamic-graph/real-time-logger-def.h>
#endif //! DYNAMIC_GRAPH_LOGGER_REAL_TIME_H
#endif //! DYNAMIC_GRAPH_LOGGER_REAL_TIME_H