rad  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utils.hpp
Go to the documentation of this file.
1 
9 #ifndef RAD_UTILS_HPP
10 #define RAD_UTILS_HPP
11 
12 #include <rad/getPayload.hpp>
13 #include <rad/logger.hpp>
14 
15 #include <string>
16 
17 namespace rad {
18 
22 class Utils {
23  public:
24  template <typename EVENT>
25  static const std::string GetRequestId(rad::AnyEvent const& event);
26 
27  Utils() = delete;
28  Utils(const Utils&) = delete;
29  Utils& operator=(const Utils&) = delete;
30 };
31 
41 template <typename EVENT>
42 const std::string Utils::GetRequestId(rad::AnyEvent const& event) {
44 
45  auto payload = rad::GetPayloadNothrow<EVENT>(event);
46  if (payload == nullptr) {
47  LOG4CPLUS_ERROR(GetLogger(), "Last event's payload is NULL!");
48  return "";
49  }
50  return payload->GetOriginatorId();
51 }
52 
53 } // namespace rad
54 
55 #endif // RAD_UTILS_HPP
log4cplus::Logger & GetLogger()
Definition: logger.cpp:43
static const std::string GetRequestId(rad::AnyEvent const &event)
Definition: utils.hpp:42
Definition: utils.hpp:22
Definition: anyEvent.hpp:52
Utils & operator=(const Utils &)=delete
#define RAD_TRACE(logger)
Definition: logger.hpp:19
Utils()=delete