Skip to content

Commit e3b10c3

Browse files
committed
Merge remote-tracking branch 'remote2/develop' into develop
2 parents 0f1c1f1 + 34ba2a0 commit e3b10c3

21 files changed

+907
-0
lines changed

docs/module-mola-yaml.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. _mola-yaml:
2+
3+
====================
4+
Module: mola-yaml
5+
====================
6+
7+
YAML helper C++ library common to all MOLA modules, released under BSD-3-Clause.
8+
9+
This module implements the YAML extensions explained in: :ref:`yaml_slam_cfg_file`.

mola_yaml/.clang-format

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
Language: Cpp
2+
BasedOnStyle: Google
3+
# ---
4+
#AccessModifierOffset: -4
5+
AlignAfterOpenBracket: AlwaysBreak # Values: Align, DontAlign, AlwaysBreak
6+
AlignConsecutiveAssignments: true
7+
AlignConsecutiveDeclarations: true
8+
#AlignEscapedNewlinesLeft: true
9+
#AlignOperands: false
10+
AlignTrailingComments: false # Should be off, causes many dummy problems!!
11+
#AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: true
13+
#AllowShortCaseLabelsOnASingleLine: false
14+
#AllowShortFunctionsOnASingleLine: Empty
15+
#AllowShortIfStatementsOnASingleLine: false
16+
#AllowShortLoopsOnASingleLine: false
17+
#AlwaysBreakAfterDefinitionReturnType: None
18+
#AlwaysBreakAfterReturnType: None
19+
#AlwaysBreakBeforeMultilineStrings: true
20+
#AlwaysBreakTemplateDeclarations: true
21+
#BinPackArguments: false
22+
#BinPackParameters: false
23+
#BraceWrapping:
24+
#AfterClass: false
25+
#AfterControlStatement: false
26+
#AfterEnum: false
27+
#AfterFunction: false
28+
#AfterNamespace: false
29+
#AfterObjCDeclaration: false
30+
#AfterStruct: false
31+
#AfterUnion: false
32+
#BeforeCatch: false
33+
#BeforeElse: true
34+
#IndentBraces: false
35+
#BreakBeforeBinaryOperators: None
36+
BreakBeforeBraces: Allman
37+
#BreakBeforeTernaryOperators: true
38+
#BreakConstructorInitializersBeforeComma: false
39+
ColumnLimit: 80
40+
#CommentPragmas: ''
41+
#ConstructorInitializerAllOnOneLineOrOnePerLine: true
42+
#ConstructorInitializerIndentWidth: 4
43+
#ContinuationIndentWidth: 4
44+
#Cpp11BracedListStyle: true
45+
#DerivePointerAlignment: false
46+
#DisableFormat: false
47+
#ExperimentalAutoDetectBinPacking: false
48+
##FixNamespaceComments: true # Not applicable in 3.8
49+
#ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
50+
#IncludeCategories:
51+
#- Regex: '.*'
52+
#Priority: 1
53+
IndentCaseLabels: true
54+
IndentWidth: 4
55+
IndentWrappedFunctionNames: true
56+
#KeepEmptyLinesAtTheStartOfBlocks: true
57+
#MacroBlockBegin: ''
58+
#MacroBlockEnd: ''
59+
MaxEmptyLinesToKeep: 1
60+
NamespaceIndentation: None
61+
#PenaltyBreakBeforeFirstCallParameter: 19
62+
#PenaltyBreakComment: 300
63+
#PenaltyBreakFirstLessLess: 120
64+
#PenaltyBreakString: 1000
65+
#PenaltyExcessCharacter: 1000000
66+
#PenaltyReturnTypeOnItsOwnLine: 200
67+
DerivePointerAlignment: false
68+
#PointerAlignment: Left
69+
ReflowComments: true # Should be true, otherwise clang-format doesn't touch comments
70+
SortIncludes: true
71+
#SpaceAfterCStyleCast: false
72+
SpaceBeforeAssignmentOperators: true
73+
#SpaceBeforeParens: ControlStatements
74+
#SpaceInEmptyParentheses: false
75+
#SpacesBeforeTrailingComments: 2
76+
#SpacesInAngles: false
77+
#SpacesInContainerLiterals: true
78+
#SpacesInCStyleCastParentheses: false
79+
#SpacesInParentheses: false
80+
#SpacesInSquareBrackets: false
81+
Standard: Cpp11
82+
TabWidth: 4
83+
UseTab: Never # Available options are Never, Always, ForIndentation

