14 #define BOOST_TEST_MODULE pool 16 #if BOOST_VERSION >= 105900 17 #include <boost/test/tools/output_test_stream.hpp> 19 #include <boost/test/output_test_stream.hpp> 21 #include <boost/test/unit_test.hpp> 23 using boost::test_tools::output_test_stream;
33 m_sigdSIN(NULL,
"MyEntity(" + name +
")::input(double)::in_double"),
36 "MyEntity(" + name +
")::input(double)::out_double") {
40 virtual void display(std::ostream &os)
const {
41 os <<
"Hello! My name is " <<
getName() <<
" !" << std::endl;
46 double &
update(
double &res,
const int &inTime) {
47 const double &aDouble =
m_sigdSIN(inTime);
65 "MyEntity",
"MyEntityInst");
67 bool res2 = (entity2 == entity);
84 output_test_stream output;
87 BOOST_CHECK(output.is_equal(
"Hello! My name is MyEntityInst !\n"));
102 bool testExistence = anEntityMap.find(
"MyEntityInst") == anEntityMap.end();
103 BOOST_CHECK(!testExistence);
109 BOOST_CHECK(testExistence);
114 output.is_equal(
"MyEntityInst.in_double\nMyEntityInst.out_double\n" 115 "print\nsignals\nsignalDep\n"));
119 std::fstream the_debug_file;
120 the_debug_file.open(
"output.dot");
121 std::ostringstream oss_output_wgph;
122 oss_output_wgph << the_debug_file.rdbuf();
123 the_debug_file.close();
126 std::string str_to_test =
127 "/* This graph has been automatically generated.\n" 128 " 2019 Month: 2 Day: 28 Time: 11:28 */\n" 129 "digraph \"output\" { \t graph [ label=\"output\" " 130 "bgcolor = white rankdir=LR ]\n" 131 "\t node [ fontcolor = black, color = black,fillcolor = gold1," 132 " style=filled, shape=box ] ; \n" 133 "\tsubgraph cluster_Entities { \n" 135 "\"MyEntityInst\" [ label = \"MyEntityInst\" ,\n" 136 " fontcolor = black, color = black, fillcolor=cyan, style=filled," 141 std::string s_output_wgph = oss_output_wgph.str();
142 std::string s_crmk =
"*/";
144 std::size_t find_s_output_wgph = s_output_wgph.find(s_crmk);
145 std::string sub_s_output_wgph =
146 s_output_wgph.substr(find_s_output_wgph, s_output_wgph.length());
147 std::size_t find_str_to_test = str_to_test.find(s_crmk);
148 std::string sub_str_to_test =
149 str_to_test.substr(find_str_to_test, str_to_test.length());
151 bool two_sub_string_identical;
152 two_sub_string_identical = sub_str_to_test == sub_s_output_wgph;
153 std::cout << sub_str_to_test << std::endl;
154 std::cout << sub_s_output_wgph << std::endl;
155 std::cout << sub_str_to_test.compare(sub_s_output_wgph) << std::endl;
156 BOOST_CHECK(two_sub_string_identical);
159 std::istringstream an_iss(
"MyEntityInst.in_double");
164 std::string aSignalName = aSignal.
getName();
166 aSignalName ==
"MyEntity(MyEntityInst)::input(double)::in_double";
167 BOOST_CHECK(testExistence);
170 an_iss.str(
"MyEntityInst.in2double");
186 BOOST_CHECK(!testExistence);
189 std::string name_entity(
"MyEntityInst2");
void deregisterEntity(const std::string &entname)
Unregister an entity.
virtual void display(std::ostream &os) const
Display information on the entity inside the output stream os.
void writeGraph(const std::string &aFileName)
This method write a graph description on the file named FileName.
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
dynamicgraph::SignalTimeDependent< double, int > m_sigdTimeDepSOUT
void signalRegistration(const SignalArray< int > &signals)
double & update(double &res, const int &inTime)
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(MyEntity, "MyEntity")
void deregisterEntity(const std::string &entname)
Delete an entity from the factory.
MyEntity(const std::string &name)
dynamicgraph::SignalPtr< double, int > m_sigdSIN
void writeCompletionList(std::ostream &os)
const std::string & getName() const
bool existEntity(const std::string &name)
Test if the entity exists.
int getCode() const
Access to the error code.
Entity & getEntity(const std::string &name)
Get an entity.
virtual void display(std::ostream &os) const
Display information on the entity inside the output stream os.
static PoolStorage * getInstance()
Get unique instance of the class.
static void destroy()
Destroy the unique instance of the class.
Entity(const std::string &name)
virtual const std::string & getClassName() const
const std::string & getName() const
std::map< std::string, Entity * > Entities
Sorted set of entities with unique key (name).
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.
const Entities & getEntityMap() const
Const access to entity map.
static const std::string CLASS_NAME
BOOST_AUTO_TEST_CASE(pool_display)
SignalBase< int > & getSignal(std::istringstream &sigpath)
Get a signal by name.
void clearPlugin(const std::string &name)
Disallocate an entity.