Skip to content

Commit 7086411

Browse files
clang format.
1 parent f9edb95 commit 7086411

File tree

8 files changed

+118
-106
lines changed

8 files changed

+118
-106
lines changed

include/dynamic-graph/command-setter.t.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include "dynamic-graph/command-setter.h"
1111
#include "dynamic-graph/linear-algebra.h"
12-
#include "dynamic-graph/command-setter.h"
1312
#include <boost/assign/list_of.hpp>
1413
#include <sstream>
1514

include/dynamic-graph/logger.h

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ namespace dynamicgraph {
2727
/** Enum representing the different kind of messages.
2828
*/
2929
enum MsgType {
30-
MSG_TYPE_TYPE_BITS = 1<<0 | 1<<1 | 1<<2 | 1<<3, // 15
31-
MSG_TYPE_STREAM_BIT = 1<<4, // 16
32-
33-
MSG_TYPE_DEBUG = 1<<3, // 1
34-
MSG_TYPE_INFO = 1<<2, // 2
35-
MSG_TYPE_WARNING = 1<<1, // 4
36-
MSG_TYPE_ERROR = 1<<0, // 8
37-
MSG_TYPE_DEBUG_STREAM = MSG_TYPE_DEBUG | MSG_TYPE_STREAM_BIT, // 17
38-
MSG_TYPE_INFO_STREAM = MSG_TYPE_INFO | MSG_TYPE_STREAM_BIT, // 18
39-
MSG_TYPE_WARNING_STREAM = MSG_TYPE_WARNING | MSG_TYPE_STREAM_BIT, // 20
40-
MSG_TYPE_ERROR_STREAM = MSG_TYPE_ERROR | MSG_TYPE_STREAM_BIT // 24
30+
MSG_TYPE_TYPE_BITS = 1 << 0 | 1 << 1 | 1 << 2 | 1 << 3, // 15
31+
MSG_TYPE_STREAM_BIT = 1 << 4, // 16
32+
33+
MSG_TYPE_DEBUG = 1 << 3, // 1
34+
MSG_TYPE_INFO = 1 << 2, // 2
35+
MSG_TYPE_WARNING = 1 << 1, // 4
36+
MSG_TYPE_ERROR = 1 << 0, // 8
37+
MSG_TYPE_DEBUG_STREAM = MSG_TYPE_DEBUG | MSG_TYPE_STREAM_BIT, // 17
38+
MSG_TYPE_INFO_STREAM = MSG_TYPE_INFO | MSG_TYPE_STREAM_BIT, // 18
39+
MSG_TYPE_WARNING_STREAM = MSG_TYPE_WARNING | MSG_TYPE_STREAM_BIT, // 20
40+
MSG_TYPE_ERROR_STREAM = MSG_TYPE_ERROR | MSG_TYPE_STREAM_BIT // 24
4141
};
4242
} // namespace dynamicgraph
4343