mola_yaml/CHANGELOG.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2+
Changelog for package mola_yaml
3+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
5+
0.2.2 (2023-09-08)
6+
------------------
7+
* Fix package name in docs
8+
* Contributors: Jose Luis Blanco-Claraco
9+
10+
0.2.1 (2023-09-02)
11+
------------------
12+
13+
0.2.0 (2023-08-24)
14+
------------------
15+
* First public release as ROS 2 package.

mola_yaml/CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# ------------------------------------------------------------------------------
2+
# A Modular Optimization framework for Localization and mApping
3+
# (MOLA)
4+
#
5+
# Copyright (C) 2018-2023, Jose Luis Blanco-Claraco, contributors (AUTHORS.md)
6+
# All rights reserved.
7+
# Released under GNU GPL v3. See LICENSE file
8+
# ------------------------------------------------------------------------------
9+
10+
# Minimum CMake vesion: limited by CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
11+
cmake_minimum_required(VERSION 3.4)
12+
13+
# Tell CMake we'll use C++ for use in its tests/flags
14+
project(mola_yaml LANGUAGES CXX)
15+
16+
# MOLA CMake scripts: "mola_xxx()"
17+
find_package(mola_common REQUIRED)
18+
19+
# find dependencies:
20+
find_package(MRPT 2.1.0 REQUIRED COMPONENTS containers system)
21+
22+
# define lib:
23+
file(GLOB_RECURSE LIB_SRCS src/*.cpp src/*.h)
24+
file(GLOB_RECURSE LIB_PUBLIC_HDRS include/*.h)
25+
26+
# Use C++17 filesystem lib:
27+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
28+
find_package(Filesystem REQUIRED)
29+
30+
mola_add_library(
31+
TARGET ${PROJECT_NAME}
32+
SOURCES ${LIB_SRCS} ${LIB_PUBLIC_HDRS}
33+
PUBLIC_LINK_LIBRARIES
34+
mrpt::containers
35+
PRIVATE_LINK_LIBRARIES
36+
mrpt::system
37+
CXX::Filesystem # the C++>=17 std lib
38+
CMAKE_DEPENDENCIES
39+
mrpt-containers
40+
mrpt-system
41+
)
42+
43+
# -----------------------
44+
# define tests:
45+
enable_testing()
46+
add_subdirectory(tests)

mola_yaml/LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2021, The MOLA SLAM framework
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

mola_yaml/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# mola_yaml
2+
YAML helper library common to MOLA modules. A C++ library to parse YAML files with extended syntax allowing variable replacing, recursive `include`s of other YAML files, etc.
3+
4+
## Build and install
5+
Refer to the [root MOLA repository](https://github.com/MOLAorg/mola).
6+
7+
## Docs and examples
8+
See this package page [in the documentation](https://docs.mola-slam.org/latest/modules.html).
9+
10+
## License
11+
This package is released under the BSD-3 license.

mola_yaml/cmake/FindFilesystem.cmake

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# This is from https://github.com/vector-of-bool/pitchfork/blob/develop/cmake/FindFilesystem.cmake
2+
3+
include(CMakePushCheckState)
4+
include(CheckIncludeFileCXX)
5+
include(CheckCXXSourceCompiles)
6+
7+
cmake_push_check_state(RESET)
8+
9+
# this seems not to affect check_cxx_source_compiles()...
10+
set(CMAKE_CXX_STANDARD 17)
11+
12+
if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
13+
set(CMAKE_REQUIRED_LINK_OPTIONS -std=c++17)
14+
set(CMAKE_REQUIRED_FLAGS -std=c++17)
15+
endif()
16+
17+
set(have_fs FALSE)
18+
19+
check_include_file_cxx("filesystem" HAVE_STD_FILESYSTEM)
20+
check_include_file_cxx("experimental/filesystem" HAVE_STD_EXPERIMENTAL_FILESYSTEM)
21+
22+
if(HAVE_STD_FILESYSTEM)
23+
set(have_fs TRUE)
24+
set(header filesystem)
25+
set(namespace std::filesystem)
26+
elseif(HAVE_STD_EXPERIMENTAL_FILESYSTEM)
27+
set(have_fs TRUE)
28+
set(header experimental/filesystem)
29+
set(namespace std::experimental::filesystem)
30+
endif()
31+
32+
string(CONFIGURE [[
33+
#include <@header@>
34+
35+
int main() {
36+
auto cwd = @namespace@::current_path();
37+
return cwd.string().size();
38+
}
39+
]] code @ONLY)
40+
41+
check_cxx_source_compiles("${code}" CAN_COMPILE_FS_WITHOUT_LINK)
42+
43+
if(NOT CAN_COMPILE_FS_WITHOUT_LINK)
44+
set(CMAKE_REQUIRED_LIBRARIES -lstdc++fs)
45+
check_cxx_source_compiles("${code}" CAN_COMPILE_FS_WITH_LINK)
46+
endif()
47+
48+
cmake_pop_check_state()
49+
50+
if(have_fs)
51+
add_library(CXX::Filesystem INTERFACE IMPORTED)
52+
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
53+
target_compile_definitions(CXX::Filesystem INTERFACE STD_FS_IS_EXPERIMENTAL=$<NOT:$<BOOL:${HAVE_STD_FILESYSTEM}>>)
54+
else()
55+
set_property(TARGET CXX::Filesystem APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS STD_FS_IS_EXPERIMENTAL=$<NOT:$<BOOL:${HAVE_STD_FILESYSTEM}>>)
56+
endif()
57+
58+
if(CAN_COMPILE_FS_WITHOUT_LINK)
59+
# Nothing to add...
60+
elseif(CAN_COMPILE_FS_WITH_LINK)
61+
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
62+
target_link_libraries(CXX::Filesystem INTERFACE -lstdc++fs)
63+
else()
64+
set_property(TARGET CXX::Filesystem APPEND PROPERTY INTERFACE_LINK_LIBRARIES stdc++fs)
65+
endif()
66+
else()
67+
message(WARNING "Failed to link a filesystem library, although we found the headers...?")
68+
endif()
69+
set(Filesystem_FOUND TRUE CACHE BOOL "" FORCE)
70+
else()
71+
set(Filesystem_FOUND FALSE CACHE BOOL "" FORCE)
72+
if(Filesystem_FIND_REQUIRED)
73+
message(FATAL_ERROR "No C++ support for std::filesystem")
74+
endif()
75+
endif()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* -------------------------------------------------------------------------
2+
* A Modular Optimization framework for Localization and mApping (MOLA)
3+
* Copyright (C) 2018-2023 Jose Luis Blanco, University of Almeria
4+
* See LICENSE for license information.
5+
* ------------------------------------------------------------------------- */
6+
/**
7+
* @file macro_helpers.h
8+
* @brief C preprocessor helpers
9+
* @author Jose Luis Blanco Claraco
10+
* @date Jan 11, 2019
11+
*/
12+
#pragma once
13+
14+
// The following is taken from a great answer here:
15+
// https://stackoverflow.com/a/26408195/1631514
16+
17+
// get number of arguments with MOLA_NARG
18+
#define MOLA_NARG(...) MOLA_NARG_I_(__VA_ARGS__, MOLA_RSEQ_N())
19+
#define MOLA_NARG_I_(...) MOLA_ARG_N(__VA_ARGS__)
20+
#define MOLA_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
21+
#define MOLA_RSEQ_N() 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
22+
23+
// general definition for any function name
24+
#define MOLA_VFUNC_(name, n) name##n
25+
#define MOLA_VFUNC(name, n) MOLA_VFUNC_(name, n)
26+
#define VFUNC(func, ...) MOLA_VFUNC(func, MOLA_NARG(__VA_ARGS__))(__VA_ARGS__)

0 commit comments

Comments
 (0)