9 #ifndef IFW_CTD_SYSTEM_HPP_
10 #define IFW_CTD_SYSTEM_HPP_
17 #include "rad/logger.hpp"
22 namespace ctd::system {
27 void Assert(
const bool condition,
28 const std::string& message,
29 std::array<std::string, 3>& location);
33 const std::string&
object,
34 std::array<std::string, 3>& location);
40 int64_t
Random(
const int64_t min_val,
41 const int64_t max_val);
49 std::string
ExecCommand(
const std::string& command);
77 explicit Mutex(
const std::string&
id);
81 const std::string&
Id()
const;
90 static bool s_initialized;
91 static bool s_debug_mode;
92 static std::recursive_mutex s_gen_mutex;
93 static void _lock_gen_mutex();
94 static void _unlock_gen_mutex();
96 static std::map<std::string, std::shared_ptr<std::recursive_mutex> > s_mutexes;
99 std::recursive_mutex* m_cur_sem_ptr;
105 namespace testUtils {
109 std::string
GetResDir(
const std::string& module_path,
110 const std::string& res_dir =
"test/resource");
114 const std::string& res_dir =
"test/resource");
120 #define BEGIN_CRIT_SEC(id) { \
121 ctd::system::Mutex tmp_mutex(id); \
123 #define END_CRIT_SEC(id) }
129 #endif // IFW_CTD_SYSTEM_HPP_
int64_t Random(const int64_t min_val, const int64_t max_val)
Generate an int64_t random number in the inteval specified.
Definition: system.cpp:72
void AssertPtr(const void *ptr, const std::string &object, std::array< std::string, 3 > &location)
Check if pointer is NULL. If yes, throw rad::Exception.
Definition: system.cpp:26
Mutex(const std::string &id)
Definition: system.cpp:137
void Assert(const bool condition, const std::string &message, std::array< std::string, 3 > &location)
Check if pointer is NULL. If yes, throw rad::Exception.
void Lock()
Definition: system.cpp:192
std::string GetResDir(const std::string &module_path, const std::string &res_dir="test/resource")
Derives the "resource" directory from the current working point.
Definition: system.cpp:222
void SetRootEnvVars(const std::string &module_path, const std::string &res_dir="test/resource")
Set the root environment variables: CFGROOT, INTROOT, DATAROOT.
Definition: system.cpp:257
double _Time()
Definition: system.cpp:40
static void Clear()
Releases (deletes) all semaphores allocated. Use with caution!!
Definition: system.cpp:185
std::string ExecCommand(const std::string &command)
Execute a shell command (synchroneously).
Definition: system.cpp:101
std::string Platform()
Get the name of the platform (OS).
Definition: system.cpp:50
void Unlock()
Definition: system.cpp:203
const std::string & Id() const
Definition: system.cpp:214
The Mutex class: Scope based mutex semaphore. The ctd::system::Mutex semaphore is used to implement a...
Definition: system.hpp:72
~Mutex()
Definition: system.cpp:171