MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ get_state()

template<typename RoutineType >
template<typename T >
T * MayaFlux::Vruta::routine_promise< RoutineType >::get_state ( const std::string &  key)
inline

Retrieves a value from the state dictionary.

Parameters
keyName of the state value to retrieve
Returns
Pointer to the stored value, or nullptr if not found or type mismatch

This method provides a type-safe way to retrieve values from the state dictionary. It returns a pointer to the stored value if it exists and has the requested type, or nullptr otherwise.

Definition at line 155 of file Promise.hpp.

156 {
157 auto it = state.find(key);
158 if (it != state.end()) {
159 try {
160 return std::any_cast<T>(&it->second);
161 } catch (const std::bad_any_cast&) {
162 return nullptr;
163 }
164 }
165 return nullptr;
166 }
std::unordered_map< std::string, std::any > state
Dictionary for storing arbitrary state data.
Definition Promise.hpp:113