|
| | Map () |
| | Default constructor.
|
| |
| | Map (const Map ©) |
| | Copy constructor.
|
| |
| | Map (Map &&move) |
| | Move constructor.
|
| |
| virtual | ~Map () |
| | Destructor.
|
| |
| std::unique_ptr< Core::Base > | clone () const override |
| |
| virtual const Infinity::Types::TypeID & | typeId () const override |
| | Gets the TypeID for Map.
|
| |
| Map & | operator= (const Map ©) |
| | Copy assignment operator.
|
| |
| Map & | operator= (Map &&move) |
| | Move assignment operator.
|
| |
| bool | hasKey (const std::string &key) const |
| | Checks if a key exists in the map.
|
| |
| bool | hasValueAtKey (const std::string &key) const |
| | Checks if a key exists and contains a plain value (POD type).
|
| |
| void | set (const std::string &key, std::shared_ptr< Core::Data > data) |
| | Sets a key-value pair from a type-erased Data pointer.
|
| |
| template<typename T > |
| void | set (const std::string &key, const T &data) |
| | Sets a key-value pair with automatic type wrapping (copy, const reference).
|
| |
| template<typename T > |
| void | set (const std::string &key, T &data) |
| | Sets a key-value pair with automatic type wrapping (copy, non-const reference).
|
| |
| template<typename T > |
| void | set (const std::string &key, T &&data) |
| | Sets a key-value pair with automatic type wrapping (move).
|
| |
| const Core::Data * | get (const std::string &key) const |
| | Gets a type-erased const pointer to the value at the specified key.
|
| |
| template<typename T > |
| T & | get (const std::string &key) |
| | Gets a mutable typed reference to the value at the specified key.
|
| |
| template<typename T > |
| const T & | get (const std::string &key) const |
| | Gets a const typed reference to the value at the specified key.
|
| |
| template<typename T > |
| T & | getValue (const std::string &key) |
| | Gets a mutable reference to the underlying value from a Value<T> wrapper.
|
| |
| template<typename T > |
| const T & | getValue (const std::string &key) const |
| | Gets a const reference to the underlying value from a Value<T> wrapper.
|
| |
| void | clear () |
| | Removes all key-value pairs from the map.
|
| |
| size_t | size () const noexcept |
| | Gets the number of key-value pairs in the map.
|
| |
| | Data () |
| |
| | Data (const Data &other) |
| |
| | Data (Data &&other) |
| |
| Data & | operator= (const Data &other) |
| |
| Data & | operator= (Data &&other) |
| |
| virtual | ~Data () |
| | Virtual destructor.
|
| |
| bool | hasProperty (const std::string &key) const |
| |
| template<typename T > |
| void | setProperty (const std::string &key, T &&value) |
| | Sets a typed property value.
|
| |
| template<typename T > |
| void | setProperty (const std::string &key, const T &value) |
| | Sets a typed property value.
|
| |
| void | setProperty (const std::string &key, PropertyValue &&value) |
| | Sets a typed property value.
|
| |
| const PropertyValue & | getProperty (const std::string &key) const |
| | Gets a property value without type checking.
|
| |
| template<typename T > |
| const T & | getProperty (const std::string &key) const |
| | Gets a typed property value.
|
| |
| void | removeProperty (const std::string &key) |
| |
| virtual | ~Base () |
| | Virtual destructor.
|
| |
| virtual std::istream & | legibleDataRead (std::istream &in) override |
| | Deserializes the object from a single-line text representation.
|
| |
| virtual std::ostream & | legibleDataWrite (std::ostream &out) const override |
| | Serializes the object to a single-line text representation.
|
| |
Mutable heterogeneous key-value container for dynamic data structures.
Map provides a dictionary-like container that stores string-keyed values of heterogeneous types with full mutability. Unlike ImmutableMap, Map stores shared_ptr<Data> (non-const), allowing stored values to be modified after insertion. This makes it suitable for:
- Dynamic runtime state that changes during execution
- Mutable component properties and settings
- Cache and temporary storage during procedural generation
- Accumulator patterns for iterative algorithms
- Shared state between multiple components
The map automatically handles type wrapping, storing POD types as Value<T> and Data-derived types directly. It provides both const and non-const accessors, enabling full read-write access to stored values.
Key features:
- Heterogeneous storage with different value types in the same map
- Type-safe retrieval with automatic unwrapping
- Mutable access to stored values (unlike ImmutableMap)
- Automatic Value<T> wrapping for POD types
- Full serialization support (read/write/wrap)
- Integration with ProceduralSystem input/output ports
- Move semantics for efficient large object storage
- Shared ownership of stored data
The key difference from ImmutableMap is mutability: stored values can be retrieved as non-const references and modified in place, making Map ideal for dynamic runtime state rather than static configuration.
- Note
- Keys are case-sensitive strings.
-
Attempting to retrieve a non-existent key throws std::out_of_range.
-
Use hasKey() to safely check for key existence before retrieval.
-
Multiple maps can share references to the same data objects.
Example usage:
state.
set(
"iteration", 0);
state.
set(
"total_volume", 0.0f);
state.
set(
"active",
true);
int& iter = state.
get<
int>(
"iteration");
iter++;
float& volume = state.
get<
float>(
"total_volume");
volume += calculateVolume();
state.
set(
"control_points", std::move(points));
system->setIn("runtime_state", std::move(state));
accumulator.
set(
"sum", 0.0f);
accumulator.
set(
"count", 0);
for (const auto& value : values) {
accumulator.
get<
float>(
"sum") += value;
accumulator.
get<
int>(
"count")++;
}
Dynamic contiguous container for homogeneous elements in the Infinity type system.
Definition Array.hpp:77
void push_back(const T &value)
Appends an element to the end of the array.
Definition Array.hpp:333
Mutable heterogeneous key-value container for dynamic data structures.
Definition Map.hpp:92
void set(const std::string &key, std::shared_ptr< Core::Data > data)
Sets a key-value pair from a type-erased Data pointer.
const Core::Data * get(const std::string &key) const
Gets a type-erased const pointer to the value at the specified key.