20#include "auto_apms_behavior_tree_core/definitions.hpp"
21#include "auto_apms_behavior_tree_core/node/node_registration_options.hpp"
22#include "auto_apms_util/exceptions.hpp"
23#include "auto_apms_util/yaml.hpp"
68 std::string
str()
const;
90 const std::set<std::string> & exclude_packages = {});
138 using Map = std::map<std::string, NodeRegistrationOptions>;
171 void toFile(
const std::string & file_path)
const;
178 bool contains(
const std::string & node_name)
const;
186 RegistrationOptions &
operator[](
const std::string & node_name);
189 const RegistrationOptions &
operator[](
const std::string & node_name)
const;
199 NodeManifest &
add(
const std::string & node_name,
const RegistrationOptions & opt);
302 Identity unique_identity_;
303 std::string node_manifest_file_path_;
305 std::string node_model_file_path_;
322 static Node encode(
const Identity & rhs)
328 static bool decode(
const Node & node, Identity & rhs)
330 if (!node.IsScalar())
return false;
331 rhs = Identity(node.Scalar());
336struct convert<auto_apms_behavior_tree::core::NodeManifest>
338 using Manifest = auto_apms_behavior_tree::core::NodeManifest;
339 inline static Node encode(
const Manifest & rhs)
341 Node node(NodeType::Map);
342 for (
const auto & [name, params] : rhs.map()) node[name] = params;
345 inline static bool decode(
const Node & node, Manifest & rhs)
348 throw auto_apms_util::exceptions::YAMLFormatError(
349 "YAML::Node for auto_apms_behavior_tree::core::NodeManifest must be map but is type " +
350 std::to_string(node.Type()) +
" (0: Undefined - 1: Null - 2: Scalar - 3: Sequence - 4: Map).");
352 for (
auto it = node.begin(); it != node.end(); ++it) {
353 const auto & name = it->first.as<std::string>();
355 rhs.add(name, it->second.as<Manifest::RegistrationOptions>());
356 }
catch (
const std::exception & e) {
357 throw auto_apms_util::exceptions::YAMLFormatError(
358 "Node registration options for node '" + name +
"' are invalid: " + e.what());
NodeManifestResource(const Identity &search_identity)
Constructor of a node manifest resource object.
const NodeModelMap & getNodeModel() const
Get the node model object associated with this resource.
const Identity & getIdentity() const
Get the unique identity for this resource.
const NodeManifest & getNodeManifest() const
Get the node manifest object associated with this resource.
Data structure for information about which behavior tree node plugin to load and how to configure the...
std::map< std::string, NodeRegistrationOptions > Map
Mapping of a node's name and its registration parameters.
static NodeManifest fromFiles(const std::vector< std::string > &paths)
Create a node plugin manifest from multiple files. They are loaded in the given order.
size_t size() const
Get the number of behavior tree nodes this manifest holds registration options for.
NodeManifest & add(const std::string &node_name, const RegistrationOptions &opt)
Add registration options for a behavior tree node to the manifest.
bool contains(const std::string &node_name) const
Determine if a behavior tree node has been added to the manifest.
bool empty() const
Determine whether any node registration options have been added to the manifest.
NodeManifest & merge(const NodeManifest &other, bool replace=false)
Merges another NodeManifest with this one.
const Map & map() const
Get a view of the internal map.
std::vector< std::string > getNodeNames()
Get all names of the behavior tree nodes specified by the manifest.
RegistrationOptions & operator[](const std::string &node_name)
Access the node manifest and retrieve registration options for a specific behavior tree node.
void toFile(const std::string &file_path) const
Write the node manifest to a file.
NodeManifest(const Map &map={})
Constructor of a NodeManifest data structure.
static NodeManifest fromResource(const NodeManifestResourceIdentity &search_identity)
Create a node manifest from an installed resource.
NodeManifest & remove(const std::string &node_name)
Remove registration options for a behavior tree node.
std::set< NodeManifestResourceIdentity > getNodeManifestResourceIdentities(const std::set< std::string > &exclude_packages={})
Get all registered behavior tree node manifest resource identities.
#define AUTO_APMS_UTIL_DEFINE_YAML_CONVERSION_METHODS(ClassType)
Macro for defining YAML encode/decode methods for a class.
Core API for AutoAPMS's behavior tree implementation.
Powerful tooling for incorporating behavior trees for task development.
std::map< std::string, NodeModel > NodeModelMap
Mapping of node registration names and their implementation details.
Struct that encapsulates the identity string for a registered behavior tree node manifest.
bool empty() const
Determine whether this node manifest resource identity object is considered empty.
NodeManifestResourceIdentity(const std::string &identity)
Constructor of a node manifest resource identity object.
NodeManifestResourceIdentity()=default
Constructor of an empty node manifest resource identity object.
std::string package_name
Name of the package that registers the behavior resource.
std::string metadata_id
Metadata ID determined when regitering the corresponding node manifest resource.
std::string str() const
Create the corresponding identity string.
Parameters for loading and registering a behavior tree node class from a shared library using e....