@@ -92,7 +92,6 @@ namespace dynamicgraph {
9292
#define DYNAMIC_GRAPH_ENTITY_ERROR_STREAM(entity) \
9393
_DYNAMIC_GRAPH_ENTITY_MSG(entity, MSG_TYPE_ERROR_STREAM)
9494

95-
9695
template <typename T>
9796
std::string toString(const T &v, const int precision = 3,
9897
const int width = -1) {
@@ -143,11 +142,11 @@ std::string toString(const Eigen::MatrixBase<T> &v, const int precision = 3,
143142
}
144143

145144
enum LoggerVerbosity {
146-
VERBOSITY_ALL = MSG_TYPE_DEBUG,
145+
VERBOSITY_ALL = MSG_TYPE_DEBUG,
147146
VERBOSITY_INFO_WARNING_ERROR = MSG_TYPE_INFO,
148-
VERBOSITY_WARNING_ERROR = MSG_TYPE_WARNING,
149-
VERBOSITY_ERROR = MSG_TYPE_ERROR,
150-
VERBOSITY_NONE = 0
147+
VERBOSITY_WARNING_ERROR = MSG_TYPE_WARNING,
148+
VERBOSITY_ERROR = MSG_TYPE_ERROR,
149+
VERBOSITY_NONE = 0
151150
};
152151

153152
/// \ingroup debug
@@ -209,7 +208,7 @@ class Logger {
209208
* iterations.
210209
* \param lineId typically __FILE__ ":" BOOST_PP_STRINGIZE(__LINE__)
211210
*/
212-
RTLoggerStream stream(MsgType type, const std::string& lineId = "") {
211+
RTLoggerStream stream(MsgType type, const std::string &lineId = "") {
213212
RealTimeLogger &rtlogger = ::dynamicgraph::RealTimeLogger::instance();
214213
if (acceptMsg(type, lineId))
215214
return rtlogger.front();
@@ -221,15 +220,15 @@ class Logger {
221220
* stream(type, lineId) << msg << '\n';
222221
* \endcode
223222
*/
224-
void sendMsg(std::string msg, MsgType type, const std::string& lineId = "");
223+
void sendMsg(std::string msg, MsgType type, const std::string &lineId = "");
225224

226225
/** \deprecated instead, use
227226
* \code
228227
* stream(type, lineId) << msg << '\n';
229228
* \endcode
230229
*/
231-
void sendMsg(std::string msg, MsgType type, const std::string& file,
232-
int line) DYNAMIC_GRAPH_DEPRECATED;
230+
void sendMsg(std::string msg, MsgType type, const std::string &file,
231+
int line) DYNAMIC_GRAPH_DEPRECATED;
233232

234233
/** Set the sampling time at which the method countdown()
235234
* is going to be called. */
@@ -264,28 +263,27 @@ class Logger {
264263
the collection of streaming messages */
265264
StreamCounterMap_t m_stream_msg_counters;
266265

267-
inline bool isStreamMsg(MsgType m) {
268-
return (m & MSG_TYPE_STREAM_BIT);
269-
}
266+
inline bool isStreamMsg(MsgType m) { return (m & MSG_TYPE_STREAM_BIT); }
270267

271268
/** Check whether a message of type \m and from \c lineId should be accepted.
272269
* \note If \c is a stream type, the internal counter associated to \c lineId
273270
* is updated.
274271
*/
275-
bool acceptMsg (MsgType m, const std::string& lineId) {
272+
bool acceptMsg(MsgType m, const std::string &lineId) {
276273
// If more verbose than the current verbosity level
277274
if ((m & MSG_TYPE_TYPE_BITS) > m_lv)
278275
return false;
279276

280277
// if print is allowed by current verbosity level
281-
if (isStreamMsg(m)) return checkStreamPeriod(lineId);
278+
if (isStreamMsg(m))
279+
return checkStreamPeriod(lineId);
282280
return true;
283281
}
284282

285283
/** Check whether a message from \c lineId should be accepted.
286284
* \note The internal counter associated to \c lineId is updated.
287285
*/
288-
bool checkStreamPeriod (const std::string& lineId);
286+
bool checkStreamPeriod(const std::string &lineId);
289287
};
290288

291289
} // namespace dynamicgraph

include/dynamic-graph/value.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ class DYNAMIC_GRAPH_DLLAPI Value {
107107
Vector vectorValue() const;
108108
Eigen::MatrixXd matrixXdValue() const;
109109
Eigen::Matrix4d matrix4dValue() const;
110-
Values valuesValue () const;
111-
const Values &constValuesValue () const;
110+
Values valuesValue() const;
111+
const Values &constValuesValue() const;
112112
Type type_;
113113
const void *const value_;
114114
};

src/command/value.cpp

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ Value::Value(const Eigen::MatrixXd &value)
8282
: type_(MATRIX), value_(new Eigen::MatrixXd(value)) {}
8383
Value::Value(const Eigen::Matrix4d &value)
8484
: type_(MATRIX4D), value_(new Eigen::Matrix4d(value)) {}
85-
Value::Value(const Values &value)
86-
: type_(VALUES), value_(new Values(value)) {}
85+
Value::Value(const Values &value) : type_(VALUES), value_(new Values(value)) {}
8786

8887
Value::Value(const Value &value)
8988
: type_(value.type_), value_(copyValue(value)) {}
@@ -145,20 +144,33 @@ Value Value::operator=(const Value &value) {
145144
}
146145

147146
bool Value::operator==(const Value &other) const {
148-
if (type_ != other.type_) return false;
147+
if (type_ != other.type_)
148+
return false;
149149
switch (type_) {
150-
case Value::BOOL: return boolValue() == other.boolValue();
151-
case Value::UNSIGNED: return unsignedValue() == other.unsignedValue();
152-
case Value::INT: return intValue() == other.intValue();
153-
case Value::DOUBLE: return doubleValue() == other.doubleValue();
154-
case Value::FLOAT: return floatValue() == other.floatValue();
155-
case Value::STRING: return stringValue() == other.stringValue();
156-
case Value::VECTOR: return vectorValue() == other.vectorValue();
157-
case Value::MATRIX: return matrixXdValue() == other.matrixXdValue();
158-
case Value::MATRIX4D: return matrix4dValue() == other.matrix4dValue();
159-
case Value::VALUES: return constValuesValue() == other.constValuesValue();
160-
case Value::NONE: break;
161-
default: break;
150+
case Value::BOOL:
151+
return boolValue() == other.boolValue();
152+
case Value::UNSIGNED:
153+
return unsignedValue() == other.unsignedValue();
154+
case Value::INT:
155+
return intValue() == other.intValue();
156+
case Value::DOUBLE:
157+
return doubleValue() == other.doubleValue();
158+
case Value::FLOAT:
159+
return floatValue() == other.floatValue();
160+
case Value::STRING:
161+
return stringValue() == other.stringValue();
162+
case Value::VECTOR:
163+
return vectorValue() == other.vectorValue();
164+
case Value::MATRIX:
165+
return matrixXdValue() == other.matrixXdValue();
166+
case Value::MATRIX4D:
167+
return matrix4dValue() == other.matrix4dValue();
168+
case Value::VALUES:
169+
return constValuesValue() == other.constValuesValue();
170+
case Value::NONE:
171+
break;
172+
default:
173+
break;
162174
}
163175
return false;
164176
}
@@ -299,15 +311,13 @@ std::ostream &operator<<(std::ostream &os, const Value &value) {
299311
case Value::MATRIX4D:
300312
os << value.matrix4dValue();
301313
break;
302-
case Value::VALUES:
303-
{
304-
const std::vector<Value>& vals = value.constValuesValue();
305-
os << "[ ";
306-
for (std::size_t i = 0; i < vals.size(); ++i)
307-
os << "Value(" << vals[i] << "), ";
308-
os << "]";
309-
}
310-
break;
314+
case Value::VALUES: {
315+
const std::vector<Value> &vals = value.constValuesValue();
316+
os << "[ ";
317+
for (std::size_t i = 0; i < vals.size(); ++i)
318+
os << "Value(" << vals[i] << "), ";
319+
os << "]";
320+
} break;
311321
default:
312322
return os;
313323
}

tests/debug-logger.cpp

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,65 +34,65 @@ class CustomEntity : public Entity {
3434

3535
logger_.setVerbosity(VERBOSITY_NONE);
3636
BOOST_CHECK_EQUAL(logger_.getVerbosity(), VERBOSITY_NONE);
37-
BOOST_CHECK( logger_.stream(MSG_TYPE_DEBUG ).isNull());
38-
BOOST_CHECK( logger_.stream(MSG_TYPE_INFO ).isNull());
39-
BOOST_CHECK( logger_.stream(MSG_TYPE_WARNING).isNull());
40-
BOOST_CHECK( logger_.stream(MSG_TYPE_ERROR ).isNull());
37+
BOOST_CHECK(logger_.stream(MSG_TYPE_DEBUG).isNull());
38+
BOOST_CHECK(logger_.stream(MSG_TYPE_INFO).isNull());
39+
BOOST_CHECK(logger_.stream(MSG_TYPE_WARNING).isNull());
40+
BOOST_CHECK(logger_.stream(MSG_TYPE_ERROR).isNull());
4141

4242
logger_.setVerbosity(VERBOSITY_ERROR);
4343
BOOST_CHECK_EQUAL(logger_.getVerbosity(), VERBOSITY_ERROR);
44-
BOOST_CHECK( logger_.stream(MSG_TYPE_DEBUG ).isNull());
45-
BOOST_CHECK( logger_.stream(MSG_TYPE_INFO ).isNull());
46-
BOOST_CHECK( logger_.stream(MSG_TYPE_WARNING).isNull());
47-
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR ).isNull());
44+
BOOST_CHECK(logger_.stream(MSG_TYPE_DEBUG).isNull());
45+
BOOST_CHECK(logger_.stream(MSG_TYPE_INFO).isNull());
46+
BOOST_CHECK(logger_.stream(MSG_TYPE_WARNING).isNull());
47+
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR).isNull());
4848

4949
logger_.setVerbosity(VERBOSITY_WARNING_ERROR);
5050
BOOST_CHECK_EQUAL(logger_.getVerbosity(), VERBOSITY_WARNING_ERROR);
51-
BOOST_CHECK( logger_.stream(MSG_TYPE_DEBUG ).isNull());
52-
BOOST_CHECK( logger_.stream(MSG_TYPE_INFO ).isNull());
51+
BOOST_CHECK(logger_.stream(MSG_TYPE_DEBUG).isNull());
52+
BOOST_CHECK(logger_.stream(MSG_TYPE_INFO).isNull());
5353
BOOST_CHECK(!logger_.stream(MSG_TYPE_WARNING).isNull());
54-
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR ).isNull());
54+
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR).isNull());
5555

