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 |
|---|---|
| bool | ContainsShared (lang::Expression const & key_expr) 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 | DumpToJsonLog () Dump current environment state to JSON log. |
| Environment () |
|
| Environment (Environment &&) = default |
|
| Environment (Environment const &) = default |
|
| 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) |
| reflect::Prototypes | GetPrototypes (interface_id const & id) const |
| std::shared_ptr< OutputRecorder > | GetRecorder (Interface && interface) |
| std::shared_ptr< OutputRecorder > | GetRecorder (interface_id const & ifc_id, object_id const & obj_id) |
| std::shared_ptr< T > | GetShared (lang::Expression const & key_expr) const Get the shared data associated with object and string key. |
| T & | GetSharedRef (lang::Expression const & key_expr, A &&... args) Get reference to shared var, creating it if necessary. |
| boost::json::value | GetVar (lang::Expression const & key_expr) Get the environment variable. |
| T | GetVar (lang::Expression const & key_expr) |
| boost::json::value | GetVarOrDefault (lang::Expression const & key_expr, boost::json::value default_value={}) Get the environment variable or use default. |
| T | GetVarOrDefault (lang::Expression const & key_expr, T default_value=reflect::signal_traits< T >::init()) |
| boost::json::value | GetVarOrUpdate (lang::Expression const & key_expr, boost::json::value update_value) Get or update the environment variable. |
| T | GetVarOrUpdate (lang::Expression const & key_expr, T update_value) |
| bool | HasAction (boost::json::string_view key) const |
| bool | HasTestError () Current test error payload, null if none. |
| bool | HasTrigger (boost::json::string_view key) const |
| Environment & | InitializeInterfaceHandlers (Interface && interface) |
| 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 (lang::Expression const & key_expr, std::function< void()> action) |
| Environment & | RegisterAnonymousInterface (interface_id const & ifc_id, object_id const & obj_id) |
| enable_if_t< is_ifc_handle< Interface >::value, Environment & > | RegisterAnonymousInterface (Interface && interface, object_id const & obj_id=object_id{ifc_host_nullptr< Interface >}) |
| boost::json::string | RegisterAnonymousTrigger (Interface && interface, H && host) |
| 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< Interface >::value, Environment & > | RegisterInterface (boost::json::string_view key, Interface && interface, object_id const & obj_id=object_id{ifc_host_nullptr< Interface >}) |
| interface_id | RegisterParametricTriggerIfc (Interface && interface) |
| object_id | RegisterParametricTriggerObj (T && obj) |
| Environment & | RegisterTrigger (boost::json::string_view key, Interface && interface, H && host) Register test trigger to enable FFI in the test model runners. |
| Environment & | RegisterTrigger (boost::json::string_view key, Interface && interface) |
| void | ResetAll () Clear all data. |
| void | ResetInterfaceData () Clear all interface data (accessed via ArgsFor/ReturnFor) |
| Environment & | RunAction (lang::Expression const & key_expr) |
| Environment & | RunActionNoCatch (lang::Expression const & key_expr) |
| void | SetShared (lang::Expression const & key_expr, std::shared_ptr< T > data) Set the shared data associated with key. |
| void | SetVar (lang::Expression const & key_expr, boost::json::value var) Set the environment variable. |
| void | SetVar (lang::Expression const & key_expr, T var) |
| boost::json::value const & | TestError () Current test error payload, null if none. |
| 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 reflect::invocation_args_t< ifc_pointer_t< Interface > > | argsref_t |
| typedef mp_transform< rvref_to_val, argsref_t< Interface > > | hookout_args_t |
| typedef typename EnvironmentData::lock_t | lock_t |
| typedef reflect::invocation_ret_t< ifc_pointer_t< Interface > > | 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< Interface > > | unqf_args_t |
Protected Attributes¶
| Type | Name |
|---|---|
| std::shared_ptr< EnvironmentData > | data_ |
| std::shared_ptr< PermanentEnvData > | permanent_data_ |
Protected Functions¶
| Type | Name |
|---|---|
| void | SetTestError (boost::json::value && msg) |
Detailed Description¶
Handles signal values and calls counters to/from environment, using interface pointers as keys
See also: Environment API
Public Functions Documentation¶
function ContainsShared¶
Check if shared variable exists.
function DefaultObjectId¶
function DeferLock¶
Get the Environment thread lock with std::defer_lock tag.
function DumpToJsonLog¶
Dump current environment state to JSON log.
function Environment [1/3]¶
function Environment [2/3]¶
function Environment [3/3]¶
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 GetPrototypes¶
function GetRecorder [1/2]¶
template<class Interface>
inline std::shared_ptr< OutputRecorder > zmbt::Environment::GetRecorder (
Interface && interface
)
function GetRecorder [2/2]¶
inline std::shared_ptr< OutputRecorder > zmbt::Environment::GetRecorder (
interface_id const & ifc_id,
object_id const & obj_id
)
function GetShared¶
Get the shared data associated with object and string key.
template<class T>
inline std::shared_ptr< T > zmbt::Environment::GetShared (
lang::Expression const & key_expr
) 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:
TA
Parameters:
fmtstrkey format stringargkey format arguments
Returns:
std::shared_ptr<T>
function GetSharedRef¶
Get reference to shared var, creating it if necessary.
template<class T, class... A>
inline T & zmbt::Environment::GetSharedRef (
lang::Expression const & key_expr,
A &&... args
)
Template parameters:
T...AConstructor args for initial value
Parameters:
key_expr
Returns:
function GetVar [1/2]¶
Get the environment variable.
Template parameters:
T
Parameters:
objkey
Returns:
T
function GetVar [2/2]¶
function GetVarOrDefault [1/2]¶
Get the environment variable or use default.
boost::json::value zmbt::Environment::GetVarOrDefault (
lang::Expression const & key_expr,
boost::json::value default_value={}
)
Template parameters:
T
Parameters:
objkeydefault_value
Returns:
T
function GetVarOrDefault [2/2]¶
template<class T>
inline T zmbt::Environment::GetVarOrDefault (
lang::Expression const & key_expr,
T default_value=reflect::signal_traits < T >::init()
)
function GetVarOrUpdate [1/2]¶
Get or update the environment variable.
boost::json::value zmbt::Environment::GetVarOrUpdate (
lang::Expression const & key_expr,
boost::json::value update_value
)
Template parameters:
T
Parameters:
objkeyupdate_value
Returns:
T
function GetVarOrUpdate [2/2]¶
template<class T>
inline T zmbt::Environment::GetVarOrUpdate (
lang::Expression const & key_expr,
T update_value
)
function HasAction¶
function HasTestError¶
Current test error payload, null if none.
function HasTrigger¶
function InitializeInterfaceHandlers¶
template<class Interface>
inline Environment & zmbt::Environment::InitializeInterfaceHandlers (
Interface && interface
)
function InterfaceId¶
function Lock¶
Get the Environment thread lock.
function ObjectId¶
function RegisterAction¶
Environment & zmbt::Environment::RegisterAction (
lang::Expression const & key_expr,
std::function< void()> action
)
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 Interface>
inline enable_if_t< is_ifc_handle< Interface >::value, Environment & > zmbt::Environment::RegisterAnonymousInterface (
Interface && interface,
object_id const & obj_id=object_id { ifc_host_nullptr < Interface >}
)
function RegisterAnonymousTrigger¶
template<class Interface, class H>
inline boost::json::string zmbt::Environment::RegisterAnonymousTrigger (
Interface && interface,
H && host
)
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_idobject associated with callableifc_idcallable handlekeystring key, unique per environment
Returns:
function RegisterInterface [2/2]¶
template<class Interface>
inline enable_if_t< is_ifc_handle< Interface >::value, Environment & > zmbt::Environment::RegisterInterface (
boost::json::string_view key,
Interface && interface,
object_id const & obj_id=object_id { ifc_host_nullptr < Interface >}
)
function RegisterParametricTriggerIfc¶
template<class Interface>
inline interface_id zmbt::Environment::RegisterParametricTriggerIfc (
Interface && interface
)
function RegisterParametricTriggerObj¶
function RegisterTrigger [1/2]¶
Register test trigger to enable FFI in the test model runners.
template<class Interface, class H>
inline Environment & zmbt::Environment::RegisterTrigger (
boost::json::string_view key,
Interface && interface,
H && host
)
Template parameters:
HInterface
Parameters:
hostcallable host objectinterfacecallable interface handlekeystring key, unique per environment
Returns:
function RegisterTrigger [2/2]¶
template<class Interface>
inline Environment & zmbt::Environment::RegisterTrigger (
boost::json::string_view key,
Interface && interface
)
function ResetAll¶
Clear all data.
function ResetInterfaceData¶
Clear all interface data (accessed via ArgsFor/ReturnFor)
Warning:
this will invalidate interface records
function RunAction¶
function RunActionNoCatch¶
function SetShared¶
Set the shared data associated with key.
template<class T>
inline void zmbt::Environment::SetShared (
lang::Expression const & key_expr,
std::shared_ptr< T > data
)
Template parameters:
TA
Parameters:
key_exprdata
function SetVar [1/2]¶
Set the environment variable.
Template parameters:
T
Parameters:
key_exprkey constant expressionvar
function SetVar [2/2]¶
template<class T>
inline void zmbt::Environment::SetVar (
lang::Expression const & key_expr,
T var
)
function TestError¶
Current test error payload, null if none.
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 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 data_¶
variable permanent_data_¶
Protected Functions Documentation¶
function SetTestError¶
The documentation for this class was generated from the following file zmbt-framework/zmbt-framework/backends/cxx/include/zmbt/model/environment.hpp