|
Bifrost SDK
Bifrost SDK documentation
|
Runtime service that is used by operators. More...
#include <RuntimeServices.h>
Classes | |
| class | ProfilerGuard |
| Helper class to ensure all profiler events have matching begin/end calls. More... | |
Public Types | |
| using | LogCallback = void(*)(RuntimeMessageCategory category, Amino::StringView const &message, void *clientData) |
Public Member Functions | |
| AMINO_CORE_SHARED_DECL | RuntimeServices (LogCallback cb, void *clientData, RuntimeMessageCategory logLevel=RuntimeMessageCategory::kInfo, bool allowConcurrentCalls=false) |
| Constructs a RuntimeServices that calls the given callback when messages are logged. More... | |
| AMINO_CORE_SHARED_DECL | ~RuntimeServices () |
| Destructor. More... | |
| AMINO_CORE_SHARED_DECL bool | isLogEnabled (RuntimeMessageCategory cat) const |
| Check if logging is enabled for a specific category. More... | |
| bool | isLogInfoEnabled () const |
| Short-hand for isLogEnabled(RuntimeMessageCategory::kInfo) More... | |
| bool | isLogWarningEnabled () const |
| Short-hand for isLogEnabled(RuntimeMessageCategory::kWarning) More... | |
| bool | isLogErrorEnabled () const |
| Short-hand for isLogEnabled(RuntimeMessageCategory::kError) More... | |
| template<typename Msg > | |
| AMINO_INTERNAL_FORCEINLINE void | logInfo (Msg const &msg) const |
| Short-hand for log(RuntimeMessageCategory::kInfo, msg) More... | |
| template<typename Msg > | |
| AMINO_INTERNAL_FORCEINLINE void | logWarning (Msg const &msg) const |
| Short-hand for log(RuntimeMessageCategory::kWarning, msg) More... | |
| template<typename Msg > | |
| AMINO_INTERNAL_FORCEINLINE enable_if_functor< Msg > | logError (Msg const &msg) const |
| Short-hand for log(RuntimeMessageCategory::kError, msg) More... | |
| AMINO_CORE_SHARED_DECL void | logError (StringView msg) const |
| Log the given error message if logging of errors is enabled. More... | |
| AMINO_CORE_SHARED_DECL int | profilerEventBegin () const |
| Notify profiler about beginning of a new named event. More... | |
| AMINO_CORE_SHARED_DECL int | profilerEventBegin (const char *eventName) const |
| Notify profiler about beginning of a new named event. More... | |
| AMINO_CORE_SHARED_DECL void | profilerEventEnd (int startEventID) const |
| Notify profiler about end of an event. More... | |
| template<typename OStream > | |
| AMINO_INTERNAL_FORCEINLINE | RuntimeServices (OStream *os) |
| Constructs a RuntimeServices that logs messages to the given output stream when messages are logged. More... | |
| template<typename OStream > | |
| AMINO_INTERNAL_FORCEINLINE | RuntimeServices (OStream *os, RuntimeMessageCategory logLevel) |
| Constructs a RuntimeServices that logs messages to the given output stream when messages are logged. More... | |
| RuntimeServices (const RuntimeServices &rhs)=delete | |
| Copying and moving RuntimeServices is prohibited. More... | |
| RuntimeServices (RuntimeServices &&rhs) noexcept=delete | |
| Copying and moving RuntimeServices is prohibited. More... | |
| RuntimeServices & | operator= (const RuntimeServices &rhs)=delete |
| Copying and moving RuntimeServices is prohibited. More... | |
| RuntimeServices & | operator= (RuntimeServices &&rhs) noexcept=delete |
| Copying and moving RuntimeServices is prohibited. More... | |
| template<typename MsgFunc > | |
| AMINO_INTERNAL_FORCEINLINE enable_if_functor< MsgFunc > | log (RuntimeMessageCategory category, MsgFunc const &msgFunc) const |
| Log a message with a specific category. More... | |
| void | log (RuntimeMessageCategory category, StringView const &message) const |
| Log a message with a specific category. More... | |
Static Public Member Functions | |
| static AMINO_CORE_SHARED_DECL RuntimeServices const & | getDisabled () |
| Get reference to a "disabled" runtime services. More... | |
Runtime service that is used by operators.
The runtime service object is used by a job to capture messages generated by its operators at runtime. Operators can call the logging functions of the RuntimeServices object to generate error, warning or info messages. They can do so either by passing logging functions a functor that will lazily be called only if logging is enabled for the given message category, or by passing a StringView directly. In the latter case, except for RuntimeServices::logError, it is up to the caller to ensure that logging is enabled for the given category (logging messages when logging is disabled will trigger an assertion).
The RuntimeServices can also be used to profile the operator's execution time by creating named profiling events.
Calls to all logging and profiling functions are thread-safe.
This RuntimeServices parameter must be a const reference. For example:
In header file:
In cpp file:
It is not necessary to specify the RuntimeServices parameter on the operator if logging/profiling is not required. The header parser will detect the presence of the RuntimeServices and generate the state required for the operator to be called with this parameter.
Definition at line 103 of file RuntimeServices.h.
| using Amino::RuntimeServices::LogCallback = void (*)( RuntimeMessageCategory category, Amino::StringView const& message, void* clientData) |
Definition at line 112 of file RuntimeServices.h.
|
inlineexplicit |
Constructs a RuntimeServices that logs messages to the given output stream when messages are logged.
Definition at line 136 of file RuntimeServices.h.
References Amino::kInfo.
|
inline |
Constructs a RuntimeServices that logs messages to the given output stream when messages are logged.
Definition at line 140 of file RuntimeServices.h.
| AMINO_CORE_SHARED_DECL Amino::RuntimeServices::RuntimeServices | ( | LogCallback | cb, |
| void * | clientData, | ||
| RuntimeMessageCategory | logLevel = RuntimeMessageCategory::kInfo, |
||
| bool | allowConcurrentCalls = false |
||
| ) |
Constructs a RuntimeServices that calls the given callback when messages are logged.
|
delete |
Copying and moving RuntimeServices is prohibited.
|
deletenoexcept |
Copying and moving RuntimeServices is prohibited.
| AMINO_CORE_SHARED_DECL Amino::RuntimeServices::~RuntimeServices | ( | ) |
Destructor.
|
static |
Get reference to a "disabled" runtime services.
This RuntimeServices instance does not have logging enabled and has no profilers callbacks. It can be used by C++ library author to create operators that take a RuntimeServices job port and want to write tests for such operators directly (without creating an Amino::Job that would pass said RuntimeServices to the operator).
| AMINO_CORE_SHARED_DECL bool Amino::RuntimeServices::isLogEnabled | ( | RuntimeMessageCategory | cat | ) | const |
Check if logging is enabled for a specific category.
Referenced by isLogErrorEnabled(), isLogInfoEnabled(), isLogWarningEnabled(), and log().
|
inline |
Short-hand for isLogEnabled(RuntimeMessageCategory::kError)
Definition at line 178 of file RuntimeServices.h.
References isLogEnabled(), and Amino::kError.
|
inline |
Short-hand for isLogEnabled(RuntimeMessageCategory::kInfo)
Definition at line 168 of file RuntimeServices.h.
References isLogEnabled(), and Amino::kInfo.
|
inline |
Short-hand for isLogEnabled(RuntimeMessageCategory::kWarning)
Definition at line 173 of file RuntimeServices.h.
References isLogEnabled(), and Amino::kWarning.
|
inline |
Log a message with a specific category.
Can either be called with a functor that generates the message which will be called only if logging is enabled, or with a StringView (in which case it's up to the caller to ensure that logging is enabled with isLogEnabled).
Definition at line 193 of file RuntimeServices.h.
References isLogEnabled().
Referenced by logError(), logInfo(), and logWarning().
|
inline |
Log a message with a specific category.
Can either be called with a functor that generates the message which will be called only if logging is enabled, or with a StringView (in which case it's up to the caller to ensure that logging is enabled with isLogEnabled).
Definition at line 203 of file RuntimeServices.h.
References isLogEnabled().
|
inline |
Short-hand for log(RuntimeMessageCategory::kError, msg)
Definition at line 224 of file RuntimeServices.h.
References Amino::kError, and log().
| AMINO_CORE_SHARED_DECL void Amino::RuntimeServices::logError | ( | StringView | msg | ) | const |
Log the given error message if logging of errors is enabled.
|
inline |
Short-hand for log(RuntimeMessageCategory::kInfo, msg)
Definition at line 212 of file RuntimeServices.h.
References Amino::kInfo, and log().
|
inline |
Short-hand for log(RuntimeMessageCategory::kWarning, msg)
Definition at line 218 of file RuntimeServices.h.
References Amino::kWarning, and log().
|
delete |
Copying and moving RuntimeServices is prohibited.
|
deletenoexcept |
Copying and moving RuntimeServices is prohibited.
| AMINO_CORE_SHARED_DECL int Amino::RuntimeServices::profilerEventBegin | ( | ) | const |
Notify profiler about beginning of a new named event.
| eventName | The name to associate with profiler event. |
| AMINO_CORE_SHARED_DECL int Amino::RuntimeServices::profilerEventBegin | ( | const char * | eventName | ) | const |
Notify profiler about beginning of a new named event.
| eventName | The name to associate with profiler event. |
| AMINO_CORE_SHARED_DECL void Amino::RuntimeServices::profilerEventEnd | ( | int | startEventID | ) | const |
Notify profiler about end of an event.
| startEventID | Link to an event ID which started profiling block. |
Referenced by Amino::RuntimeServices::ProfilerGuard::~ProfilerGuard().