Class EnvironmentManager
Defined in File EnvironmentManager.cuh
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public std::enable_shared_from_this< EnvironmentManager >
Class Documentation
-
class EnvironmentManager : public std::enable_shared_from_this<EnvironmentManager>
This class manages the regular (not macro) environment properties for a single simulation instance
It packs properties into a compact cache, which can be copied to device memory for use with DeviceEnvironment When properties are mapped between submodels, a weak_ptr is held in the mapping where necessary to allow updates to propagate Propogation is carried out, by first following the chain up through parents, and then updating all direct children of the property from that parent
Public Functions
-
~EnvironmentManager()
-
EnvironmentManager(EnvironmentManager const&) = delete
-
void operator=(EnvironmentManager const&) = delete
-
template<typename T>
T setProperty(const std::string &name, T value) Sets an environment property
Setters
- Parameters:
name – name used for accessing the property
value – value to set the property
- Template Parameters:
T – Type of the environmental property array to be created
- Throws:
exception::InvalidEnvProperty – If a property of the name does not exist
exception::ReadOnlyEnvProperty – If the named property is marked as const
- Returns:
Returns the previous value
-
template<typename T, size_type N>
std::array<T, N> setProperty(const std::string &name, const std::array<T, N> &value) Sets an environment property array
- Parameters:
name – name used for accessing the property array
value – value to set the property array
- Template Parameters:
T – Type of the environmental property array to be created
N – Length of the environmental property array to be created
- Throws:
exception::InvalidEnvProperty – If a property of the name does not exist
exception::ReadOnlyEnvProperty – If the named property is marked as const
- Returns:
Returns the previous value
-
template<typename T, size_type N = 0>
T setProperty(const std::string &name, size_type index, T value) Sets an element of an environment property array
- Parameters:
name – name used for accessing the property array
index – Index of the element within the array
value – value to set the element of the property array
- Template Parameters:
T – Type of the environmental property array to be created
N – (Optional) The length of the array variable, available for parity with other APIs, checked if provided
- Throws:
exception::InvalidEnvProperty – If a property of the name does not exist
std::out_of_range –
- Returns:
Returns the previous value
-
template<typename T>
T getProperty(const std::string &name) Gets an environment property
Getters
See also
get(const NamePair &)
- Parameters:
name – name used for accessing the property
- Template Parameters:
T – Type of the environmental property array to be created
- Throws:
exception::InvalidEnvProperty – If a property of the name does not exist
-
template<typename T, size_type N>
std::array<T, N> getProperty(const std::string &name) Gets an environment property array
- Parameters:
name – name used for accessing the property array
- Template Parameters:
T – Type of the environmental property array to be created
N – Length of the environmental property array to be created
- Throws:
exception::InvalidEnvProperty – If a property array of the name does not exist
-
template<typename T, size_type N = 0>
T getProperty(const std::string &name, size_type index) Gets an element of an environment property array
- Parameters:
name – name used for accessing the property array
index – Index of the element within the array
- Template Parameters:
T – Type of the value to be returned
N – (Optional) The length of the array variable, available for parity with other APIs, checked if provided
- Throws:
exception::InvalidEnvProperty – If a property of the name does not exist
std::out_of_range –
-
void resetModel(const EnvironmentData &desc)
Returns all environment properties owned by a model to their default values This means that properties inherited by a submodel will not be reset to their default values
- Parameters:
desc – The environment description (this is where the defaults are pulled from)
-
void updateDevice_async(cudaStream_t stream) const
Copies the environment property cache to a device buffer
- Parameters:
stream – Cuda stream to perform memcpys on
-
inline size_t getBufferLen() const
Returns the minimum buffer size required to call updateDevice_async()
- Returns:
The size of h_buffer
-
inline const void *getHostBuffer() const
Used by IO methods to efficiently access environment
-
inline const void *getDeviceBuffer() const
Used by agent functions to access the environment
Public Static Functions
-
static inline std::shared_ptr<EnvironmentManager> create(const EnvironmentData &desc)
Initialises a model’s environment property cache
- Parameters:
desc – environment properties description to use
Initialises a submodel’s environment property cache Links a submodel’s mapped environment properties with their master property
- Parameters:
desc – environment properties description to use
parent_environment – EnvironmentManager of the parent of the submodel, used to initialise mappings
mapping – Metadata for which environment properties are mapped between master and submodels
Friends
- friend class flamegpu::CUDASimulation
-
~EnvironmentManager()