Controller Plugin Project
Directory Structure
Mainly divided into third-party libraries, configuration files, usage examples, main code src, and xcore api
example
├──3rdparty/
├──config/
├──examples/
├──src/
├──xcore_api/
├──CMakeLists.txt
└──README.md
Third-party Libraries
Mainly includes commonly used third-party libraries: g3log, jsoncpp, gtest, etc. Plugins only need to use the header files of third-party libraries. To facilitate users using third-party libraries separately, corresponding lib packages are provided. Users can link the corresponding libraries to form executable programs and run them independently. Later, we will introduce the usage of commonly used log libraries and json libraries.
Config Directory
All files in this directory will be packaged into the Plugin's binary data. Files can be read directly through the cmrc interface.
CMRC_DECLARE(cmrc_config);
auto cmrc_fs = cmrc::cmrc_config::get_filesystem();
// All json files in the conf_data directory
auto file_path = "cmrc_config/conf_data/" + dir_in_conf_data;
for (auto&& entry : cmrc_fs.iterate_directory(file_path)) {
Json::Value root;
auto json_file = cmrc_fs.open(file_path + entry.filename());
auto json_str = std::string(json_file.begin(), json_file.end());
xcore_api::utils::LoadFromStringAPI(root,json_str);
ret[dir_in_conf_data + entry.filename()] = root;
}
Examples Directory
Contains usage examples of the Plugin. Users can refer to these examples to understand how to use the API. example_launch is the entry point for these examples.
Src Directory
The main body of the Plugin program code. Users can add their own programs to this directory. Currently, the launch module is built-in as the Plugin's entry program. Users can add their own implementation logic in this directory.
xcore_api Directory
Interfaces encapsulated by the Controller. Users can use Controller functions through these interfaces.