5656
logger_.setVerbosity(VERBOSITY_INFO_WARNING_ERROR);
5757
BOOST_CHECK_EQUAL(logger_.getVerbosity(), VERBOSITY_INFO_WARNING_ERROR);
58-
BOOST_CHECK( logger_.stream(MSG_TYPE_DEBUG ).isNull());
59-
BOOST_CHECK(!logger_.stream(MSG_TYPE_INFO ).isNull());
58+
BOOST_CHECK(logger_.stream(MSG_TYPE_DEBUG).isNull());
59+
BOOST_CHECK(!logger_.stream(MSG_TYPE_INFO).isNull());
6060
BOOST_CHECK(!logger_.stream(MSG_TYPE_WARNING).isNull());
61-
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR ).isNull());
61+
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR).isNull());
6262

6363
logger_.setVerbosity(VERBOSITY_ALL);
6464
BOOST_CHECK_EQUAL(logger_.getVerbosity(), VERBOSITY_ALL);
65-
BOOST_CHECK(!logger_.stream(MSG_TYPE_DEBUG ).isNull());
66-
BOOST_CHECK(!logger_.stream(MSG_TYPE_INFO ).isNull());
65+
BOOST_CHECK(!logger_.stream(MSG_TYPE_DEBUG).isNull());
66+
BOOST_CHECK(!logger_.stream(MSG_TYPE_INFO).isNull());
6767
BOOST_CHECK(!logger_.stream(MSG_TYPE_WARNING).isNull());
68-
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR ).isNull());
68+
BOOST_CHECK(!logger_.stream(MSG_TYPE_ERROR).isNull());
6969
}
7070

