Skip to content

Commit

Permalink
rosbag2_storage_mcap: format using ament_uncrustify
Browse files Browse the repository at this point in the history
Signed-off-by: James Smith <james@foxglove.dev>
  • Loading branch information
james-rms committed Nov 18, 2022
1 parent fbaf5a9 commit d1a3c49
Show file tree
Hide file tree
Showing 10 changed files with 341 additions and 296 deletions.
28 changes: 12 additions & 16 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,25 @@ jobs:
fail-fast: false
matrix:
linter: [cppcheck, cpplint, uncrustify]
package_name:
- rosbag2_compression
- rosbag2_compression_zstd
- rosbag2_cpp
- rosbag2_examples_cpp
- rosbag2_py
- rosbag2_storage
- rosbag2_storage_sqlite3
- rosbag2_storage_mcap
- rosbag2_test_common
- rosbag2_tests
- rosbag2_transport
exclude:
- linter: uncrustify
package_name: rosbag2_storage_mcap

steps:
- uses: actions/checkout@v2
- uses: ros-tooling/action-ros-lint@v0.1
with:
linter: ${{ matrix.linter }}
distribution: rolling
package-name: ${{ matrix.package_name }}
package-name: |
rosbag2_compression
rosbag2_compression_zstd
rosbag2_cpp
rosbag2_examples_cpp
rosbag2_py
rosbag2_storage
rosbag2_storage_sqlite3
rosbag2_storage_mcap
rosbag2_test_common
rosbag2_tests
rosbag2_transport
ament_lint_python: # Linters applicable to Python packages
name: ament_${{ matrix.linter }}
Expand Down
2 changes: 0 additions & 2 deletions CPPLINT.cfg

This file was deleted.

30 changes: 0 additions & 30 deletions rosbag2_storage_mcap/.clang-format

This file was deleted.

6 changes: 0 additions & 6 deletions rosbag2_storage_mcap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ if(BUILD_TESTING)

add_definitions(-D_TEST_RESOURCES_DIR_PATH="${CMAKE_CURRENT_SOURCE_DIR}/test/${PROJECT_NAME}")

set(ament_cmake_clang_format_CONFIG_FILE .clang-format)
list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_uncrustify)
if(WIN32)
# clang-format is not easily exposed to Windows, this linter enforced regardless via Linux/OSX builds
list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_clang_format)
endif()
ament_lint_auto_find_test_dependencies()

ament_add_gmock(test_mcap_storage test/rosbag2_storage_mcap/test_mcap_storage.cpp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,51 @@
#include <unordered_set>
#include <utility>

namespace rosbag2_storage_mcap::internal {
namespace rosbag2_storage_mcap::internal
{

enum struct Format {
enum struct Format
{
IDL,
MSG,
};

struct MessageSpec {
MessageSpec(Format format, std::string text, const std::string& package_context);
struct MessageSpec
{
MessageSpec(Format format, std::string text, const std::string & package_context);
const std::set<std::string> dependencies;
const std::string text;
Format format;
};

struct DefinitionIdentifier {
struct DefinitionIdentifier
{
Format format;
std::string package_resource_name;

bool operator==(const DefinitionIdentifier& di) const {
bool operator==(const DefinitionIdentifier & di) const
{
return (format == di.format) && (package_resource_name == di.package_resource_name);
}
};

class DefinitionNotFoundError : public std::exception {
class DefinitionNotFoundError : public std::exception
{
private:
std::string name_;

public:
explicit DefinitionNotFoundError(std::string name)
: name_(std::move(name)) {}
: name_(std::move(name)) {}

const char* what() const noexcept override {
const char * what() const noexcept override
{
return name_.c_str();
}
};

class MessageDefinitionCache final {
class MessageDefinitionCache final
{
public:
/**
* Concatenate the message definition with its dependencies into a self-contained schema.
Expand All @@ -70,11 +78,13 @@ class MessageDefinitionCache final {
* package resource name.
*/
ROSBAG2_STORAGE_MCAP_PUBLIC
std::pair<Format, std::string> get_full_text(const std::string& package_resource_name);
std::pair<Format, std::string> get_full_text(const std::string & package_resource_name);

private:
struct DefinitionIdentifierHash {
std::size_t operator()(const DefinitionIdentifier& di) const {
struct DefinitionIdentifierHash
{
std::size_t operator()(const DefinitionIdentifier & di) const
{
std::size_t h1 = std::hash<Format>()(di.format);
std::size_t h2 = std::hash<std::string>()(di.package_resource_name);
return h1 ^ h2;
Expand All @@ -84,15 +94,16 @@ class MessageDefinitionCache final {
* Load and parse the message file referenced by the given datatype, or return it from
* msg_specs_by_datatype
*/
const MessageSpec& load_message_spec(const DefinitionIdentifier& definition_identifier);
const MessageSpec & load_message_spec(const DefinitionIdentifier & definition_identifier);

std::unordered_map<DefinitionIdentifier, MessageSpec, DefinitionIdentifierHash>
msg_specs_by_definition_identifier_;
msg_specs_by_definition_identifier_;
};

ROSBAG2_STORAGE_MCAP_PUBLIC
std::set<std::string> parse_dependencies(Format format, const std::string& text,
const std::string& package_context);
std::set<std::string> parse_dependencies(
Format format, const std::string & text,
const std::string & package_context);

} // namespace rosbag2_storage_mcap::internal

Expand Down
1 change: 0 additions & 1 deletion rosbag2_storage_mcap/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<depend>rcutils</depend>
<depend>rosbag2_storage</depend>

<test_depend>ament_cmake_clang_format</test_depend>
<test_depend>ament_cmake_gmock</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
Loading

0 comments on commit d1a3c49

Please sign in to comment.