Skip to content
Snippets Groups Projects
Commit 8c879124 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

Merge branch 'devel' of github.com:stack-of-tasks/dynamic-graph into devel

parents 2c2196de b3ce2e4a
No related branches found
No related tags found
No related merge requests found
...@@ -36,11 +36,11 @@ It is providing a step-by-step way of building an entity ...@@ -36,11 +36,11 @@ It is providing a step-by-step way of building an entity
\section sec_htw_helpers Helpers \section sec_htw_helpers Helpers
When writing entities you might use some macros which are very useful to write your class. When writing entities you might use some macros which are very useful to write your class.
They are given also in the <a href="http://projects.laas.fr/gepetto/doc/stack-of-tasks/sot-core/master/doxygen-html">sot-core</a> package as well.
\subsection subsec_howto_typedef Entity helpers \subsection subsec_howto_typedef Entity helpers
The header <b>entity-helper.h</b> is defining a type called EntityClassName The header <b>entity-helper.h</b> is defining a type called EntityClassName
\section sec_howto_macros_helpers Macro helpers \section sec_howto_macros_helpers Macro helpers
\subsection subsec_howto_macros_helpers Preprocessing macros for signals \subsection subsec_howto_macros_helpers Preprocessing macros for signals
...@@ -95,17 +95,27 @@ The header <b>entity-helper.h</b> is defining a type called EntityClassName ...@@ -95,17 +95,27 @@ The header <b>entity-helper.h</b> is defining a type called EntityClassName
</ul> </ul>
<li> <li>
</li> </li> Inner signals
<ul>
<li> <b> DECLARE_SIGNAL_INNER(signal_name,type)</b> <li> <b> DECLARE_SIGNAL_INNER(signal_name,type)</b>
Inner signal are signal that depend on a state of the entity and not on input signals. Inner signal are signal that depend on a state of the entity and not on input signals.
This macro declares an inner signal with the following pattern: This macro declares an inner signal with the following pattern:
\code \code
m_signal_nameSINNER m_signal_nameSINNER
\endcode \endcode
</li> It also creates a member function with the following pattern:
<li> <b>DEFINE_SIGNAL_INNER_FUNCTION</b> \code
This macro type & EntityClassName::nameSINNER_function(signal_name)(type &, int)
</li> \endcode
</li>
<li> <b>DEFINE_SIGNAL_INNER_FUNCTION(signal_name,type)</b>
This macro is used to implement the method related to signal_name. More precisely
it provides the header of the member function(i.e. method) declaration.
</li>
<li><b>DECLARE_SIGNAL_INNER_FUNCTION(signal_name,type)</b>
This macros declares the member function used to handle the access to this signal.
</li>
</ul>
</ul> </ul>
*/ */
/* Copyright 2019, LAAS-CNRS
*
* Olivier Stasse
*
* See LICENSE file
*
*/
#include <sstream>
#include <iostream>
#include <dynamic-graph/entity.h>
#include <dynamic-graph/exception-factory.h>
#include "dynamic-graph/factory.h"
#include "dynamic-graph/pool.h"
#define ENABLE_RT_LOG
#include <dynamic-graph/real-time-logger.h>
#include <dynamic-graph/logger.h>
#define BOOST_TEST_MODULE debug-logger
#include <boost/test/unit_test.hpp>
#include <boost/test/output_test_stream.hpp>
using boost::test_tools::output_test_stream;
namespace dynamicgraph
{
class CustomEntity : public Entity
{
public:
static const std::string CLASS_NAME;
virtual const std::string& getClassName () const
{
return CLASS_NAME;
}
CustomEntity (const std::string n)
: Entity (n)
{
logger_.setTimeSample(0.001);
logger_.setStreamPrintPeriod(0.005);
logger_.setVerbosity(VERBOSITY_ALL);
LoggerVerbosity alv = logger_.getVerbosity();
BOOST_CHECK(alv==VERBOSITY_ALL);
}
~CustomEntity()
{
}
void testDebugTrace()
{
sendMsg("This is a message of level MSG_TYPE_DEBUG",MSG_TYPE_DEBUG);
sendMsg("This is a message of level MSG_TYPE_INFO",MSG_TYPE_INFO);
sendMsg("This is a message of level MSG_TYPE_WARNING",MSG_TYPE_WARNING);
sendMsg("This is a message of level MSG_TYPE_ERROR",MSG_TYPE_ERROR);
sendMsg("This is a message of level MSG_TYPE_DEBUG_STREAM",MSG_TYPE_DEBUG_STREAM);
sendMsg("This is a message of level MSG_TYPE_INFO_STREAM",MSG_TYPE_INFO_STREAM);
sendMsg("This is a message of level MSG_TYPE_WARNING_STREAM",MSG_TYPE_WARNING_STREAM);
sendMsg("This is a message of level MSG_TYPE_ERROR_STREAM",MSG_TYPE_ERROR_STREAM);
logger_.countdown();
}
};
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (CustomEntity,"CustomEntity");
}
BOOST_AUTO_TEST_CASE(debug_logger_wrong_initialization)
{
std::ofstream of;
dynamicgraph::RealTimeLogger::instance();
//of.open("/tmp/dg-LOGS.txt",std::ofstream::out|std::ofstream::app);
// dgADD_OSTREAM_TO_RTLOG (of);
BOOST_CHECK_EQUAL (dynamicgraph::CustomEntity::CLASS_NAME, "CustomEntity");
dynamicgraph::CustomEntity& entity = *(dynamic_cast<dynamicgraph::CustomEntity *>(
dynamicgraph::FactoryStorage::getInstance()->newEntity("CustomEntity",
"my-entity-2")));
for(unsigned int i=0;i<10000;i++)
{
entity.testDebugTrace();
}
dynamicgraph::RealTimeLogger::destroy();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment