custom-entity.cpp
Go to the documentation of this file.
1 // Copyright 2010 Thomas Moulard.
2 //
3 
4 #include <dynamic-graph/entity.h>
7 #include <dynamic-graph/pool.h>
8 
9 #include <sstream>
10 
11 #define BOOST_TEST_MODULE customEntity
12 
13 #if BOOST_VERSION >= 105900
14 #include <boost/test/tools/output_test_stream.hpp>
15 #else
16 #include <boost/test/output_test_stream.hpp>
17 #endif
18 #include <boost/test/unit_test.hpp>
19 
20 using boost::test_tools::output_test_stream;
21 
23  static const std::string CLASS_NAME;
24 
25  virtual const std::string &getClassName() const { return CLASS_NAME; }
26 
27  explicit CustomEntity(const std::string &n) : Entity(n) {}
28 
29  virtual ~CustomEntity() {}
30 
31  void display(std::ostream &os) const { os << "custom entity"; }
32 };
33 
35 
36 BOOST_AUTO_TEST_CASE(constructor) {
37  BOOST_CHECK_EQUAL(CustomEntity::CLASS_NAME, "CustomEntity");
38 
39  dynamicgraph::Entity *entity =
41  "my-entity");
42  BOOST_CHECK_EQUAL(entity->getName(), "my-entity");
43  BOOST_CHECK_EQUAL(entity->Entity::getClassName(), "Entity");
44  BOOST_CHECK_EQUAL(entity->getClassName(), CustomEntity::CLASS_NAME);
45 
46  // CustomEntity entity2 ("");
47  // Deregister entities before destroying them
49 }
50 
52  dynamicgraph::Entity *entity =
54  "my-entity");
55 
56  output_test_stream output;
57 
58  entity->display(output);
59  BOOST_CHECK(output.is_equal("custom entity"));
60  // Deregister entities before destroying them
62 }
entity.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(constructor)
Definition: custom-entity.cpp:36
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CustomEntity, "CustomEntity")
dynamicgraph::Entity
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
Definition: include/dynamic-graph/entity.h:52
CustomEntity
Definition: custom-entity.cpp:22
dynamicgraph::Entity::getName
const std::string & getName() const
Definition: include/dynamic-graph/entity.h:60
CustomEntity::display
void display(std::ostream &os) const
Display information on the entity inside the output stream os.
Definition: custom-entity.cpp:31
CustomEntity::CustomEntity
CustomEntity(const std::string &n)
Definition: custom-entity.cpp:27
CustomEntity::CLASS_NAME
static const std::string CLASS_NAME
Definition: custom-entity.cpp:23
dynamicgraph::Entity::getClassName
virtual const std::string & getClassName() const
Definition: include/dynamic-graph/entity.h:61
dynamicgraph::Entity::display
virtual void display(std::ostream &os) const
Display information on the entity inside the output stream os.
Definition: src/dgraph/entity.cpp:170
dynamicgraph::Entity::Entity
Entity(const std::string &name)
Definition: src/dgraph/entity.cpp:33
CustomEntity::getClassName
virtual const std::string & getClassName() const
Definition: custom-entity.cpp:25
exception-factory.h
CustomEntity::~CustomEntity
virtual ~CustomEntity()
Definition: custom-entity.cpp:29
factory.h
dynamicgraph::PoolStorage::destroy
static void destroy()
Destroy the unique instance of the class.
Definition: src/dgraph/pool.cpp:38
dynamicgraph::FactoryStorage::newEntity
Entity * newEntity(const std::string &classname, const std::string &objname) const
Instantiate (and allocate) an entity.
Definition: src/dgraph/factory.cpp:79
pool.h
dynamicgraph::FactoryStorage::getInstance
static FactoryStorage * getInstance()
Get pointer to unique object of the class.
Definition: src/dgraph/factory.cpp:15


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Sun Oct 22 2023 02:27:08