CMS 3D CMS Logo

MessageSender.h
Go to the documentation of this file.
1 #ifndef FWCore_MessageLogger_MessageSender_h
2 #define FWCore_MessageLogger_MessageSender_h
3 
6 
7 #include <memory>
8 
9 #include <map>
10 
11 namespace edm {
12 
13  class MessageSender {
14  struct ErrorObjDeleter {
16  void operator()(ErrorObj* errorObjPtr);
17  };
18 
19  public:
20  // --- birth/death:
21  MessageSender() = default;
23  std::string_view id,
24  bool verbatim = false,
25  bool suppressed = false);
26  MessageSender(MessageSender&&) = default;
27  MessageSender(MessageSender const&) = default;
29  MessageSender& operator=(MessageSender const&) = default;
31 
32  // --- stream out the next part of a message:
33  template <class T>
35  if (valid())
36  (*errorobj_p) << t;
37  return *this;
38  }
39 
40  template <typename... Args>
41  MessageSender& format(std::string_view fmt, Args const&... args) {
42  if (valid())
43  errorobj_p->format(fmt, args...);
44  return *this;
45  }
46 
47  bool valid() const noexcept { return errorobj_p != nullptr; }
48 
49  private:
50  // data:
51  std::shared_ptr<ErrorObj> errorobj_p;
52 
53  }; // MessageSender
54 
55 } // namespace edm
56 
57 #endif // FWCore_MessageLogger_MessageSender_h
MessageSender & operator<<(T const &t)
Definition: MessageSender.h:34
MessageSender & operator=(MessageSender &&)=default
MessageSender & format(std::string_view fmt, Args const &... args)
Definition: MessageSender.h:41
std::shared_ptr< ErrorObj > errorobj_p
Definition: MessageSender.h:51
void operator()(ErrorObj *errorObjPtr)
MessageSender()=default
HLT enums.
long double T
bool valid() const noexcept
Definition: MessageSender.h:47