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(fmt::format_string<Args...> format, Args&&... args) {
42  if (valid())
43  errorobj_p->format(std::move(format), std::forward<Args>(args)...);
44  return *this;
45  }
46 
47  template <typename... Args>
48  MessageSender& vformat(std::string_view fmt, fmt::format_args args) {
49  if (valid())
50  errorobj_p->vformat(fmt, args);
51  return *this;
52  }
53 
54  bool valid() const noexcept { return errorobj_p != nullptr; }
55 
56  private:
57  // data:
58  std::shared_ptr<ErrorObj> errorobj_p;
59 
60  }; // MessageSender
61 
62 } // namespace edm
63 
64 #endif // FWCore_MessageLogger_MessageSender_h
MessageSender & operator<<(T const &t)
Definition: MessageSender.h:34
MessageSender & operator=(MessageSender &&)=default
std::shared_ptr< ErrorObj > errorobj_p
Definition: MessageSender.h:58
void operator()(ErrorObj *errorObjPtr)
MessageSender & format(fmt::format_string< Args... > format, Args &&... args)
Definition: MessageSender.h:41
MessageSender()=default
HLT enums.
long double T
MessageSender & vformat(std::string_view fmt, fmt::format_args args)
Definition: MessageSender.h:48
def move(src, dest)
Definition: eostools.py:511
bool valid() const noexcept
Definition: MessageSender.h:54