21 #define BOOST_TEST_MODULE entity 23 #if BOOST_VERSION >= 105900 24 #include <boost/test/tools/output_test_stream.hpp> 26 #include <boost/test/output_test_stream.hpp> 28 #include <boost/test/unit_test.hpp> 30 using boost::test_tools::output_test_stream;
42 m_sigdSIN(NULL,
"CustomEntity(" +
name +
")::input(double)::in_double"),
44 "CustomEntity(" +
name +
")::input(double)::in_double"),
47 "CustomEntity(" +
name +
")::input(double)::out_double"),
58 BOOST_CHECK_EQUAL(aef.
getCode(),
68 double &
update(
double &res,
const int &inTime) {
69 const double &aDouble =
m_sigdSIN(inTime);
87 "CustomEntity",
"my-entity");
88 BOOST_CHECK_EQUAL(entity.
getName(),
"my-entity");
94 dgc::DirectGetter<dg::CustomEntity, double> a_direct_getter(
95 entity2, &entity2.m_value,
98 dgc::DirectSetter<dg::CustomEntity, double> a_direct_setter(
99 entity2, &entity2.m_value,
102 dgc::Value aValue(2.0);
103 std::vector<dgc::Value> values;
104 values.push_back(aValue);
105 a_direct_setter.setParameterValues(values);
106 a_direct_setter.execute();
107 a_direct_getter.execute();
109 output_test_stream output;
110 output << entity2.m_value;
123 BOOST_ERROR(
"Should never happen.");
125 BOOST_CHECK_EQUAL(exception.
getCode(),
133 BOOST_ERROR(
"Should never happen.");
135 BOOST_CHECK_EQUAL(exception.
getCode(),
143 std::string signame(
"CustomEntity(my-entity)::input(double)::in_double");
144 customEntity->Entity::hasSignal(signame);
145 output_test_stream output;
146 customEntity->Entity::displaySignalList(output);
148 output << customEntity;
152 customEntity->rmValidSignal();
153 BOOST_ERROR(
"Should never happen.");
155 BOOST_CHECK_EQUAL(exception.
getCode(),
164 output_test_stream output;
167 BOOST_CHECK(output.is_equal(
"--- <my-entity> signal list: \n"));
174 output_test_stream output;
177 BOOST_CHECK(output.is_equal(
"CustomEntity: my-entity"));
184 BOOST_CHECK_EQUAL(entity.
getCommandList(),
"print\nsignals\nsignalDep");
191 output_test_stream output;
194 BOOST_CHECK(output.is_equal(
""));
201 output_test_stream output;
204 BOOST_CHECK(output.is_equal(
"print\nsignals\nsignalDep\n"));
209 of.open(
"/tmp/dg-LOGS.txt", std::ofstream::out | std::ofstream::app);
215 output_test_stream output;
217 for (
unsigned int i = 0; i < 4; i++) {
218 for (
unsigned int j = 0; j < 2000; j++) {
223 output <<
"Mismatch output";
225 #define __FILELINE__ __FILE__ BOOST_PP_STRINGIZE(__LINE__) 234 <<
" WARNING" <<
'\n';
242 BOOST_CHECK(output.is_equal(
""));
251 BOOST_CHECK_EQUAL(entity.
test(),
BOOST_AUTO_TEST_CASE(constructor)
std::string docDirectGetter(const std::string &name, const std::string &type)
const std::string & getCommandList() const
std::ostream & displaySignalList(std::ostream &os) const
Display the list of signals of this entity in output stream os.
virtual std::string getDocString() const
Returns the Entity documentation.
virtual void test2(SignalBase< int > *)
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
#define dgADD_OSTREAM_TO_RTLOG(ostr)
void sendMsg(const std::string &msg, MsgType t=MSG_TYPE_INFO, const std::string &lineId="")
Send messages msg with level t. Add string file and line to message.
void signalRegistration(const SignalArray< int > &signals)
SignalMap getSignalMap() const
Provides a map of all the signals.
virtual std::ostream & writeGraph(std::ostream &os) const
This method is used to write down in os the edges of the graph by calling the signals writeGraph meth...
std::map< std::string, SignalBase< int > * > SignalMap
virtual SignalBase< int > * test()
static const std::string CLASS_NAME
dynamicgraph::SignalPtr< double, int > m_sigdSIN
virtual const std::string & getClassName() const
virtual const std::string & getClassName() const
virtual std::ostream & writeCompletionList(std::ostream &os) const
This method is used write in the output stream os the signals names and the commands of the entity...
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.
double & update(double &res, const int &inTime)
CustomEntity(const std::string &n)
void setLoggerVerbosityLevel(LoggerVerbosity lv)
Specify the verbosity level of the logger.
Entity(const std::string &name)
dynamicgraph::SignalTimeDependent< double, int > m_sigdTimeDepSOUT
LoggerVerbosity getLoggerVerbosityLevel()
Get the logger's verbosity level.
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")
SignalBase< int > & getSignal(const std::string &signalName)
Provides a reference to the signal named signalName.
void signalDeregistration(const std::string &name)
std::string docDirectSetter(const std::string &name, const std::string &type)
dynamicgraph::SignalPtr< double, int > m_sigdSIN2
void entityDeregistration()