Skip to content
Snippets Groups Projects
Commit 34801f48 authored by Thomas Moulard's avatar Thomas Moulard
Browse files

Add helper macro for entity declaration. Use it when possible.

parent 9de21fbb
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,31 @@
# include <dynamic-graph/signal-array.h>
# include <dynamic-graph/signal-base.h>
/// \brief Helper macro for entity declaration.
///
/// This macro should be called in the declaration of all entities.
/// Example:
/// <code>
/// class A : public dynamicgraph::entity
/// {
/// DYNAMIC_GRAPH_ENTITY_DECL();
///
/// public:
// // your class here
/// };
/// </code>
///
/// 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; \
} \
static const std::string CLASS_NAME
namespace dynamicgraph
{
/// \ingroup dgraph
......@@ -46,12 +71,11 @@ namespace dynamicgraph
/// customize the command-line by overriding commandLine ().
class DYNAMIC_GRAPH_DLLAPI Entity : private boost::noncopyable
{
DYNAMIC_GRAPH_ENTITY_DECL ();
public:
typedef std::map< std::string,SignalBase<int>* > SignalMap;
typedef std::map<const std::string, command::Command*> CommandMap_t;
static const std::string CLASS_NAME;
explicit Entity (const std::string& name);
virtual ~Entity ();
......@@ -60,11 +84,6 @@ namespace dynamicgraph
return name;
}
virtual const std::string& getClassName () const
{
return CLASS_NAME;
}
SignalBase<int>& getSignal (const std::string& signalName);
const SignalBase<int>& getSignal (const std::string& signalName) const;
std::ostream& displaySignalList(std::ostream& os) const;
......
......@@ -52,13 +52,8 @@ namespace dynamicgraph
/// \brief Main class of the tracer real-time plug-in.
class DG_TRACERREALTIME_DLLAPI TracerRealTime : public Tracer
{
DYNAMIC_GRAPH_ENTITY_DECL ();
public:
static const std::string CLASS_NAME;
virtual const std::string& getClassName () const
{
return CLASS_NAME;
}
TracerRealTime (const std::string n);
virtual ~TracerRealTime ()
{}
......
......@@ -36,18 +36,10 @@ namespace dynamicgraph
/// \brief Tracer plug-in main class.
class DG_TRACER_DLLAPI Tracer : public Entity
{
DYNAMIC_GRAPH_ENTITY_DECL ();
protected:
typedef std::list< const SignalBase<int>* > SignalList;
SignalList toTraceSignals;
public:
static const std::string CLASS_NAME;
virtual const std::string& getClassName () const
{
return CLASS_NAME;
}
public:
enum TraceStyle
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment