Class zmbt::Environment¶
ClassList > zmbt > Environment
Controlled environment data storage. More...
#include <environment.hpp>
Classes¶
Type | Name |
---|---|
class | InterfaceHandle Environment extension handling the interface data. |
class | TypedInterfaceHandle <class Interface> Environment API handler for specific interface. |
Public Functions¶
Type | Name |
---|---|
PersistentConfig | Config () const |
bool | ContainsShared (boost::json::string_view fmtstr, A &&... arg) const Check if shared variable exists. |
object_id | DefaultObjectId (interface_id const & ifc_id) const |
lock_t | DeferLock () const Get the Environment thread lock with std::defer_lock tag. |
void | DumpJsonData (std::ostream & os) Dump current environment state in prettified JSON. |
Environment () |
|
Environment (Environment &&) = default |
|
Environment (Environment const &) = default |
|
SignalOperatorHandler | GetOperator (boost::json::string_view name) const |
SignalOperatorHandler | GetOperatorOrDefault (boost::json::string_view name) const |
boost::json::string | GetOrRegisterInterface (object_id const & obj_id, interface_id const & ifc_id) |
boost::json::string | GetOrRegisterParametricTrigger (object_id const & obj_id, interface_id const & ifc_id) |
std::shared_ptr< T > | GetShared (boost::json::string_view fmtstr, A &&... arg) const Get the shared data associated with object and string key. |
T | GetVar (object_id obj, std::string key) Get the environment variable. |
T | GetVar (std::string key) |
boost::json::value | GetVar (object_id obj, std::string key) |
boost::json::value | GetVar (std::string key) |
T | GetVarOrDefault (object_id obj, std::string key, T default_value=reflect::signal_traits< T >::init()) Get the environment variable or use default. |
T | GetVarOrDefault (std::string key, T default_value=reflect::signal_traits< T >::init()) |
boost::json::value | GetVarOrDefault (object_id obj, std::string key, boost::json::value default_value=nullptr) |
boost::json::value | GetVarOrDefault (std::string key, boost::json::value default_value=nullptr) |
T | GetVarOrUpdate (object_id obj, std::string key, T update_value) Get or update the environment variable. |
T | GetVarOrUpdate (std::string key, T update_value) |
boost::json::value | GetVarOrUpdate (object_id obj, std::string key, boost::json::value update_value) |
boost::json::value | GetVarOrUpdate (std::string key, boost::json::value update_value) |
Environment & | HandleTestFailure (boost::json::value const & diagnostics) |
bool | HasAction (boost::json::string_view key) const |
bool | HasTrigger (boost::json::string_view key) const |
interface_id | InterfaceId (boost::json::string_view interface_key) const |
lock_t | Lock () const Get the Environment thread lock. |
object_id | ObjectId (boost::json::string_view interface_key) const |
Environment & | RegisterAction (std::function< void()> action, boost::json::string_view fmtstr, A &&... arg) |
Environment & | RegisterAnonymousInterface (interface_id const & ifc_id, object_id const & obj_id) |
enable_if_t< is_ifc_handle< I >::value, Environment & > | RegisterAnonymousInterface (I && interface, object_id const & obj_id=object_id{ifc_host_nullptr< I >}) |
boost::json::string | RegisterAnonymousTrigger (H && host, I && interface) |
Environment & | RegisterInterface (boost::json::string_view key, interface_id const & ifc_id, object_id const & obj_id) Register interface to enable FFI in the test model runners. |
enable_if_t< is_ifc_handle< I >::value, Environment & > | RegisterInterface (boost::json::string_view key, I && interface, object_id const & obj_id=object_id{ifc_host_nullptr< I >}) |
Environment & | RegisterOperator (boost::json::string_view key, SignalOperatorHandler const & op) Register operator handler to enable FFI for type decoration in the test model runners. |
Environment & | RegisterOperator (SignalOperatorHandler const & op) |
interface_id | RegisterParametricTriggerIfc (I && interface) |
object_id | RegisterParametricTriggerObj (T && obj) |
Environment & | RegisterPrototypes (I && interface) |
Environment & | RegisterTrigger (boost::json::string_view key, I && interface, H && host) Register test trigger to enable FFI in the test model runners. |
Environment & | RegisterTrigger (boost::json::string_view key, I && interface) |
void | ResetAll () Clear all data. |
void | ResetAllFor (object_id obj) Clear data associated with the object. |
Environment & | ResetFailureHandler () Reset the test handler to default. |
void | ResetInterfaceData () Clear all interface data (accessed via ArgsFor/ReturnFor) |
void | ResetInterfaceDataFor (object_id obj) Clear interface data associated with the object (accessed via ArgsFor/ReturnFor) |
Environment & | RunAction (boost::json::string_view fmtstr, A &&... arg) |
Environment & | SetFailureHandler (std::function< void(boost::json::value const &)> const & fn) Set custom test failure handler. |
Environment & | SetPrettyPrint (bool const pretty_print=true) Set pretty print JSON values. |
void | SetShared (std::shared_ptr< T > data, boost::json::string_view fmtstr, A &&... arg) Set the shared data associated with key. |
void | SetVar (object_id obj, std::string key, T var) Set the environment variable. |
void | SetVar (std::string key, T var) |
lock_t | TryLock () const Get the Environment thread lock with std::try_to_lock tag. |
JsonNode & | json_data () |
JsonNode const & | json_data () const |
Environment & | operator= (Environment &&) = default |
Environment & | operator= (Environment const &) = default |
virtual | ~Environment () |
Public Static Functions¶
Type | Name |
---|---|
boost::json::string | autokey (object_id const & obj_id, interface_id const & ifc_id) |
Protected Types¶
Type | Name |
---|---|
typedef std::function< void(boost::json::value const &)> | FailureHandler |
typedef reflect::invocation_args_t< ifc_pointer_t< T > > | argsref_t |
typedef mp_transform< rvref_to_val, argsref_t< I > > | hookout_args_t |
typedef typename EnvironmentData::lock_t | lock_t |
typedef reflect::invocation_ret_t< ifc_pointer_t< T > > | return_t |
typedef mp_if< std::is_rvalue_reference< T >, std::remove_reference_t< T >, T > | rvref_to_val |
typedef reflect::invocation_args_unqf_t< ifc_pointer_t< T > > | unqf_args_t |
Protected Attributes¶
Type | Name |
---|---|
std::shared_ptr< PersistentConfig > | config_ |
std::shared_ptr< EnvironmentData > | data_ |
Detailed Description¶
Handles signal values and calls counters to/from environment, using interface pointers as keys
Public Functions Documentation¶
function Config¶
function ContainsShared¶
Check if shared variable exists.
template<class... A>
inline bool zmbt::Environment::ContainsShared (
boost::json::string_view fmtstr,
A &&... arg
) const
function DefaultObjectId¶
function DeferLock¶
Get the Environment thread lock with std::defer_lock tag.
function DumpJsonData¶
Dump current environment state in prettified JSON.
Parameters:
os
output stream
function Environment [1/3]¶
function Environment [2/3]¶
function Environment [3/3]¶
function GetOperator¶
function GetOperatorOrDefault¶
SignalOperatorHandler zmbt::Environment::GetOperatorOrDefault (
boost::json::string_view name
) const
function GetOrRegisterInterface¶
boost::json::string zmbt::Environment::GetOrRegisterInterface (
object_id const & obj_id,
interface_id const & ifc_id
)
function GetOrRegisterParametricTrigger¶
boost::json::string zmbt::Environment::GetOrRegisterParametricTrigger (
object_id const & obj_id,
interface_id const & ifc_id
)
function GetShared¶
Get the shared data associated with object and string key.
template<class T, class... A>
inline std::shared_ptr< T > zmbt::Environment::GetShared (
boost::json::string_view fmtstr,
A &&... arg
) const
Dynamic polymorphism is not supported, as the type safety is ensured by comparing typeid(T). If the type T is not exactly the same as was used on corresponding SetShared call, the method will throw environment_error.
If corresponding data was not set, the metod return nullptr.
Template parameters:
T
A
Parameters:
fmtstr
key format stringarg
key format arguments
Returns:
std::shared_ptr<T>
function GetVar [1/4]¶
Get the environment variable.
Template parameters:
T
Parameters:
obj
key
Returns:
T
function GetVar [2/4]¶
function GetVar [3/4]¶
function GetVar [4/4]¶
function GetVarOrDefault [1/4]¶
Get the environment variable or use default.
template<class T>
inline T zmbt::Environment::GetVarOrDefault (
object_id obj,
std::string key,
T default_value=reflect::signal_traits < T >::init()
)
Template parameters:
T
Parameters:
obj
key
default_value
Returns:
T
function GetVarOrDefault [2/4]¶
template<class T>
inline T zmbt::Environment::GetVarOrDefault (
std::string key,
T default_value=reflect::signal_traits < T >::init()
)
function GetVarOrDefault [3/4]¶
inline boost::json::value zmbt::Environment::GetVarOrDefault (
object_id obj,
std::string key,
boost::json::value default_value=nullptr
)
function GetVarOrDefault [4/4]¶
inline boost::json::value zmbt::Environment::GetVarOrDefault (
std::string key,
boost::json::value default_value=nullptr
)
function GetVarOrUpdate [1/4]¶
Get or update the environment variable.
template<class T>
inline T zmbt::Environment::GetVarOrUpdate (
object_id obj,
std::string key,
T update_value
)
Template parameters:
T
Parameters:
obj
key
update_value
Returns:
T
function GetVarOrUpdate [2/4]¶
function GetVarOrUpdate [3/4]¶
inline boost::json::value zmbt::Environment::GetVarOrUpdate (
object_id obj,
std::string key,
boost::json::value update_value
)
function GetVarOrUpdate [4/4]¶
inline boost::json::value zmbt::Environment::GetVarOrUpdate (
std::string key,
boost::json::value update_value
)
function HandleTestFailure¶
function HasAction¶
function HasTrigger¶
function InterfaceId¶
function Lock¶
Get the Environment thread lock.
function ObjectId¶
function RegisterAction¶
template<class... A>
inline Environment & zmbt::Environment::RegisterAction (
std::function< void()> action,
boost::json::string_view fmtstr,
A &&... arg
)
function RegisterAnonymousInterface [1/2]¶
inline Environment & zmbt::Environment::RegisterAnonymousInterface (
interface_id const & ifc_id,
object_id const & obj_id
)
function RegisterAnonymousInterface [2/2]¶
template<class I>
inline enable_if_t< is_ifc_handle< I >::value, Environment & > zmbt::Environment::RegisterAnonymousInterface (
I && interface,
object_id const & obj_id=object_id { ifc_host_nullptr < I >}
)
function RegisterAnonymousTrigger¶
template<class H, class I>
inline boost::json::string zmbt::Environment::RegisterAnonymousTrigger (
H && host,
I && interface
)
function RegisterInterface [1/2]¶
Register interface to enable FFI in the test model runners.
Environment & zmbt::Environment::RegisterInterface (
boost::json::string_view key,
interface_id const & ifc_id,
object_id const & obj_id
)
Parameters:
obj_id
object associated with callableifc_id
callable handlekey
string key, unique per environment
Returns:
function RegisterInterface [2/2]¶
template<class I>
inline enable_if_t< is_ifc_handle< I >::value, Environment & > zmbt::Environment::RegisterInterface (
boost::json::string_view key,
I && interface,
object_id const & obj_id=object_id { ifc_host_nullptr < I >}
)
function RegisterOperator [1/2]¶
Register operator handler to enable FFI for type decoration in the test model runners.
Environment & zmbt::Environment::RegisterOperator (
boost::json::string_view key,
SignalOperatorHandler const & op
)
Parameters:
op
operator handlerkey
string key, unique per environment
Returns:
function RegisterOperator [2/2]¶
function RegisterParametricTriggerIfc¶
template<class I>
inline interface_id zmbt::Environment::RegisterParametricTriggerIfc (
I && interface
)
function RegisterParametricTriggerObj¶
function RegisterPrototypes¶
function RegisterTrigger [1/2]¶
Register test trigger to enable FFI in the test model runners.
template<class I, class H>
inline Environment & zmbt::Environment::RegisterTrigger (
boost::json::string_view key,
I && interface,
H && host
)
Template parameters:
H
I
Parameters:
host
callable host objectinterface
callable interface handlekey
string key, unique per environment
Returns:
function RegisterTrigger [2/2]¶
template<class I>
inline Environment & zmbt::Environment::RegisterTrigger (
boost::json::string_view key,
I && interface
)
function ResetAll¶
Clear all data.
function ResetAllFor¶
Clear data associated with the object.
Parameters:
obj
function ResetFailureHandler¶
Reset the test handler to default.
function ResetInterfaceData¶
Clear all interface data (accessed via ArgsFor/ReturnFor)
Warning:
this will invalidate interface records
function ResetInterfaceDataFor¶
Clear interface data associated with the object (accessed via ArgsFor/ReturnFor)
Warning:
this will invalidate interface records
Parameters:
obj
function RunAction¶
template<class... A>
inline Environment & zmbt::Environment::RunAction (
boost::json::string_view fmtstr,
A &&... arg
)
function SetFailureHandler¶
Set custom test failure handler.
Environment & zmbt::Environment::SetFailureHandler (
std::function< void(boost::json::value const &)> const & fn
)
function SetPrettyPrint¶
Set pretty print JSON values.
function SetShared¶
Set the shared data associated with key.
template<class T, class... A>
inline void zmbt::Environment::SetShared (
std::shared_ptr< T > data,
boost::json::string_view fmtstr,
A &&... arg
)
this will prolong the original data lifetime
Template parameters:
T
A
Parameters:
data
fmtstr
key format stringarg
key format arguments
function SetVar [1/2]¶
Set the environment variable.
Template parameters:
T
Parameters:
obj
key
var
function SetVar [2/2]¶
function TryLock¶
Get the Environment thread lock with std::try_to_lock tag.
function json_data [1/2]¶
function json_data [2/2]¶
function operator=¶
function operator=¶
function ~Environment¶
Public Static Functions Documentation¶
function autokey¶
static inline boost::json::string zmbt::Environment::autokey (
object_id const & obj_id,
interface_id const & ifc_id
)
Protected Types Documentation¶
typedef FailureHandler¶
typedef argsref_t¶
typedef hookout_args_t¶
typedef lock_t¶
typedef return_t¶
typedef rvref_to_val¶
using zmbt::Environment::rvref_to_val = mp_if<std::is_rvalue_reference<T>, std::remove_reference_t<T>, T>;
typedef unqf_args_t¶
Protected Attributes Documentation¶
variable config_¶
variable data_¶
The documentation for this class was generated from the following file zmbt-framework/zmbt-framework/backends/cxx/include/zmbt/model/environment.hpp