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 }
CustomEntity(const std::string &n)
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
virtual ~CustomEntity()
virtual const std::string & getClassName() const
static const std::string CLASS_NAME
BOOST_AUTO_TEST_CASE(constructor)
void display(std::ostream &os) const
Display information on the entity inside the output stream os.
virtual const std::string & getClassName() const
virtual void display(std::ostream &os) const
Display information on the entity inside the output stream os.
static void destroy()
Destroy the unique instance of the class.
Entity(const std::string &name)
const std::string & getName() const
Entity * newEntity(const std::string &classname, const std::string &objname) const
Instantiate (and allocate) an entity.
static FactoryStorage * getInstance()
Get pointer to unique object of the class.
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CustomEntity, "CustomEntity")


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Sun Jun 25 2023 02:06:03