Skip to content

Commit b030783

Browse files
committed
formatten .cpp and .h files
1 parent a0ce0f0 commit b030783

File tree

4 files changed

+354
-308
lines changed

4 files changed

+354
-308
lines changed

include/mros2.h

Lines changed: 70 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,95 +10,93 @@
1010

1111
/* Statement to avoid link error */
1212
#ifdef __cplusplus
13-
extern void* __dso_handle;
13+
extern void *__dso_handle;
1414
#endif
1515

1616
namespace rtps
1717
{
18-
namespace Config
19-
{
20-
extern std::array<uint8_t, 4> IP_ADDRESS;
21-
}
18+
namespace Config
19+
{
20+
extern std::array<uint8_t, 4> IP_ADDRESS;
21+
}
2222
}
2323

2424
namespace mros2
2525
{
2626

27-
void init(int argc, char * argv[]);
27+
void init(int argc, char *argv[]);
2828

2929
#ifdef __cplusplus
30-
extern "C" {
30+
extern "C"
31+
{
3132
#endif
32-
void mros2_init(void *arg);
33+
void mros2_init(void *arg);
3334
#ifdef __cplusplus
34-
}
35+
}
3536
#endif
3637

37-
class Node;
38-
class Publisher;
39-
class Subscriber;
40-
41-
/* TODO: move to node.h/cpp? */
42-
class Node
43-
{
44-
public:
45-
static Node create_node(
46-
std::string node_name
47-
);
48-
49-
template <class T>
50-
Publisher create_publisher(
51-
std::string topic_name,
52-
int qos
53-
);
54-
55-
template <class T>
56-
Subscriber create_subscription(
57-
std::string topic_name,
58-
int qos,
59-
void (*fp)(T*)
60-
);
61-
62-
std::string node_name;
63-
rtps::Participant* part;
64-
65-
private:
66-
67-
};
68-
69-
class Publisher
70-
{
71-
public:
72-
std::string topic_name;
73-
template <class T>
74-
void publish(T& msg);
75-
};
76-
77-
class Subscriber
78-
{
79-
public:
80-
std::string topic_name;
81-
template <class T>
82-
static void callback_handler(
83-
void* callee,
84-
const rtps::ReaderCacheChange& cacheChange
85-
);
86-
void (*cb_fp)(intptr_t);
87-
private:
88-
};
89-
90-
void spin();
91-
92-
void setIPAddrRTPS(std::array<uint8_t, 4> ipaddr);
93-
94-
} /* namespace mros2 */
38+
class Node;
39+
class Publisher;
40+
class Subscriber;
41+
42+
/* TODO: move to node.h/cpp? */
43+
class Node
44+
{
45+
public:
46+
static Node create_node(
47+
std::string node_name);
48+
49+
template <class T>
50+
Publisher create_publisher(
51+
std::string topic_name,
52+
int qos);
53+
54+
template <class T>
55+
Subscriber create_subscription(
56+
std::string topic_name,
57+
int qos,
58+
void (*fp)(T *));
59+
60+
std::string node_name;
61+
rtps::Participant *part;
62+
63+
private:
64+
};
65+
66+
class Publisher
67+
{
68+
public:
69+
std::string topic_name;
70+
template <class T>
71+
void publish(T &msg);
72+
};
73+
74+
class Subscriber
75+
{
76+
public:
77+
std::string topic_name;
78+
template <class T>
79+
static void callback_handler(
80+
void *callee,
81+
const rtps::ReaderCacheChange &cacheChange);
82+
void (*cb_fp)(intptr_t);
83+
84+
private:
85+
};
86+
87+
void spin();
88+
89+
void setIPAddrRTPS(std::array<uint8_t, 4> ipaddr);
90+
91+
} /* namespace mros2 */
9592

9693
namespace message_traits
9794
{
98-
template <class T>
99-
struct TypeName {
100-
static const char* value();
101-
};
102-
} /* namespace message_traits */
95+
template <class T>
96+
struct TypeName
97+
{
98+
static const char *value();
99+
};
100+
} /* namespace message_traits */
103101

104102
#endif /* MROS2_MROS2_H */

