C++ reflection library with focus on serialization/configuration (ROS parameter server, YAML, JSON, XML, etc)
Alexander Sherikov 21df44f48b Use find_package for msgpack | 6 months ago | |
---|---|---|
.github | 1 year ago | |
cmake | 5 months ago | |
cpput | 3 years ago | |
doc | 1 year ago | |
extra_adapters | 1 year ago | |
extra_visitors | 5 months ago | |
include | 1 year ago | |
qa | 1 year ago | |
tests | 5 months ago | |
.clang-format | 1 year ago | |
.gitignore | 3 years ago | |
.gitmodules | 4 years ago | |
.travis.yml.disable | 3 years ago | |
AUTHORS.md | 6 years ago | |
CHANGELOG.md | 5 months ago | |
CMakeLists.txt | 6 months ago | |
LICENSE | 6 years ago | |
Makefile | 5 months ago | |
README.md | 6 months ago |
branch | HEAD v2 |
pkg_catkin_2 (ROS/catkin package) |
pkg_freebsd_2 (FreeBSD package) |
---|---|---|---|
CI status | |||
package |
|
Loosely speaking, ariles
is a C++ reflection library, i.e., it provides
meta-programming APIs for implementation of class visitors (processors). It
also provides a number of (de)serializers based on these APIs, e.g., YAML
,
JSON
, XML
, ROS
parameter server; and serialization wrappers for some
types, e.g., STL
containers, smart pointers, Eigen
matrices, etc.
Parsing and generation of configuration files. Unlike some common
serialization libraries, e.g., boost::serialization
, ariles
tries to be
flexible while parsing by:
XML
,Conversion between different formats, for example, YAML
<-> ROS
parameter server. Note that the conversion is not data-agnostic, i.e., the
complete data structure must be represented in C++ code.
Flattening of a class hierarchy to a list of name-value pairs (string-double), which is useful for collection of time-series data.
Exporting of numerical data to an Octave
script for debugging purposes.
Implemetation of parsers for specific data formats, e.g., URDF
.
Class [./tests/api_v2/types/minimal.h
]:
class Configurable : public ariles2::DefaultBase
{
#define ARILES2_DEFAULT_ID "ConfigurableEntryName" // optional, defaults to 'ariles'
#define ARILES2_ENTRIES(v) \
ARILES2_TYPED_ENTRY(v, integer_member, int)
#include ARILES2_INITIALIZE
};
Serialization:
Configurable configurable;
configurable.integer_member = 10;
ariles2::apply<ariles2::yaml_cpp::Writer>("config.yaml", configurable);
ariles2::apply<ariles2::yaml_cpp::Writer>(std::cout, configurable);
Result:
ConfigurableEntryName:
integer_member: 10
Deserialization:
ariles2::apply<ariles2::yaml_cpp::Reader>("config.yaml", configurable);
Conversion:
// read class from a file
ariles2::apply<ariles2::yaml_cpp::Reader>("config.yaml", configurable);
// dump class to ROS parameter server
ariles2::apply<ariles2::rosparam::Writer>(nh, configurable, "/some_namespace/");
See demo for more exaples: https://asherikov.github.io/ariles/2/DEMO.html
[./tests/api_v2/demo_api_v2.cpp
]
ariles
includes a number of optional visitors that support various data
representation formats, in particular:
YAML
via yaml-cpp
:
https://asherikov.github.io/ariles/2/group__yaml__cpp.html.
msgpack
via msgpack-c
:
https://asherikov.github.io/ariles/2/group__msgpack.html.
JSON
via RapidJSON
, with optional Jsonnet preprocessing:
https://asherikov.github.io/ariles/2/group__rapidjson.html and
https://asherikov.github.io/ariles/2/group__jsonnet.html.
XML
via PugiXML
:
https://asherikov.github.io/ariles/2/group__pugixml.html
Octave
script, output only, no dependencies:
https://asherikov.github.io/ariles/2/group__octave.html
ROS
parameter server, via standard ROS
libs:
https://asherikov.github.io/ariles/2/group__ros.html
A set of flattened key-value pairs, output only, no dependencies: https://asherikov.github.io/ariles/2/group__namevalue.html
graphviz
dot files for diagram generation:
https://asherikov.github.io/ariles/2/group__graphviz.html
There are also a few utility visitors, e.g.,
compare
for class comparison;copyto
for copying data to non-ariles
classes;copyfrom
for copying data from non-ariles
classes.The complete list of modules is available at https://asherikov.github.io/ariles/2/modules.html
ariles
provides serialization wrappers for the follwing types:
std::string
, std::vector
, std::map
, std::pair
, std::shared_ptr
, std::unique_ptr
.Eigen
types: matrices, transforms, quaternions.Boost
classes: boost::optional
, boost::movelib::unique_ptr
. boost::shared_ptr
.cmake
>= 3.0C++11
compatible compilerboost
Visitors and corresponding dependencies can be enabled or disabled via cmake options, the same applies to data types which depend on external libraries.
An example catkin package is provided in pkg_catkin_2
branch of the main
repository -> https://github.com/asherikov/ariles/tree/pkg_catkin_2.
https://github.com/PickNikRobotics/rosparam_shortcuts: a set of wrapper
functions to read individual parameters from ROS parameter server. This tool
serves pretty much the same purpose as ariles2::rosparam::Reader
, but its
functionality is more limited.
https://billyquith.github.io/ponder/: C++14 reflection library, supports
serialization to XML and JSON. Unlike ariles
it is more focused on
reflection per se rather than applications, for example, it allows to set
value by string name of a class member, handles class methods, etc. Ponder
does not rely as much on preprocessor macro, but is more verbose.
https://github.com/bytemaster/boost_reflect: discontinued C++ reflection
library, similar to ponder
. Partially inspired ariles
2.x.x API.
https://github.com/apolukhin/magic_get (aka pfr
): C++14 library providing
tuple like methods for aggregate initializable structures. Addresses a
somewhat different but related problem.
Serialization libraries, e.g., boost::serialization
,
https://github.com/USCiLab/cereal.
A library with similar functionality in C++17 https://github.com/injae/serdepp.