rad  3.0.0
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
rad::Utils::Utils
Utils()=delete
rad
Definition: actionCallback.hpp:21
rad::GetLogger
log4cplus::Logger & GetLogger()
Definition: logger.cpp:44
rad::AnyEvent
Definition: anyEvent.hpp:52
rad::Utils::operator=
Utils & operator=(const Utils &)=delete
rad::Utils::Utils
Utils(const Utils &)=delete
rad::Utils::GetRequestId
static const std::string GetRequestId(rad::AnyEvent const &event)
Definition: utils.hpp:42
RAD_TRACE
#define RAD_TRACE(logger)
Definition: logger.hpp:24
rad::Utils
Definition: utils.hpp:22