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 156 of file Promise.hpp.

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