7171
~CustomEntity() {}
7272
void testDebugTrace() {
7373
logger_.stream(MSG_TYPE_DEBUG)
74-
<< "This is a message of level MSG_TYPE_DEBUG\n";
74+
<< "This is a message of level MSG_TYPE_DEBUG\n";
7575
dynamicgraph::RealTimeLogger::instance().spinOnce();
7676
logger_.stream(MSG_TYPE_INFO)
77-
<< "This is a message of level MSG_TYPE_INFO\n";
77+
<< "This is a message of level MSG_TYPE_INFO\n";
7878
dynamicgraph::RealTimeLogger::instance().spinOnce();
7979
logger_.stream(MSG_TYPE_WARNING)
80-
<< "This is a message of level MSG_TYPE_WARNING\n";
80+
<< "This is a message of level MSG_TYPE_WARNING\n";
8181
dynamicgraph::RealTimeLogger::instance().spinOnce();
8282
logger_.stream(MSG_TYPE_ERROR)
83-
<< "This is a message of level MSG_TYPE_ERROR\n";
83+
<< "This is a message of level MSG_TYPE_ERROR\n";
8484
dynamicgraph::RealTimeLogger::instance().spinOnce();
8585
logger_.stream(MSG_TYPE_DEBUG_STREAM)
86-
<< "This is a message of level MSG_TYPE_DEBUG_STREAM\n";
86+
<< "This is a message of level MSG_TYPE_DEBUG_STREAM\n";
8787
dynamicgraph::RealTimeLogger::instance().spinOnce();
8888
logger_.stream(MSG_TYPE_INFO_STREAM)
89-
<< "This is a message of level MSG_TYPE_INFO_STREAM\n";
89+
<< "This is a message of level MSG_TYPE_INFO_STREAM\n";
9090
dynamicgraph::RealTimeLogger::instance().spinOnce();
9191
logger_.stream(MSG_TYPE_WARNING_STREAM)
92-
<< "This is a message of level MSG_TYPE_WARNING_STREAM\n";
92+
<< "This is a message of level MSG_TYPE_WARNING_STREAM\n";
9393
dynamicgraph::RealTimeLogger::instance().spinOnce();
9494
logger_.stream(MSG_TYPE_ERROR_STREAM)
95-
<< "This is a message of level MSG_TYPE_ERROR_STREAM\n";
95+
<< "This is a message of level MSG_TYPE_ERROR_STREAM\n";
9696
/* Add test toString */
9797
dynamicgraph::RealTimeLogger::instance().spinOnce();
9898
double q = 1.0;
@@ -103,13 +103,16 @@ class CustomEntity : public Entity {
103103
vq[0] = 1.0;
104104
vq[1] = 2.0;
105105
vq[2] = 3.0;
106-
logger_.stream(MSG_TYPE_INFO) << "Value to display: " << toString(vq) << '\n';
106+
logger_.stream(MSG_TYPE_INFO)
107+
<< "Value to display: " << toString(vq) << '\n';
107108
dynamicgraph::RealTimeLogger::instance().spinOnce();
108-
logger_.stream(MSG_TYPE_INFO) << "Value to display: " << toString(vq, 3, 10) << '\n';
109+
logger_.stream(MSG_TYPE_INFO)
110+
<< "Value to display: " << toString(vq, 3, 10) << '\n';
109111
dynamicgraph::RealTimeLogger::instance().spinOnce();
110112
Eigen::Matrix<double, 3, 3> an_eig_m;
111113
an_eig_m.setOnes();
112-
logger_.stream(MSG_TYPE_INFO) << "Value to display: " << toString(an_eig_m) << '\n';
114+
logger_.stream(MSG_TYPE_INFO)
115+
<< "Value to display: " << toString(an_eig_m) << '\n';
113116
dynamicgraph::RealTimeLogger::instance().spinOnce();
114117
logger_.countdown();
115118
}

tests/entity.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,17 @@ BOOST_AUTO_TEST_CASE(sendMsg) {
218218

219219
#define __FILELINE__ __FILE__ BOOST_PP_STRINGIZE(__LINE__)
220220
entity.logger().stream(dynamicgraph::MSG_TYPE_DEBUG, __FILELINE__)
221-
<< "Auto Test Case" << " DEBUG" << '\n';
221+
<< "Auto Test Case"
222+
<< " DEBUG" << '\n';
222223
entity.logger().stream(dynamicgraph::MSG_TYPE_INFO, __FILELINE__)
223-
<< "Auto Test Case" << " INFO" << '\n';
224+
<< "Auto Test Case"
225+
<< " INFO" << '\n';
224226
entity.logger().stream(dynamicgraph::MSG_TYPE_WARNING, __FILELINE__)
225-
<< "Auto Test Case" << " WARNING" << '\n';
227+
<< "Auto Test Case"
228+
<< " WARNING" << '\n';
226229
entity.logger().stream(dynamicgraph::MSG_TYPE_ERROR, __FILELINE__)
227-
<< "Auto Test Case" << " ERROR" << '\n';
230+
<< "Auto Test Case"
231+
<< " ERROR" << '\n';
228232
#undef __FILELINE__
229233
};
230234
};

tests/signal-all.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,25 +210,23 @@ BOOST_AUTO_TEST_CASE(signal_caster_basics) {
210210

211211
/// Unregister a type
212212
asig_caster->unregisterCast(typeid(double));
213-
213+
214214
/// Unregister the type a second time to generate exception
215-
bool res= false;
215+
bool res = false;
216216
try {
217217
asig_caster->unregisterCast(typeid(double));
218-
} catch (ExceptionSignal &aes)
219-
{
218+
} catch (ExceptionSignal &aes) {
220219
res = (aes.getCode() == ExceptionSignal::GENERIC);
221220
}
222221
BOOST_CHECK(res);
223222

224223
/// Get the type cast to generate exception
225-
res= false;
226-
double ad=2.0;
224+
res = false;
225+
double ad = 2.0;
227226
output_test_stream output;
228227
try {
229-
asig_caster->disp(ad,output);
230-
} catch (ExceptionSignal &aes)
231-
{
228+
asig_caster->disp(ad, output);
229+
} catch (ExceptionSignal &aes) {
232230
res = (aes.getCode() == ExceptionSignal::BAD_CAST);
233231
}
234232
BOOST_CHECK(res);

0 commit comments

Comments
 (0)