Class NodeVariant

Class Documentation

class NodeVariant

A wrapper class for representing different types of nodes in the planning system.

NodeVariant encapsulates a variant type that can hold one of several node types used in the planning system, including Predicate, Function, Derived, and ActionVariant. It provides utility methods for type checking, accessing the underlying node, and retrieving node-specific information such as name and type.

The class supports hashing, equality comparison, and printing node information for debugging purposes.

This class uses a custom hash function and ‘==’ operators designed specifically for enabling the resolution of derived predicates in the correct order, which might not be suitable for other uses. For example (check the unit tests for more examples):

  • (predA ?a) == (predA ?x)

Author

Date

Note

The underlying node is stored as a shared pointer to allow for efficient copying and management.

Public Types

using NodeType = std::variant<plansys2::Predicate, plansys2::Function, plansys2::Derived, plansys2::ActionVariant>

Public Functions

template<typename NodeT>
inline NodeVariant(NodeT node)
inline size_t hash() const
inline bool operator==(const NodeVariant &other) const
inline bool operator!=(const NodeVariant &other) const
inline const NodeType &getNode() const
inline std::string getNodeName() const
inline bool isPredicate() const
inline bool isFunction() const
inline bool isDerived() const
inline bool isAction() const
inline bool isDurativeAction() const
inline bool isActionVariant() const
inline plansys2::Function &getFunctionNode() const
inline plansys2::Predicate getPredicateNode() const
inline plansys2::Derived getDerivedNode() const
inline plansys2::ActionVariant getActionVariantNode() const
inline auto &getDerivedPreconditions() const
inline auto &getDerivedPredicate() const
inline std::string getNodeType() const
inline void printNode() const

Friends

friend struct std::hash< NodeVariant >