Skip to content

Commit 8c87912

Browse files
committed
Merge branch 'devel' of github.com:stack-of-tasks/dynamic-graph into devel
2 parents 2c2196d + b3ce2e4 commit 8c87912

File tree

2 files changed

+105
-6
lines changed

2 files changed

+105
-6
lines changed

doc/additionalDoc/extension.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ It is providing a step-by-step way of building an entity
3636
\section sec_htw_helpers Helpers
3737
3838
When writing entities you might use some macros which are very useful to write your class.
39-
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.
4039
4140
\subsection subsec_howto_typedef Entity helpers
4241
4342
The header <b>entity-helper.h</b> is defining a type called EntityClassName
43+
4444
\section sec_howto_macros_helpers Macro helpers
4545
4646
\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
9595
9696
</ul>
9797
<li>
98-
</li>
98+
</li> Inner signals
99+
<ul>
99100
<li> <b> DECLARE_SIGNAL_INNER(signal_name,type)</b>
100101
Inner signal are signal that depend on a state of the entity and not on input signals.
101102
This macro declares an inner signal with the following pattern:
102103
\code
103104
m_signal_nameSINNER
104105
\endcode
105-
</li>
106-
<li> <b>DEFINE_SIGNAL_INNER_FUNCTION</b>
107-
This macro
108-
</li>
106+
It also creates a member function with the following pattern:
107+
\code
108+
type & EntityClassName::nameSINNER_function(signal_name)(type &, int)
109+
\endcode
110+
</li>
111+
<li> <b>DEFINE_SIGNAL_INNER_FUNCTION(signal_name,type)</b>
112+
This macro is used to implement the method related to signal_name. More precisely
113+
it provides the header of the member function(i.e. method) declaration.
114+
</li>
115+
<li><b>DECLARE_SIGNAL_INNER_FUNCTION(signal_name,type)</b>
116+
This macros declares the member function used to handle the access to this signal.
117+
</li>
118+
</ul>
109119
</ul>
110120
111121
*/

tests/debug-logger-winit.cpp

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/* Copyright 2019, LAAS-CNRS
2+
*
3+
* Olivier Stasse
4+
*
5+
* See LICENSE file
6+
*
7+
*/
8+
#include <sstream>
9+
#include <iostream>
10+
#include <dynamic-graph/entity.h>
11+
#include <dynamic-graph/exception-factory.h>
12+
#include "dynamic-graph/factory.h"
13+
#include "dynamic-graph/pool.h"
14+
15+
#define ENABLE_RT_LOG
16+
#include <dynamic-graph/real-time-logger.h>
17+
#include <dynamic-graph/logger.h>
18+
19+
#define BOOST_TEST_MODULE debug-logger
20+
21+
#include <boost/test/unit_test.hpp>
22+
#include <boost/test/output_test_stream.hpp>
23+
24+
using boost::test_tools::output_test_stream;
25+
26+
27+
namespace dynamicgraph
28+
{
29+
class CustomEntity : public Entity
30+
{
31+
public:
32+
static const std::string CLASS_NAME;
33+
virtual const std::string& getClassName () const
34+
{
35+
return CLASS_NAME;
36+
}
37+
CustomEntity (const std::string n)
38+
: Entity (n)
39+
{
40+
logger_.setTimeSample(0.001);
41+
logger_.setStreamPrintPeriod(0.005);
42+
logger_.setVerbosity(VERBOSITY_ALL);
43+
LoggerVerbosity alv = logger_.getVerbosity();
44+
BOOST_CHECK(alv==VERBOSITY_ALL);
45+
}
46+
47+
~CustomEntity()
48+
{
49+
}
50+
void testDebugTrace()
51+
{
52+
sendMsg("This is a message of level MSG_TYPE_DEBUG",MSG_TYPE_DEBUG);
53+
sendMsg("This is a message of level MSG_TYPE_INFO",MSG_TYPE_INFO);
54+
sendMsg("This is a message of level MSG_TYPE_WARNING",MSG_TYPE_WARNING);
55+
sendMsg("This is a message of level MSG_TYPE_ERROR",MSG_TYPE_ERROR);
56+
sendMsg("This is a message of level MSG_TYPE_DEBUG_STREAM",MSG_TYPE_DEBUG_STREAM);
57+
sendMsg("This is a message of level MSG_TYPE_INFO_STREAM",MSG_TYPE_INFO_STREAM);
58+
sendMsg("This is a message of level MSG_TYPE_WARNING_STREAM",MSG_TYPE_WARNING_STREAM);
59+
sendMsg("This is a message of level MSG_TYPE_ERROR_STREAM",MSG_TYPE_ERROR_STREAM);
60+
61+
logger_.countdown();
62+
63+
}
64+
};
65+
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (CustomEntity,"CustomEntity");
66+
}
67+
68+
BOOST_AUTO_TEST_CASE(debug_logger_wrong_initialization)
69+
{
70+
std::ofstream of;
71+
dynamicgraph::RealTimeLogger::instance();
72+
//of.open("/tmp/dg-LOGS.txt",std::ofstream::out|std::ofstream::app);
73+
// dgADD_OSTREAM_TO_RTLOG (of);
74+
75+
BOOST_CHECK_EQUAL (dynamicgraph::CustomEntity::CLASS_NAME, "CustomEntity");
76+
77+
dynamicgraph::CustomEntity& entity = *(dynamic_cast<dynamicgraph::CustomEntity *>(
78+
dynamicgraph::FactoryStorage::getInstance()->newEntity("CustomEntity",
79+
"my-entity-2")));
80+
81+
for(unsigned int i=0;i<10000;i++)
82+
{
83+
entity.testDebugTrace();
84+
}
85+
86+
dynamicgraph::RealTimeLogger::destroy();
87+
}
88+
89+

0 commit comments

Comments
 (0)