10 #ifndef _UGCS_VSM_UTILS_H_
11 #define _UGCS_VSM_UTILS_H_
17 #include <type_traits>
25 #define DEFINE_COMMON_CLASS(__class_name, ...) \
29 typedef std::shared_ptr<__class_name> Ptr; \
32 typedef std::weak_ptr<__class_name> Weak_ptr; \
35 template <typename... Args> \
37 Create(Args &&... args) \
39 return std::make_shared<__class_name>(std::forward<Args>(args)...); \
43 typedef ugcs::vsm::internal::Shared_getter<__class_name, ## __VA_ARGS__> Shared_getter; \
44 friend Shared_getter; \
50 return Shared_getter::Get(this); \
61 template <
class T,
class Shared_base =
void>
68 static std::shared_ptr<T>
71 return std::dynamic_pointer_cast<T>(this_ptr->shared_from_this());
80 static std::shared_ptr<T>
87 return std::shared_ptr<T>();
98 static std::shared_ptr<T>
101 return this_ptr->shared_from_this();
125 Ltrim(std::string & str);
128 Rtrim(std::string & str);
131 Trim(std::string & str);
Helper class for working with classes which are derived from std::enable_shared_from_this.
Definition: utils.h:62
Debugging and troubleshooting helpers.
Shared_base Shared_base_type
The type of base class.
Definition: utils.h:65
static std::shared_ptr< T > Get(T *this_ptr)
Get shared pointer to derived class.
Definition: utils.h:69
#define ASSERT(x)
No action in release.
Definition: debug.h:68
VSM exceptions definition.
#define __UNUSED
Use with unused arguments if you like to declare that it is not (yet) used a the function.
Definition: defs.h:30
std::regex_constants::syntax_option_type platform_independent_filename_regex_matching_flag
This flag is used to support case insensitive file systems in regular expression matching.
uint64_t Get_random_seed()
Return a random number on each call.
uint32_t Get_application_instance_id()
Return instance id which is randomly generated on the first call.
static std::shared_ptr< T > Get(T *this_ptr __attribute__((unused)))
Get which leads to runtime failure.
Definition: utils.h:81
static std::shared_ptr< T > Get(T *this_ptr)
Get shared pointer to itself.
Definition: utils.h:99