Class HostEnvironment
Defined in File HostEnvironment.cuh
Class Documentation
-
class HostEnvironment
This class provides host function access to Environment Properties It acts as a wrapper to EnvironmentManager, proxying calls, converting variable name and model_name into a combined hash Pairs with EnvironmentManager, AgentEnvironment and EnvironmentDescription This class is only to be constructed by HostAPI
Note
Not thread-safe
Public Functions
-
template<typename T>
T getProperty(const std::string &name) const Gets an environment property
Getters
- Parameters:
name – name used for accessing the property
- Template Parameters:
T – Type of the environment property
- Throws:
exception::InvalidEnvProperty – If a property of the name does not exist
-
template<typename T, flamegpu::size_type N>
std::array<T, N> getProperty(const std::string &name) const Gets an environment property array
- Parameters:
name – name used for accessing the property
- Template Parameters:
T – Type of the elements of the environment property array
N – Length of the environment property array
- Throws:
exception::InvalidEnvProperty – If a property array of the name does not exist
-
template<typename T, flamegpu::size_type N = 0>
T getProperty(const std::string &name, flamegpu::size_type index) const Gets an element of an environment property array
See also
get(const std::string &)
- Parameters:
name – name used for accessing the property
index – Index of the element within the environment property array to return
- Template Parameters:
T – Type of the elements of the environment property array
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 –
-
template<typename T>
T setProperty(const std::string &name, T value) const Sets an environment property
Setters
- Parameters:
name – name used for accessing the property
value – to set the property
- Template Parameters:
T – Type of the elements of the environment property
- 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, flamegpu::size_type N>
std::array<T, N> setProperty(const std::string &name, const std::array<T, N> &value) const Sets an environment property array
- Parameters:
name – name used for accessing the property array
value – to set the property array
- Template Parameters:
T – Type of the elements of the environment property array
N – Length of the environmental property array
- 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, flamegpu::size_type N = 0>
T setProperty(const std::string &name, flamegpu::size_type index, T value) const Sets an element of an environment property array
See also
get(const std::string &)
- Parameters:
name – name used for accessing the property array
index – element within the environment property array to set
value – to set the element of the property array
- Template Parameters:
T – Type of the environmental property array
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, unsigned int I = 1, unsigned int J = 1, unsigned int K = 1, unsigned int W = 1>
HostMacroProperty<T, I, J, K, W> getMacroProperty(const std::string &name) const Returns an interface for accessing the named host macro property
- Parameters:
name – The name of the environment macro property to return
-
void importMacroProperty(const std::string &property_name, const std::string &file_path) const
Import macro property data from file
Note
This method supports raw binary files (.bin)
- Parameters:
property_name – Name of the macro property to import
file_path – Path to file containing macro property data (.json, .xml, .bin)
-
void exportMacroProperty(const std::string &property_name, const std::string &file_path, bool pretty_print = true) const
Export macro property data to file
Note
This method supports raw binary files (.bin)
- Parameters:
property_name – Name of the macro property to import
file_path – Path to file to export macro property data (.json, .xml. bin)
pretty_print – Print in readable or minified format (if available)
-
HostEnvironmentDirectedGraph getDirectedGraph(const std::string &name) const
Returns an interface for accessing the named directed graph
- Parameters:
name – The name of the environment directed graph to return
Protected Functions
Constructor, to be called by HostAPI
Protected Attributes
-
const std::shared_ptr<detail::EnvironmentManager> env_mgr
Provides access to EnvironmentManager singleton
-
const std::shared_ptr<detail::CUDAMacroEnvironment> macro_env
Provides access to macro properties for the instance
-
CUDADirectedGraphMap &directed_graph_map
Provides access to directed graphs for the instance
-
const unsigned int instance_id
Access to instance id of the CUDASimulation This is used to augment all variable names
-
CUDASimulation &simulation
The relevant simulation, required for importing macro properties
-
detail::CUDAScatter &scatter
CUDA scatter singleton
-
const unsigned int streamID
CUDA stream index used for cuda stream resources.
-
const cudaStream_t stream
CUDA stream used for cuda operations.
-
template<typename T>