include/mros2/logging.h

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,49 +25,74 @@
2525
#define MROS2_DEBUG_SKIPFIRST(...)
2626
#else
2727
#ifdef __MBED__
28-
#define MROS2_DEBUG(...) do{ printf(__VA_ARGS__); printf("\r\n"); }while(0)
28+
#define MROS2_DEBUG(...) \
29+
do \
30+
{ \
31+
printf(__VA_ARGS__); \
32+
printf("\r\n"); \
33+
} while (0)
2934
#else /* __MBED__ */
30-
#define MROS2_DEBUG(...) CMSIS_IMPL_DEBUG(__VA_ARGS__)
35+
#define MROS2_DEBUG(...) CMSIS_IMPL_DEBUG(__VA_ARGS__)
3136
#endif /* __MBED__ */
3237
#endif
3338

3439
#if (MROS2_LOG_MIN_SEVERITY > MROS2_LOG_MIN_SEVERITY_INFO)
3540
#define MROS2_INFO(...)
3641
#else
3742
#ifdef __MBED__
38-
#define MROS2_INFO(...) do{ printf(__VA_ARGS__); printf("\r\n"); }while(0)
43+
#define MROS2_INFO(...) \
44+
do \
45+
{ \
46+
printf(__VA_ARGS__); \
47+
printf("\r\n"); \
48+
} while (0)
3949
#else /* __MBED__ */
40-
#define MROS2_INFO(...) CMSIS_IMPL_INFO(__VA_ARGS__)
50+
#define MROS2_INFO(...) CMSIS_IMPL_INFO(__VA_ARGS__)
4151
#endif /* __MBED__ */
4252
#endif
4353

4454
#if (MROS2_LOG_MIN_SEVERITY > MROS2_LOG_MIN_SEVERITY_WARN)
4555
#define MROS2_WARN(...)
4656
#else
4757
#ifdef __MBED__
48-
#define MROS2_WARN(...) do{ printf(__VA_ARGS__); printf("\r\n"); }while(0)
58+
#define MROS2_WARN(...) \
59+
do \
60+
{ \
61+
printf(__VA_ARGS__); \
62+
printf("\r\n"); \
63+
} while (0)
4964
#else /* __MBED__ */
50-
#define MROS2_WARN(...) CMSIS_IMPL_WARN(__VA_ARGS__)
65+
#define MROS2_WARN(...) CMSIS_IMPL_WARN(__VA_ARGS__)
5166
#endif /* __MBED__ */
5267
#endif
5368

5469
#if (MROS2_LOG_MIN_SEVERITY > MROS2_LOG_MIN_SEVERITY_ERROR)
5570
#define MROS2_ERROR(...)
5671
#else
5772
#ifdef __MBED__
58-
#define MROS2_ERROR(...) do{ error(__VA_ARGS__); printf("\r\n"); }while(0)
73+
#define MROS2_ERROR(...) \
74+
do \
75+
{ \
76+
error(__VA_ARGS__); \
77+
printf("\r\n"); \
78+
} while (0)
5979
#else /* __MBED__ */
60-
#define MROS2_ERROR(...) CMSIS_IMPL_ERROR(__VA_ARGS__)
80+
#define MROS2_ERROR(...) CMSIS_IMPL_ERROR(__VA_ARGS__)
6181
#endif /* __MBED__ */
6282
#endif
6383

6484
#if (MROS2_LOG_MIN_SEVERITY > MROS2_LOG_MIN_SEVERITY_FATAL)
6585
#define MROS2_FATAL(...)
6686
#else
6787
#ifdef __MBED__
68-
#define MROS2_FATAL(...) do{ error(__VA_ARGS__); printf("\r\n"); }while(0)
88+
#define MROS2_FATAL(...) \
89+
do \
90+
{ \
91+
error(__VA_ARGS__); \
92+
printf("\r\n"); \
93+
} while (0)
6994
#else /* __MBED__ */
70-
#define MROS2_FATAL(...) CMSIS_IMPL_FATAL(__VA_ARGS__)
95+
#define MROS2_FATAL(...) CMSIS_IMPL_FATAL(__VA_ARGS__)
7196
#endif /* __MBED__ */
7297
#endif
7398

include/mros2_config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#define _MROS2_USER_CONFIG_H_
33

44
#ifdef __cplusplus
5-
extern "C" {
5+
extern "C"
6+
{
67
#endif
78

89
#define SUB_MSG_COUNT 10

0 commit comments

Comments
 (0)