EnvironmentVariable holds a pointer to the actual variable, it should be used as any smart pointer. Event though most of the it will be "static" as it's treated as a global. More...
#include <Environment.h>
Public Types | |
typedef AZ::Internal::EnvironmentVariableHolder< T > | HolderType |
Public Member Functions | |
EnvironmentVariable (HolderType *holder) | |
template<class U > | |
EnvironmentVariable (EnvironmentVariable< U > const &rhs, typename AZStd::Internal::sp_enable_if_convertible< U, T >::type=AZStd::Internal::sp_empty()) | |
EnvironmentVariable (EnvironmentVariable const &rhs) | |
template<class U > | |
EnvironmentVariable & | operator= (EnvironmentVariable< U > const &rhs) |
EnvironmentVariable (EnvironmentVariable &&rhs) | |
EnvironmentVariable & | operator= (EnvironmentVariable &&rhs) |
EnvironmentVariable & | operator= (EnvironmentVariable const &rhs) |
void | Reset () |
T & | operator* () const |
T * | operator-> () const |
T & | Get () const |
template<typename U > | |
auto | Set (U &&value) -> AZStd::enable_if_t< AZStd::assignable_from< T &, U > > |
operator bool () const | |
bool | operator! () const |
void | Swap (EnvironmentVariable &rhs) |
bool | IsOwner () const |
bool | IsConstructed () const |
Protected Attributes | |
HolderType * | m_data |
EnvironmentVariable holds a pointer to the actual variable, it should be used as any smart pointer. Event though most of the it will be "static" as it's treated as a global.
EnvironmentVariable implementation, T should be default constructible/destructible. Keep in mind that if T uses virtual function (virtual destructor), it will use the vtable for the current module unloading the module with a vtable will destroy the variable (unless specified with CreateVariableEx). You will either need to control the order (aka Call Environmnet::Create from the module that will alive before the variable is destroyed) or provide intramodule allocator Environment::Create and make sure you don't use virtual function (of course implementations must match too). In general we advise to use the minimal amount of environment variables and use pointer types so you can manage the life cycle yourself, we will accept value types and do the best to make it work for you. When it comes to threading we make sure the EnvironmentVariable objects can be created, destroyed and assigned from multiple threads, however we don't make the code safe (for performance) when you access the variable. If your variable can be access from multiple threads while it's being modified you will need to make sure you synchronize the access to it.