Commit 05d4ac50 authored by Olivier Stasse's avatar Olivier Stasse Committed by olivier stasse
Browse files

[clang] Format clang

parent 240df675
/**
\page subp_debug_rt_logger Real-time Logger
It is intended to be used like this:
\code
#define ENABLE_RT_LOG
#include <dynamic-graph/real-time-logger.h>
// Somewhere in the main function of your executable
int main (int argc, char** argv) {
dgADD_OSTREAM_TO_RTLOG (std::cout);
}
// Somewhere in your library
dgRTLOG() << "your message. Prefer to use \n than std::endl."
\endcode
\note Thread safety. This class expects to have:
- only one reader: the one who take the log entries and write them somewhere.
- one writer at a time. Writing to the logs is **never** a blocking
operation. If the resource is busy, the log entry is discarded.
*/
......@@ -97,7 +97,7 @@ std::map<const std::string, Command *> aCommandMap =
std::string cmd_name = "4_args";
std::map<const std::string, Command *>::iterator it_map;
it_map = aCommandMap.find(cmd_name);
if (it_map == aCommandMap.end())
......@@ -107,7 +107,7 @@ std::vector<Value> values;
for (unsigned int i = 0; i < 4; i++)
values.push_back(aValue);
it_map->second->setParameterValues(values);
it_map->second->execute();
it_map->second->owner();
......
......@@ -10,11 +10,12 @@
either the entity method setLoggerVerbosityLevel()
or the corresponding python bindings.
\section real_time_logger_modifying_entities Putting information in your entity.
\section real_time_logger_modifying_entities Putting information in your
entity.
It is possible to define the periodicity of the logger:
\code
logger_.setTimeSample(0.001);
logger_.setTimeSample(0.001);
\endcode
To define the periodicity at which one wants to print information:
......@@ -36,23 +37,24 @@ level : ERROR</li>
</ul>
It is specified by the enum LoggerVerbosity
It is possible to display information according to various level of debug:
\code
sendMsg("This is a message of level MSG_TYPE_DEBUG", MSG_TYPE_DEBUG);
\endcode
or
\code
DYNAMIC_GRAPH_ENTITY_DEBUG (*this) << "This is a message of level MSG_TYPE_DEBUG\n";
DYNAMIC_GRAPH_ENTITY_INFO (*this) << "This is a message of level MSG_TYPE_INFO\n";
DYNAMIC_GRAPH_ENTITY_WARNING (*this) << "This is a message of level MSG_TYPE_WARNING\n";
DYNAMIC_GRAPH_ENTITY_ERROR (*this) << "This is a message of level MSG_TYPE_ERROR\n";
DYNAMIC_GRAPH_ENTITY_DEBUG_STREAM (*this) << "This is a message of level MSG_TYPE_DEBUG_STREAM\n";
DYNAMIC_GRAPH_ENTITY_INFO_STREAM (*this) << "This is a message of level MSG_TYPE_INFO_STREAM\n";
DYNAMIC_GRAPH_ENTITY_WARNING_STREAM (*this) << "This is a message of level MSG_TYPE_WARNING_STREAM\n";
DYNAMIC_GRAPH_ENTITY_ERROR_STREAM (*this) << "This is a message of level MSG_TYPE_ERROR_STREAM\n";
\endcode
DYNAMIC_GRAPH_ENTITY_DEBUG (*this) << "This is a message of level
MSG_TYPE_DEBUG\n"; DYNAMIC_GRAPH_ENTITY_INFO (*this) << "This is a message of
level MSG_TYPE_INFO\n"; DYNAMIC_GRAPH_ENTITY_WARNING (*this) << "This is a
message of level MSG_TYPE_WARNING\n"; DYNAMIC_GRAPH_ENTITY_ERROR (*this) <<
"This is a message of level MSG_TYPE_ERROR\n"; DYNAMIC_GRAPH_ENTITY_DEBUG_STREAM
(*this) << "This is a message of level MSG_TYPE_DEBUG_STREAM\n";
DYNAMIC_GRAPH_ENTITY_INFO_STREAM (*this) << "This is a message of level
MSG_TYPE_INFO_STREAM\n"; DYNAMIC_GRAPH_ENTITY_WARNING_STREAM (*this) << "This is
a message of level MSG_TYPE_WARNING_STREAM\n"; DYNAMIC_GRAPH_ENTITY_ERROR_STREAM
(*this) << "This is a message of level MSG_TYPE_ERROR_STREAM\n"; \endcode
\note Thread safety. This class expects to have:
- only one reader: the one who take the log entries and write them somewhere.
......
......@@ -80,9 +80,7 @@ template <class E, typename T> struct CommandVoid1 : public Command {
typedef boost::function<void(const T &)> function_t;
CommandVoid1(E &entity, function_t function, const std::string &docString)
: Command(entity,
boost::assign::list_of
(ValueHelper<T>::TypeID),
: Command(entity, boost::assign::list_of(ValueHelper<T>::TypeID),
docString),
fptr(function) {}
......@@ -107,12 +105,12 @@ makeCommandVoid1(E &entity, boost::function<void(const T &)> function,
}
template <class E, typename T>
CommandVoid1<E, T> *makeCommandVoid1(
E &entity,
// The following syntaxt don't compile when not specializing the template
// arg... why ???
boost::function<void(E *, const T &)> function,
const std::string &docString) {
CommandVoid1<E, T> *
makeCommandVoid1(E &entity,
// The following syntaxt don't compile when not specializing
// the template arg... why ???
boost::function<void(E *, const T &)> function,
const std::string &docString) {
return new CommandVoid1<E, T>(entity, boost::bind(function, &entity, _1),
docString);
}
......@@ -144,9 +142,8 @@ struct CommandVoid2 : public Command {
CommandVoid2(E &entity, function_t function, const std::string &docString)
: Command(entity,
boost::assign::list_of
(ValueHelper<T1>::TypeID)
(ValueHelper<T2>::TypeID),
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID),
docString),
fptr(function) {}
......@@ -172,12 +169,12 @@ makeCommandVoid2(E &entity,
}
template <class E, typename T1, typename T2>
CommandVoid2<E, T1, T2> *makeCommandVoid2(
E &entity,
// The following syntaxt don't compile when not specializing the template
// arg... why ???
boost::function<void(E *, const T1 &, const T2 &)> function,
const std::string &docString) {
CommandVoid2<E, T1, T2> *
makeCommandVoid2(E &entity,
// The following syntaxt don't compile when not specializing
// the template arg... why ???
boost::function<void(E *, const T1 &, const T2 &)> function,
const std::string &docString) {
return new CommandVoid2<E, T1, T2>(
entity, boost::bind(function, &entity, _1, _2), docString);
}
......@@ -211,10 +208,8 @@ struct CommandVoid3 : public Command {
CommandVoid3(E &entity, function_t function, const std::string &docString)
: Command(entity,
boost::assign::list_of
(ValueHelper<T1>::TypeID)
(ValueHelper<T2>::TypeID)
(ValueHelper<T3>::TypeID),
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID),
docString),
fptr(function) {}
......@@ -286,11 +281,9 @@ struct CommandVoid4 : public Command {
CommandVoid4(E &entity, function_t function, const std::string &docString)
: Command(entity,
boost::assign::list_of
(ValueHelper<T1>::TypeID)
(ValueHelper<T2>::TypeID)
(ValueHelper<T3>::TypeID)
(ValueHelper<T4>::TypeID),
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
ValueHelper<T4>::TypeID),
docString),
fptr(function) {}
......@@ -382,14 +375,11 @@ makeCommandVerbose(E &entity, typename CommandVerbose<E>::function_t function,
return NULL;
}
template <class E>
CommandVerbose<E> *
makeCommandVerbose(E &entity,
void (E::*function)(std::ostream &),
const std::string &docString) {
return new CommandVerbose<E>(entity,
boost::bind(function, &entity,_1),
CommandVerbose<E> *makeCommandVerbose(E &entity,
void (E::*function)(std::ostream &),
const std::string &docString) {
return new CommandVerbose<E>(entity, boost::bind(function, &entity, _1),
docString);
return NULL;
}
......@@ -462,9 +452,7 @@ struct CommandReturnType1 : public Command {
CommandReturnType1(E &entity, function_t function,
const std::string &docString)
: Command(entity,
boost::assign::list_of
(ValueHelper<T>::TypeID),
: Command(entity, boost::assign::list_of(ValueHelper<T>::TypeID),
docString),
fptr(function) {}
......@@ -489,12 +477,12 @@ makeCommandReturnType1(E &entity,
}
template <class E, typename ReturnType, typename T>
CommandReturnType1<E, ReturnType, T> *makeCommandReturnType1(
E &entity,
// The following syntaxt don't compile when not specializing the template
// arg... why ???
boost::function<ReturnType(E *, const T &)> function,
const std::string &docString) {
CommandReturnType1<E, ReturnType, T> *
makeCommandReturnType1(E &entity,
// The following syntaxt don't compile when not
// specializing the template arg... why ???
boost::function<ReturnType(E *, const T &)> function,
const std::string &docString) {
return new CommandReturnType1<E, ReturnType, T>(
entity, boost::bind(function, &entity, _1), docString);
}
......@@ -529,9 +517,8 @@ struct CommandReturnType2 : public Command {
CommandReturnType2(E &entity, function_t function,
const std::string &docString)
: Command(entity,
boost::assign::list_of
(ValueHelper<T1>::TypeID)
(ValueHelper<T2>::TypeID),
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID),
docString),
fptr(function) {}
......@@ -589,5 +576,4 @@ inline std::string docCommandReturnType2(const std::string &doc,
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_bind_h__
......@@ -39,7 +39,8 @@ private:
};
/** \ingroup dgraph
\brief This class implements a variant design pattern to handle basic types in Command.
\brief This class implements a variant design pattern to handle basic types
in Command.
*/
class DYNAMIC_GRAPH_DLLAPI Value {
......
......@@ -127,7 +127,8 @@ void TracerRealTime::openFile(const SignalBase<int> &sig,
std::ofstream *newfile = new std::ofstream(filename.c_str());
if (!newfile->good()) {
delete newfile;
DG_THROW ExceptionTraces(ExceptionTraces::NOT_OPEN,
DG_THROW ExceptionTraces(
ExceptionTraces::NOT_OPEN,
"Could not open file " + filename + " for signal " + signame, "");
}
dgDEBUG(5) << "Newfile:" << (void *)newfile << endl;
......
......@@ -37,7 +37,7 @@ public:
bool test_four_args_;
bool test_one_arg_ret_;
bool test_two_args_ret_;
virtual const std::string &getClassName() const { return CLASS_NAME; }
explicit CustomEntity(const std::string &n) : Entity(n) {
test_zero_arg_ = false;
......@@ -47,7 +47,7 @@ public:
test_four_args_ = false;
test_one_arg_ret_ = false;
test_two_args_ret_ = false;
addCommand("0_arg", makeCommandVoid0(*this, &CustomEntity::zero_arg,
docCommandVoid0("zero arg")));
......@@ -68,20 +68,17 @@ public:
docCommandVoid4("four args", "int", "int", "int", "int")));
addCommand("1_arg_r",
makeCommandReturnType1(
*this, &CustomEntity::one_arg_ret,
docCommandVoid1("one arg", "int")));
makeCommandReturnType1(*this, &CustomEntity::one_arg_ret,
docCommandVoid1("one arg", "int")));
addCommand("2_args_r",
makeCommandReturnType2(
*this, &CustomEntity::two_args_ret,
docCommandVoid2("two args", "int","int")));
addCommand("2_args_r", makeCommandReturnType2(
*this, &CustomEntity::two_args_ret,
docCommandVoid2("two args", "int", "int")));
addCommand("cmd_verbose",
makeCommandVerbose(
*this,&CustomEntity::cmd_verbose,
docCommandVerbose("Display some information")));
addCommand(
"cmd_verbose",
makeCommandVerbose(*this, &CustomEntity::cmd_verbose,
docCommandVerbose("Display some information")));
/// Generating an exception by adding a command which already exist
bool res = false;
......@@ -110,13 +107,18 @@ public:
test_four_args_ = true;
}
int one_arg_ret(const int &) { test_one_arg_ret_ = true; return 2;}
int one_arg_ret(const int &) {
test_one_arg_ret_ = true;
return 2;
}
std::string two_args_ret(const int &, const int &)
{ test_two_args_ret_ = true; return std::string("return");}
std::string two_args_ret(const int &, const int &) {
test_two_args_ret_ = true;
return std::string("return");
}
void cmd_verbose(std::ostream &oss)
{ std::string as("print verbose");
void cmd_verbose(std::ostream &oss) {
std::string as("print verbose");
oss << as;
}
};
......@@ -171,17 +173,16 @@ BOOST_AUTO_TEST_CASE(command_test) {
vec_fname.push_back(std::string("1_arg_r"));
vec_fname.push_back(std::string("2_args_r"));
values.clear();
for (unsigned int i = 0; i < 2; i++) {
it_map = aCommandMap.find(vec_fname[i]);
if (it_map == aCommandMap.end())
{
if (it_map == aCommandMap.end()) {
BOOST_CHECK(false);
exit(-1);
}
values.push_back(aValue);
it_map->second->setParameterValues(values);
Value aValue =it_map->second->execute();
Value aValue = it_map->second->execute();
it_map->second->owner();
it_map->second->getDocstring();
}
......
......@@ -65,11 +65,12 @@ BOOST_AUTO_TEST_CASE(test_tracer) {
std::string basename("my-tracer");
std::string suffix(".dat");
atracer.setBufferSize(1<<14);
atracer.setBufferSize(1 << 14);
// Check that an exception is thrown if the filename is invalid.
atracer.openFiles(rootdir, "invalid/filename", suffix);
BOOST_CHECK_THROW(atracer.addSignalToTraceByName("my-entity.out_double", "output"),
BOOST_CHECK_THROW(
atracer.addSignalToTraceByName("my-entity.out_double", "output"),
ExceptionTraces);
// Test openfiles
......
......@@ -306,9 +306,7 @@ BOOST_AUTO_TEST_CASE(set_signal_string) {
std::istringstream value(os.str());
try {
s.set(value);
}
catch(const std::exception& exc)
{
} catch (const std::exception &exc) {
std::cout << exc.what() << std::endl;
BOOST_CHECK(!"Tentative to set signal to empty string");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment