Skip to content

Commit 6435fb7

Browse files
committedMar 26, 2024
new clang format
1 parent 2bf04cc commit 6435fb7

37 files changed

+573
-456
lines changed
 
+22-23
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
---
2-
BasedOnStyle: Google
2+
BasedOnStyle: Google
33
AccessModifierOffset: -2
44
ConstructorInitializerIndentWidth: 2
55
AlignEscapedNewlinesLeft: false
66
AlignTrailingComments: true
77
AllowAllParametersOfDeclarationOnNextLine: false
88
AllowShortIfStatementsOnASingleLine: false
99
AllowShortLoopsOnASingleLine: false
10-
AllowShortFunctionsOnASingleLine: Inline
10+
AllowShortFunctionsOnASingleLine: None
1111
AlwaysBreakTemplateDeclarations: true
1212
AlwaysBreakBeforeMultilineStrings: false
1313
BreakBeforeBinaryOperators: false
1414
BreakBeforeTernaryOperators: false
15-
BreakConstructorInitializersBeforeComma: false
16-
BreakConstructorInitializers: AfterColon
15+
BreakConstructorInitializers: BeforeComma
1716
BinPackParameters: true
18-
ColumnLimit: 90
17+
ColumnLimit: 90
1918
ConstructorInitializerAllOnOneLineOrOnePerLine: true
2019
DerivePointerBinding: false
2120
PointerBindsToType: true
@@ -30,19 +29,20 @@ PenaltyBreakString: 1
3029
PenaltyBreakFirstLessLess: 1000
3130
PenaltyExcessCharacter: 1000
3231
PenaltyReturnTypeOnItsOwnLine: 90
33-
SpacesBeforeTrailingComments: 3
34-
Cpp11BracedListStyle: true
35-
Standard: Auto
36-
IndentWidth: 2
37-
TabWidth: 2
38-
UseTab: Never
32+
SpacesBeforeTrailingComments: 2
33+
Cpp11BracedListStyle: false
34+
Standard: Auto
35+
IndentWidth: 2
36+
TabWidth: 2
37+
UseTab: Never
3938
IndentFunctionDeclarationAfterType: false
4039
SpacesInParentheses: false
41-
SpacesInAngles: false
40+
SpacesInAngles: false
4241
SpaceInEmptyParentheses: false
4342
SpacesInCStyleCastParentheses: false
4443
SpaceAfterControlStatementKeyword: true
4544
SpaceBeforeAssignmentOperators: true
45+
SpaceBeforeParens: Never
4646
ContinuationIndentWidth: 4
4747
SortIncludes: false
4848
SpaceAfterCStyleCast: false
@@ -53,17 +53,16 @@ BreakBeforeBraces: Custom
5353

5454
# Control of individual brace wrapping cases
5555
BraceWrapping: {
56-
AfterClass: 'true'
57-
AfterControlStatement: 'true'
58-
AfterEnum : 'true'
59-
AfterFunction : 'true'
60-
AfterNamespace : 'true'
61-
AfterStruct : 'true'
62-
AfterUnion : 'true'
63-
BeforeCatch : 'true'
64-
BeforeElse : 'true'
65-
IndentBraces : 'false'
56+
AfterClass: 'true',
57+
AfterControlStatement: 'true',
58+
AfterEnum : 'true',
59+
AfterFunction : 'true',
60+
AfterNamespace : 'true',
61+
AfterStruct : 'true',
62+
AfterUnion : 'true',
63+
BeforeCatch : 'true',
64+
BeforeElse : 'true',
65+
IndentBraces : 'false',
6666
SplitEmptyFunction: 'false'
6767
}
6868
...
69-

‎.github/workflows/cmake_ubuntu.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ jobs:
2020

2121
steps:
2222
- uses: actions/checkout@v2
23-
23+
2424
- name: Install Conan
2525
id: conan
2626
uses: turtlebrowser/get-conan@main
2727
with:
2828
version: 2.0.13
29-
29+
3030
- name: Create default profile
3131
run: conan profile detect
3232

@@ -48,17 +48,16 @@ jobs:
4848
shell: bash
4949
working-directory: ${{github.workspace}}/build
5050
run: cmake --build . --config Debug
51-
51+
5252
- name: run test (Linux)
5353
working-directory: ${{github.workspace}}/build
5454
run: ctest -T test -T Coverage
55-
55+
5656
- name: Upload coverage reports to Codecov
5757
uses: codecov/codecov-action@v3
58-
with:
58+
with:
5959
directory: ${{github.workspace}}/build
6060
gcov_ignore: ${{github.workspace}}/3rdparty
6161
verbose: true
6262
env:
6363
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
64-

‎.pre-commit-config.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
# To use:
3+
#
4+
# pre-commit run -a
5+
#
6+
# Or:
7+
#
8+
# pre-commit install # (runs every time you commit in git)
9+
#
10+
# To update this file:
11+
#
12+
# pre-commit autoupdate
13+
#
14+
# See https://github.com/pre-commit/pre-commit
15+
16+
exclude: ^data_tamer_cpp/3rdparty/
17+
repos:
18+
19+
# Standard hooks
20+
- repo: https://github.com/pre-commit/pre-commit-hooks
21+
rev: v4.5.0
22+
hooks:
23+
- id: check-added-large-files
24+
- id: check-ast
25+
- id: check-case-conflict
26+
- id: check-docstring-first
27+
- id: check-merge-conflict
28+
- id: check-symlinks
29+
- id: check-xml
30+
- id: check-yaml
31+
- id: debug-statements
32+
- id: end-of-file-fixer
33+
exclude_types: [svg]
34+
- id: mixed-line-ending
35+
- id: trailing-whitespace
36+
exclude_types: [svg]
37+
- id: fix-byte-order-marker
38+
39+
# CPP hooks
40+
- repo: https://github.com/pre-commit/mirrors-clang-format
41+
rev: v18.1.2
42+
hooks:
43+
- id: clang-format
44+
args: ['-fallback-style=none', '-i']

‎README.md

+7-11
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
[![cmake Ubuntu](https://github.com/facontidavide/data_tamer/actions/workflows/cmake_ubuntu.yml/badge.svg)](https://github.com/facontidavide/data_tamer/actions/workflows/cmake_ubuntu.yml)
44
[![ros2](https://github.com/PickNikRobotics/data_tamer/actions/workflows/ros2.yml/badge.svg)](https://github.com/PickNikRobotics/data_tamer/actions/workflows/ros2.yml)
55
[![codecov](https://codecov.io/gh/facontidavide/data_tamer/graph/badge.svg?token=D0wtsntWds)](https://codecov.io/gh/facontidavide/data_tamer)
6-
6+
77
**DataTamer** is a library to log/trace numerical variables over time and
88
takes periodic "snapshots" of their values, to later visualize them as **timeseries**.
99

1010
It works great with [PlotJuggler](https://github.com/facontidavide/PlotJuggler),
1111
the timeseries visualization tool (note: you will need PlotJuggler **3.8.2** or later).
1212

13-
**DataTamer** is "fearless data logger" because you can record hundreds or **thousands of variables**:
13+
**DataTamer** is "fearless data logger" because you can record hundreds or **thousands of variables**:
1414
even 1 million points per second should have a fairly small CPU overhead.
1515

16-
Since all the values are aggregated in a single "snapshot", it is usually meant to
16+
Since all the values are aggregated in a single "snapshot", it is usually meant to
1717
record data in a periodic loop (a very frequent use case, in robotics applications).
1818

1919
Kudos to [pal_statistics](https://github.com/pal-robotics/pal_statistics), for inspiring this project.
@@ -27,20 +27,20 @@ DataTamer can be used to monitor multiple variables in your applications.
2727
**Channels** are used to take "snapshots" of a subset of variables at a given time.
2828
If you want to record at different frequencies, you can use different channels.
2929

30-
DataTamer will forward the collected data to 1 or multiple **sinks**;
30+
DataTamer will forward the collected data to 1 or multiple **sinks**;
3131
a sink may save the information immediately in a file (currently, we support [MCAP](https://mcap.dev/))
3232
or publish it using an inter-process communication, for instance, a ROS2 publisher.
3333

3434
You can easily create your own, specialized sinks.
3535

3636
Use [PlotJuggler](https://github.com/facontidavide/PlotJuggler) to
37-
visualize your logs offline or in real-time.
37+
visualize your logs offline or in real-time.
3838

3939
## Features
4040

4141
- **Serialization schema is created at run-time**: no need to do code generation.
4242
- **Suitable for real-time applications**: very low latency (on the side of the callee).
43-
- **Multi-sink architecture**: recorded data can be forwarded to multiple "backends".
43+
- **Multi-sink architecture**: recorded data can be forwarded to multiple "backends".
4444
- **Very low serialization overhead**, in the order of 1 bit per traced value.
4545
- The user can enable/disable traced variables at run-time.
4646

@@ -176,11 +176,7 @@ cmake --build build/Debug --parallel
176176
# How to deserialize data recorded with DataTamer
177177

178178
I will write more extensively about the serialization format used by DataTamer, but for the time being I
179-
created a single header file without external dependencies that you can just copy into your project:
179+
created a single header file without external dependencies that you can just copy into your project:
180180
[data_tamer_parser.hpp](data_tamer/include/data_tamer_parser)
181181

182182
You can see how it is used in this example: [mcap_reader](data_tamer/examples/mcap_reader.cpp)
183-
184-
185-
186-

‎data_tamer_cpp/CMakeLists.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
1919
find_package(ament_cmake QUIET)
2020

2121
if (ament_cmake_FOUND)
22-
set(ROS2_SINK
22+
set(ROS2_SINK
2323
src/sinks/ros2_publisher_sink.cpp)
2424
endif()
2525

@@ -139,7 +139,7 @@ endif()
139139

140140
if(DATA_TAMER_BUILD_TESTS)
141141
include(CTest)
142-
enable_testing()
142+
enable_testing()
143143
add_subdirectory(tests)
144144
endif()
145145

@@ -153,4 +153,3 @@ if(benchmark_FOUND)
153153
else()
154154
message("Google Benchmark library not found")
155155
endif()
156-

‎data_tamer_cpp/benchmarks/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ add_executable(dt_benchmark data_tamer_benchmark.cpp)
33
target_include_directories(dt_benchmark
44
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
55
target_link_libraries(dt_benchmark data_tamer benchmark)
6-

‎data_tamer_cpp/benchmarks/data_tamer_benchmark.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@ using namespace DataTamer;
88
class NullSink : public DataSinkBase
99
{
1010
public:
11-
~NullSink() override { stopThread(); }
12-
void addChannel(std::string const&, Schema const&) override {}
13-
bool storeSnapshot(const Snapshot&) override { return true; }
11+
~NullSink() override
12+
{
13+
stopThread();
14+
}
15+
void addChannel(std::string const&, Schema const&) override
16+
{}
17+
bool storeSnapshot(const Snapshot&) override
18+
{
19+
return true;
20+
}
1421
};
1522

1623
static void DT_Doubles(benchmark::State& state)
@@ -23,7 +30,7 @@ static void DT_Doubles(benchmark::State& state)
2330

2431
channel->registerValue("values", &values);
2532

26-
for (auto _ : state)
33+
for(auto _ : state)
2734
{
2835
channel->takeSnapshot();
2936
}
@@ -39,7 +46,7 @@ static void DT_PoseType(benchmark::State& state)
3946

4047
channel->registerValue("values", &poses);
4148

42-
for (auto _ : state)
49+
for(auto _ : state)
4350
{
4451
channel->takeSnapshot();
4552
}

‎data_tamer_cpp/examples/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ else()
2929
$<BUILD_INTERFACE:${PROJECT_DIR}/3rdparty>
3030
)
3131
endif()
32-

‎data_tamer_cpp/examples/custom_types.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ int main()
3535

3636
// Note has the size of the message is almost the same as the raw data.
3737
// The only overhead is the size of points_vect
38-
size_t expected_size = sizeof(double) * 3 + // point
39-
sizeof(double) * 7 + // pose
40-
sizeof(uint32_t) + 5 * (sizeof(double) * 3) + // points_vect and its size
41-
sizeof(int32_t) * 3; // value_array
38+
size_t expected_size = sizeof(double) * 3 + // point
39+
sizeof(double) * 7 + // pose
40+
sizeof(uint32_t) +
41+
5 * (sizeof(double) * 3) + // points_vect and its size
42+
sizeof(int32_t) * 3; // value_array
4243

4344
channel->takeSnapshot();
4445
std::this_thread::sleep_for(std::chrono::milliseconds(10));

‎data_tamer_cpp/examples/geometry_types.hpp

+35-10
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,26 @@ class Vector2d
3232

3333
public:
3434
Vector2d() = default;
35-
Vector2d(double x, double y) : _x(x), _y(y) {}
35+
Vector2d(double x, double y) : _x(x), _y(y)
36+
{}
3637

37-
const double& x() const { return _x; }
38-
const double& y() const { return _y; }
38+
const double& x() const
39+
{
40+
return _x;
41+
}
42+
const double& y() const
43+
{
44+
return _y;
45+
}
3946

40-
double& x() { return _x; }
41-
double& y() { return _y; }
47+
double& x()
48+
{
49+
return _x;
50+
}
51+
double& y()
52+
{
53+
return _y;
54+
}
4255
};
4356

4457
namespace DataTamer
@@ -47,7 +60,10 @@ namespace DataTamer
4760
template <>
4861
struct TypeDefinition<Point3D>
4962
{
50-
std::string typeName() const { return "Point3D"; }
63+
std::string typeName() const
64+
{
65+
return "Point3D";
66+
}
5167

5268
template <class Function>
5369
void typeDef(Function& addField)
@@ -61,7 +77,10 @@ struct TypeDefinition<Point3D>
6177
template <>
6278
struct TypeDefinition<Quaternion>
6379
{
64-
std::string typeName() const { return "Quaternion"; }
80+
std::string typeName() const
81+
{
82+
return "Quaternion";
83+
}
6584

6685
template <class Function>
6786
void typeDef(Function& addField)
@@ -76,7 +95,10 @@ struct TypeDefinition<Quaternion>
7695
template <>
7796
struct TypeDefinition<Pose>
7897
{
79-
std::string typeName() const { return "Pose"; }
98+
std::string typeName() const
99+
{
100+
return "Pose";
101+
}
80102

81103
template <class Function>
82104
void typeDef(Function& addField)
@@ -89,7 +111,10 @@ struct TypeDefinition<Pose>
89111
template <>
90112
struct TypeDefinition<Vector2d>
91113
{
92-
std::string typeName() const { return "Vector2d"; }
114+
std::string typeName() const
115+
{
116+
return "Vector2d";
117+
}
93118

94119
// typeDef must use a different overload and x() and y() must return const reference to
95120
// a class attribute
@@ -101,4 +126,4 @@ struct TypeDefinition<Vector2d>
101126
}
102127
};
103128

104-
} // namespace DataTamer
129+
} // namespace DataTamer

0 commit comments

Comments
 (0)
Please sign in to comment.