Commit 70864112 authored by Olivier Stasse's avatar Olivier Stasse

clang format.

parent f9edb95c
Pipeline #8203 passed with stage
in 8 minutes and 16 seconds
......@@ -9,7 +9,6 @@
#include "dynamic-graph/command-setter.h"
#include "dynamic-graph/linear-algebra.h"
#include "dynamic-graph/command-setter.h"
#include <boost/assign/list_of.hpp>
#include <sstream>
......
......@@ -27,17 +27,17 @@ namespace dynamicgraph {
/** Enum representing the different kind of messages.
*/
enum MsgType {
MSG_TYPE_TYPE_BITS = 1<<0 | 1<<1 | 1<<2 | 1<<3, // 15
MSG_TYPE_STREAM_BIT = 1<<4, // 16
MSG_TYPE_DEBUG = 1<<3, // 1
MSG_TYPE_INFO = 1<<2, // 2
MSG_TYPE_WARNING = 1<<1, // 4
MSG_TYPE_ERROR = 1<<0, // 8
MSG_TYPE_DEBUG_STREAM = MSG_TYPE_DEBUG | MSG_TYPE_STREAM_BIT, // 17
MSG_TYPE_INFO_STREAM = MSG_TYPE_INFO | MSG_TYPE_STREAM_BIT, // 18
MSG_TYPE_WARNING_STREAM = MSG_TYPE_WARNING | MSG_TYPE_STREAM_BIT, // 20
MSG_TYPE_ERROR_STREAM = MSG_TYPE_ERROR | MSG_TYPE_STREAM_BIT // 24
MSG_TYPE_TYPE_BITS = 1 << 0 | 1 << 1 | 1 << 2 | 1 << 3, // 15
MSG_TYPE_STREAM_BIT = 1 << 4, // 16
MSG_TYPE_DEBUG = 1 << 3, // 1
MSG_TYPE_INFO = 1 << 2, // 2
MSG_TYPE_WARNING = 1 << 1, // 4
MSG_TYPE_ERROR = 1 << 0, // 8
MSG_TYPE_DEBUG_STREAM = MSG_TYPE_DEBUG | MSG_TYPE_STREAM_BIT, // 17
MSG_TYPE_INFO_STREAM = MSG_TYPE_INFO | MSG_TYPE_STREAM_BIT, // 18
MSG_TYPE_WARNING_STREAM = MSG_TYPE_WARNING | MSG_TYPE_STREAM_BIT, // 20
MSG_TYPE_ERROR_STREAM = MSG_TYPE_ERROR | MSG_TYPE_STREAM_BIT // 24
};
} // namespace dynamicgraph
......@@ -92,7 +92,6 @@ namespace dynamicgraph {
#define DYNAMIC_GRAPH_ENTITY_ERROR_STREAM(entity) \
_DYNAMIC_GRAPH_ENTITY_MSG(entity, MSG_TYPE_ERROR_STREAM)
template <typename T>
std::string toString(const T &v, const int precision = 3,
const int width = -1) {
......@@ -143,11 +142,11 @@ std::string toString(const Eigen::MatrixBase<T> &v, const int precision = 3,
}
enum LoggerVerbosity {
VERBOSITY_ALL = MSG_TYPE_DEBUG,
VERBOSITY_ALL = MSG_TYPE_DEBUG,
VERBOSITY_INFO_WARNING_ERROR = MSG_TYPE_INFO,
VERBOSITY_WARNING_ERROR = MSG_TYPE_WARNING,
VERBOSITY_ERROR = MSG_TYPE_ERROR,
VERBOSITY_NONE = 0
VERBOSITY_WARNING_ERROR = MSG_TYPE_WARNING,
VERBOSITY_ERROR = MSG_TYPE_ERROR,
VERBOSITY_NONE = 0
};
/// \ingroup debug
......@@ -209,7 +208,7 @@ public:
* iterations.
* \param lineId typically __FILE__ ":" BOOST_PP_STRINGIZE(__LINE__)
*/
RTLoggerStream stream(MsgType type, const std::string& lineId = "") {
RTLoggerStream stream(MsgType type, const std::string &lineId = "") {
RealTimeLogger &rtlogger = ::dynamicgraph::RealTimeLogger::instance();
if (acceptMsg(type, lineId))
return rtlogger.front();
......@@ -221,15 +220,15 @@ public:
* stream(type, lineId) << msg << '\n';
* \endcode
*/
void sendMsg(std::string msg, MsgType type, const std::string& lineId = "");
void sendMsg(std::string msg, MsgType type, const std::string &lineId = "");
/** \deprecated instead, use
* \code
* stream(type, lineId) << msg << '\n';
* \endcode
*/
void sendMsg(std::string msg, MsgType type, const std::string& file,
int line) DYNAMIC_GRAPH_DEPRECATED;
void sendMsg(std::string msg, MsgType type, const std::string &file,
int line) DYNAMIC_GRAPH_DEPRECATED;
/** Set the sampling time at which the method countdown()
* is going to be called. */
......@@ -264,28 +263,27 @@ protected:
the collection of streaming messages */
StreamCounterMap_t m_stream_msg_counters;
inline bool isStreamMsg(MsgType m) {
return (m & MSG_TYPE_STREAM_BIT);
}
inline bool isStreamMsg(MsgType m) { return (m & MSG_TYPE_STREAM_BIT); }
/** Check whether a message of type \m and from \c lineId should be accepted.
* \note If \c is a stream type, the internal counter associated to \c lineId
* is updated.
*/
bool acceptMsg (MsgType m, const std::string& lineId) {
bool acceptMsg(MsgType m, const std::string &lineId) {
// If more verbose than the current verbosity level
if ((m & MSG_TYPE_TYPE_BITS) > m_lv)
return false;
// if print is allowed by current verbosity level
if (isStreamMsg(m)) return checkStreamPeriod(lineId);
if (isStreamMsg(m))
return checkStreamPeriod(lineId);
return true;
}
/** Check whether a message from \c lineId should be accepted.
* \note The internal counter associated to \c lineId is updated.
*/
bool checkStreamPeriod (const std::string& lineId);
bool checkStreamPeriod(const std::string &lineId);
};
} // namespace dynamicgraph
......
......@@ -107,8 +107,8 @@ public:
Vector vectorValue() const;
Eigen::MatrixXd matrixXdValue() const;
Eigen::Matrix4d matrix4dValue() const;
Values valuesValue () const;
const Values &constValuesValue () const;
Values valuesValue() const;
const Values &constValuesValue() const;
Type type_;
const void *const value_;
};
......
......@@ -82,8 +82,7 @@ Value::Value(const Eigen::MatrixXd &value)
: type_(MATRIX), value_(new Eigen::MatrixXd(value)) {}
Value::Value(const Eigen::Matrix4d &value)
: type_(MATRIX4D), value_(new Eigen::Matrix4d(value)) {}
Value::Value(const Values &value)
: type_(VALUES), value_(new Values(value)) {}
Value::Value(const Values &value) : type_(VALUES), value_(new Values(value)) {}
Value::Value(const Value &value)
: type_(value.type_), value_(copyValue(value)) {}
......@@ -145,20 +144,33 @@ Value Value::operator=(const Value &value) {
}
bool Value::operator==(const Value &other) const {
if (type_ != other.type_) return false;
if (type_ != other.type_)
return false;
switch (type_) {
case Value::BOOL: return boolValue() == other.boolValue();
case Value::UNSIGNED: return unsignedValue() == other.unsignedValue();
case Value::INT: return intValue() == other.intValue();
case Value::DOUBLE: return doubleValue() == other.doubleValue();
case Value::FLOAT: return floatValue() == other.floatValue();
case Value::STRING: return stringValue() == other.stringValue();
case Value::VECTOR: return vectorValue() == other.vectorValue();
case Value::MATRIX: return matrixXdValue() == other.matrixXdValue();
case Value::MATRIX4D: return matrix4dValue() == other.matrix4dValue();
case Value::VALUES: return constValuesValue() == other.constValuesValue();
case Value::NONE: break;
default: break;
case Value::BOOL:
return boolValue() == other.boolValue();
case Value::UNSIGNED:
return unsignedValue() == other.unsignedValue();
case Value::INT:
return intValue() == other.intValue();
case Value::DOUBLE:
return doubleValue() == other.doubleValue();
case Value::FLOAT:
return floatValue() == other.floatValue();
case Value::STRING:
return stringValue() == other.stringValue();
case Value::VECTOR:
return vectorValue() == other.vectorValue();
case Value::MATRIX:
return matrixXdValue() == other.matrixXdValue();
case Value::MATRIX4D:
return matrix4dValue() == other.matrix4dValue();
case Value::VALUES:
return constValuesValue() == other.constValuesValue();
case Value::NONE:
break;
default:
break;
}
return false;
}
......@@ -299,15 +311,13 @@ std::ostream &operator<<(std::ostream &os, const Value &value) {
case Value::MATRIX4D:
os << value.matrix4dValue();
break;
case Value::VALUES:
{
const std::vector<Value>& vals = value.constValuesValue();
os << "[ ";
for (std::size_t i = 0; i < vals.size(); ++i)
os << "Value(" << vals[i] << "), ";
os << "]";
}
break;
case Value::VALUES: {
const std::vector<Value> &vals = value.constValuesValue();
os << "[ ";
for (std::size_t i = 0; i < vals.size(); ++i)
os << "Value(" << vals[i] << "), ";
os << "]";
} break;
default:
return os;
}
......
......@@ -34,65 +34,65 @@ public:
logger_.setVerbosity(VERBOSITY_NONE);
BOOST_CHECK_EQUAL(logger_.getVerbosity(), VERBOSITY_NONE);
BOOST_CHECK( logger_.stream(MSG_TYPE_DEBUG ).isNull());
BOOST_CHECK( logger_.stream(MSG_TYPE_INFO ).isNull());
BOOST_CHECK( logger_.stream(MSG_TYPE_WARNING).isNull());
BOOST_CHECK( logger_.stream(MSG_TYPE_ERROR ).isNull());
BOOST_CHECK(logger_.stream(MSG_TYPE_DEBUG).isNull());
BOOST_CHECK(logger_.stream(MSG_TYPE_INFO).isNull());
BOOST_CHECK(logger_.stream(MSG_TYPE_WARNING).isNull());
BOOST_CHECK(logger_.stream(MSG_TYPE_ERROR).isNull());
logger_.setVerbosity(VERBOSITY_ERROR);
BOOST_CHECK_EQUAL(logger_.getVerbosity(), VERBOSITY_ERROR);
BOOST_CHECK( logger_.stream(MSG_TYPE_DEBUG ).isNull());
BOOST_CHECK( logger_.stream(MSG_TYPE_INFO ).isNull());
BOOST_CHECK( logger_.stream(MSG_TYPE_WARNING).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR ).isNull());
BOOST_CHECK(logger_.stream(MSG_TYPE_DEBUG).isNull());
BOOST_CHECK(logger_.stream(MSG_TYPE_INFO).isNull());
BOOST_CHECK(logger_.stream(MSG_TYPE_WARNING).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR).isNull());
logger_.setVerbosity(VERBOSITY_WARNING_ERROR);
BOOST_CHECK_EQUAL(logger_.getVerbosity(), VERBOSITY_WARNING_ERROR);
BOOST_CHECK( logger_.stream(MSG_TYPE_DEBUG ).isNull());
BOOST_CHECK( logger_.stream(MSG_TYPE_INFO ).isNull());
BOOST_CHECK(logger_.stream(MSG_TYPE_DEBUG).isNull());
BOOST_CHECK(logger_.stream(MSG_TYPE_INFO).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_WARNING).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR ).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR).isNull());
logger_.setVerbosity(VERBOSITY_INFO_WARNING_ERROR);
BOOST_CHECK_EQUAL(logger_.getVerbosity(), VERBOSITY_INFO_WARNING_ERROR);
BOOST_CHECK( logger_.stream(MSG_TYPE_DEBUG ).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_INFO ).isNull());
BOOST_CHECK(logger_.stream(MSG_TYPE_DEBUG).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_INFO).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_WARNING).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR ).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR).isNull());
logger_.setVerbosity(VERBOSITY_ALL);
BOOST_CHECK_EQUAL(logger_.getVerbosity(), VERBOSITY_ALL);
BOOST_CHECK(!logger_.stream(MSG_TYPE_DEBUG ).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_INFO ).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_DEBUG).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_INFO).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_WARNING).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR ).isNull());
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR).isNull());
}
~CustomEntity() {}
void testDebugTrace() {
logger_.stream(MSG_TYPE_DEBUG)
<< "This is a message of level MSG_TYPE_DEBUG\n";
<< "This is a message of level MSG_TYPE_DEBUG\n";
dynamicgraph::RealTimeLogger::instance().spinOnce();
logger_.stream(MSG_TYPE_INFO)
<< "This is a message of level MSG_TYPE_INFO\n";
<< "This is a message of level MSG_TYPE_INFO\n";
dynamicgraph::RealTimeLogger::instance().spinOnce();
logger_.stream(MSG_TYPE_WARNING)
<< "This is a message of level MSG_TYPE_WARNING\n";
<< "This is a message of level MSG_TYPE_WARNING\n";
dynamicgraph::RealTimeLogger::instance().spinOnce();
logger_.stream(MSG_TYPE_ERROR)
<< "This is a message of level MSG_TYPE_ERROR\n";
<< "This is a message of level MSG_TYPE_ERROR\n";
dynamicgraph::RealTimeLogger::instance().spinOnce();
logger_.stream(MSG_TYPE_DEBUG_STREAM)
<< "This is a message of level MSG_TYPE_DEBUG_STREAM\n";
<< "This is a message of level MSG_TYPE_DEBUG_STREAM\n";
dynamicgraph::RealTimeLogger::instance().spinOnce();
logger_.stream(MSG_TYPE_INFO_STREAM)
<< "This is a message of level MSG_TYPE_INFO_STREAM\n";
<< "This is a message of level MSG_TYPE_INFO_STREAM\n";
dynamicgraph::RealTimeLogger::instance().spinOnce();
logger_.stream(MSG_TYPE_WARNING_STREAM)
<< "This is a message of level MSG_TYPE_WARNING_STREAM\n";
<< "This is a message of level MSG_TYPE_WARNING_STREAM\n";
dynamicgraph::RealTimeLogger::instance().spinOnce();
logger_.stream(MSG_TYPE_ERROR_STREAM)
<< "This is a message of level MSG_TYPE_ERROR_STREAM\n";
<< "This is a message of level MSG_TYPE_ERROR_STREAM\n";
/* Add test toString */
dynamicgraph::RealTimeLogger::instance().spinOnce();
double q = 1.0;
......@@ -103,13 +103,16 @@ public:
vq[0] = 1.0;
vq[1] = 2.0;
vq[2] = 3.0;
logger_.stream(MSG_TYPE_INFO) << "Value to display: " << toString(vq) << '\n';
logger_.stream(MSG_TYPE_INFO)
<< "Value to display: " << toString(vq) << '\n';
dynamicgraph::RealTimeLogger::instance().spinOnce();
logger_.stream(MSG_TYPE_INFO) << "Value to display: " << toString(vq, 3, 10) << '\n';
logger_.stream(MSG_TYPE_INFO)
<< "Value to display: " << toString(vq, 3, 10) << '\n';
dynamicgraph::RealTimeLogger::instance().spinOnce();
Eigen::Matrix<double, 3, 3> an_eig_m;
an_eig_m.setOnes();
logger_.stream(MSG_TYPE_INFO) << "Value to display: " << toString(an_eig_m) << '\n';
logger_.stream(MSG_TYPE_INFO)
<< "Value to display: " << toString(an_eig_m) << '\n';
dynamicgraph::RealTimeLogger::instance().spinOnce();
logger_.countdown();
}
......
......@@ -218,13 +218,17 @@ BOOST_AUTO_TEST_CASE(sendMsg) {
#define __FILELINE__ __FILE__ BOOST_PP_STRINGIZE(__LINE__)
entity.logger().stream(dynamicgraph::MSG_TYPE_DEBUG, __FILELINE__)
<< "Auto Test Case" << " DEBUG" << '\n';
<< "Auto Test Case"
<< " DEBUG" << '\n';
entity.logger().stream(dynamicgraph::MSG_TYPE_INFO, __FILELINE__)
<< "Auto Test Case" << " INFO" << '\n';
<< "Auto Test Case"
<< " INFO" << '\n';
entity.logger().stream(dynamicgraph::MSG_TYPE_WARNING, __FILELINE__)
<< "Auto Test Case" << " WARNING" << '\n';
<< "Auto Test Case"
<< " WARNING" << '\n';
entity.logger().stream(dynamicgraph::MSG_TYPE_ERROR, __FILELINE__)
<< "Auto Test Case" << " ERROR" << '\n';
<< "Auto Test Case"
<< " ERROR" << '\n';
#undef __FILELINE__
};
};
......
......@@ -210,25 +210,23 @@ BOOST_AUTO_TEST_CASE(signal_caster_basics) {
/// Unregister a type
asig_caster->unregisterCast(typeid(double));
/// Unregister the type a second time to generate exception
bool res= false;
bool res = false;
try {
asig_caster->unregisterCast(typeid(double));
} catch (ExceptionSignal &aes)
{
} catch (ExceptionSignal &aes) {
res = (aes.getCode() == ExceptionSignal::GENERIC);
}
BOOST_CHECK(res);
/// Get the type cast to generate exception
res= false;
double ad=2.0;
res = false;
double ad = 2.0;
output_test_stream output;
try {
asig_caster->disp(ad,output);
} catch (ExceptionSignal &aes)
{
asig_caster->disp(ad, output);
} catch (ExceptionSignal &aes) {
res = (aes.getCode() == ExceptionSignal::BAD_CAST);
}
BOOST_CHECK(res);
......
......@@ -376,26 +376,26 @@ BOOST_AUTO_TEST_CASE(value_values) {
Value vd1(d1);
Values values;
values.push_back (vs1);
values.push_back (vd1);
values.push_back(vs1);
values.push_back(vd1);
Value vvalues (values);
Value vvalues(values);
BOOST_CHECK_EQUAL(vvalues.type(), Value::VALUES);
{ // Const ref
const Values& vs = vvalues.constValuesValue();
const Values &vs = vvalues.constValuesValue();
BOOST_CHECK_EQUAL(vs.size(), values.size());
BOOST_CHECK(vs == values);
}
{ // Cast does not work.
//dg::command::EitherType eitherType (vvalues);
//Values vs = static_cast<Values>(eitherType);
//BOOST_CHECK_EQUAL(vs.size(), values.size());
//BOOST_CHECK(vs == values);
}
{ // Constructor
Value vvs (vvalues);
{
// Cast does not work.
// dg::command::EitherType eitherType (vvalues);
// Values vs = static_cast<Values>(eitherType);
// BOOST_CHECK_EQUAL(vs.size(), values.size());
// BOOST_CHECK(vs == values);
} { // Constructor
Value vvs(vvalues);
BOOST_CHECK(vvs == vvalues);
}
......
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