A type-erased container for orchestration operands with runtime type checking.
More...
#include <operand_bundle.hpp>
|
| using | iterator = std::unordered_map< std::string, std::any >::iterator |
| |
| using | const_iterator = std::unordered_map< std::string, std::any >::const_iterator |
| |
|
| | OperandBundle ()=default |
| |
| iterator | begin () noexcept |
| |
| iterator | end () noexcept |
| |
| const_iterator | begin () const noexcept |
| |
| const_iterator | end () const noexcept |
| |
| const_iterator | cbegin () const noexcept |
| |
| const_iterator | cend () const noexcept |
| |
| std::optional< std::any > | get (const std::string &key) const |
| | Retrieves an operand value as std::any.
|
| |
| template<typename T > |
| std::optional< T > | get_unwrapped (const std::string &key) const |
| | Retrieves and casts an operand value to the specified type.
|
| |
| std::size_t | size () const |
| | Returns the number of operands stored in the bundle.
|
| |
| void | put (const std::string &key, const std::any &value) |
| | Stores an operand value with the given key.
|
| |
| bool | contains (const std::string &key) const |
| | Checks if an operand with the given key exists.
|
| |
| std::optional< std::type_index > | type_index_of (const std::string &key) const |
| | Retrieves the runtime type information for an operand.
|
| |
| bool | satisfies_declarations (const std::vector< OperandDeclaration > &declarations) const |
| | Validates that the bundle satisfies a set of operand declarations.
|
| |
A type-erased container for orchestration operands with runtime type checking.
OperandBundle provides a key-value store that can hold operands of any type using std::any. It supports type-safe retrieval, validation against OperandDeclaration specifications, and range-based iteration. This class is primarily used by the orchestration framework to pass data between Operation instances while maintaining type safety at runtime.
Definition at line 25 of file operand_bundle.hpp.
◆ const_iterator
◆ iterator
◆ OperandBundle()
| porytiles2::OperandBundle::OperandBundle |
( |
| ) |
|
|
default |
◆ begin() [1/2]
◆ begin() [2/2]
◆ cbegin()
◆ cend()
◆ contains()
| bool porytiles2::OperandBundle::contains |
( |
const std::string & |
key | ) |
const |
Checks if an operand with the given key exists.
- Parameters
-
| key | The string key to check for existence |
- Returns
- true if the key exists in the bundle, false otherwise
Definition at line 58 of file operand_bundle.cpp.
◆ end() [1/2]
◆ end() [2/2]
◆ get()
| std::optional< std::any > porytiles2::OperandBundle::get |
( |
const std::string & |
key | ) |
const |
Retrieves an operand value as std::any.
Returns the operand associated with the given key wrapped in std::optional. If the key does not exist, returns std::nullopt.
- Parameters
-
| key | The string key identifying the operand |
- Returns
- std::optional<std::any> containing the value if found, std::nullopt otherwise
Definition at line 40 of file operand_bundle.cpp.
◆ get_unwrapped()
template<typename T >
| std::optional< T > porytiles2::OperandBundle::get_unwrapped |
( |
const std::string & |
key | ) |
const |
|
inline |
Retrieves and casts an operand value to the specified type.
Performs type-safe retrieval and casting of an operand value. If the key exists but the stored type does not match T, the function will panic. If the key does not exist, returns std::nullopt.
- Template Parameters
-
| T | The expected type of the operand |
- Parameters
-
| key | The string key identifying the operand |
- Precondition
- If key exists, the stored type must match T
- Returns
- std::optional<T> containing the cast value if found and type matches
Definition at line 66 of file operand_bundle.hpp.
◆ put()
| void porytiles2::OperandBundle::put |
( |
const std::string & |
key, |
|
|
const std::any & |
value |
|
) |
| |
Stores an operand value with the given key.
Inserts or updates an operand in the bundle. If the key already exists, the previous value is replaced.
- Parameters
-
| key | The string key to associate with the value |
| value | The operand value to store (type-erased as std::any) |
Definition at line 53 of file operand_bundle.cpp.
◆ satisfies_declarations()
| bool porytiles2::OperandBundle::satisfies_declarations |
( |
const std::vector< OperandDeclaration > & |
declarations | ) |
const |
Validates that the bundle satisfies a set of operand declarations.
Checks that all required operands specified in the declarations are present in the bundle and have the correct types. This is used by the orchestration framework to validate Operation inputs and outputs.
- Parameters
-
- Returns
- true if all declarations are satisfied, false otherwise
Definition at line 71 of file operand_bundle.cpp.
◆ size()
| std::size_t porytiles2::OperandBundle::size |
( |
| ) |
const |
Returns the number of operands stored in the bundle.
- Returns
- The count of key-value pairs in the bundle
Definition at line 48 of file operand_bundle.cpp.
◆ type_index_of()
| std::optional< std::type_index > porytiles2::OperandBundle::type_index_of |
( |
const std::string & |
key | ) |
const |
Retrieves the runtime type information for an operand.
Returns the std::type_index of the value stored at the given key. This is useful for runtime type checking and validation.
- Parameters
-
| key | The string key identifying the operand |
- Returns
- std::optional<std::type_index> containing the type if key exists, std::nullopt otherwise
Definition at line 63 of file operand_bundle.cpp.
The documentation for this class was generated from the following files: