Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2010 Thomas Moulard.
//
// This file is part of dynamic-graph.
// dynamic-graph is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// dynamic-graph is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public License
// along with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
#include <sstream>
#include <dynamic-graph/entity.h>
#include <dynamic-graph/factory.h>
#include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/pool.h>
#define BOOST_TEST_MODULE pool
#include <boost/test/unit_test.hpp>
#include <boost/test/output_test_stream.hpp>
using boost::test_tools::output_test_stream;
struct MyEntity : public dynamicgraph::Entity
{
static const std::string CLASS_NAME;
MyEntity (const std::string& name)
: Entity (name)
{}
virtual void display (std::ostream& os) const
{
os << "Hello! My name is " << getName () << " !" << std::endl;
}
virtual const std::string& getClassName () const
{
return CLASS_NAME;
}
};
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (MyEntity, "MyEntity");
BOOST_AUTO_TEST_CASE (pool_display)
{
dynamicgraph::Entity* entity =
dynamicgraph::FactoryStorage::getInstance()->
newEntity("MyEntity", "MyEntityInst");
output_test_stream output;
dynamicgraph::Entity& e = dynamicgraph::PoolStorage::getInstance()->getEntity
("MyEntityInst");
e.display(output);
BOOST_CHECK (output.is_equal ("Hello! My name is MyEntityInst !\n"));
dynamicgraph::PoolStorage::getInstance()->deregisterEntity
(entity->getName());
dynamicgraph::PoolStorage::destroy();