PdCom  5.3
Process data communication client
MessageManagerBase.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vim:tw=78
3  *
4  * Copyright (C) 2022 Richard Hacker (lerichi at gmx dot net),
5  * Bjarne von Horn (vh at igh dot de).
6  *
7  * This file is part of the PdCom library.
8  *
9  * The PdCom library is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or (at your
12  * option) any later version.
13  *
14  * The PdCom library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with the PdCom library. If not, see <http://www.gnu.org/licenses/>.
21  *
22  *****************************************************************************/
23 
26 #ifndef PDCOM5_MESSAGEMANAGERBASE_H
27 #define PDCOM5_MESSAGEMANAGERBASE_H
28 
29 #include <chrono>
30 #include <cstdint>
31 #include <memory>
32 #include <pdcom5_export.h>
33 #include <string>
34 #include <vector>
35 
36 namespace PdCom {
37 namespace impl {
38 class Process;
39 }
40 
41 enum class LogLevel : int {
42  Reset = -1,
43  Emergency = 0,
44  Alert = 1,
45  Critical = 2,
46  Error = 3,
47  Warn = 4,
48  Info = 6,
49  Debug = 7,
50  Trace = 8,
51 };
52 
54 struct Message
55 {
56  uint32_t seqNo;
58  LogLevel level;
59  std::string path;
60  std::chrono::nanoseconds time;
61  std::string text;
62  int index;
64 };
65 
66 class PDCOM5_PUBLIC MessageManagerBase
67 {
68  public:
71  MessageManagerBase(MessageManagerBase const &) = delete;
72  MessageManagerBase &operator=(MessageManagerBase &&) noexcept;
73  MessageManagerBase &operator=(MessageManagerBase const &) = delete;
74 
75  protected:
85  void getMessage(uint32_t seqNo) const;
86 
93  void activeMessages() const;
94 
95  virtual ~MessageManagerBase();
96 
97  private:
98  friend impl::Process;
99  std::weak_ptr<impl::Process> process_;
100 
110  virtual void processMessage(Message message);
111 
118  virtual void getMessageReply(Message message);
119 
129  virtual void activeMessagesReply(std::vector<Message> messageList);
130 };
131 } // namespace PdCom
132 
133 
134 #endif // PDCOM5_MESSAGEMANAGERBASE_H
uint32_t seqNo
sequence number.
Definition: MessageManagerBase.h:56
int index
-1 for scalar; index in case of a vector
Definition: MessageManagerBase.h:62
std::string path
event&#39;s path
Definition: MessageManagerBase.h:59
LogLevel level
severity
Definition: MessageManagerBase.h:58
Definition: MessageManagerBase.h:66
std::string text
Text of message.
Definition: MessageManagerBase.h:61
Message structure.
Definition: MessageManagerBase.h:54
Definition: ClientStatistics.h:31
std::chrono::nanoseconds time
event time in nanoseconds since epoch
Definition: MessageManagerBase.h:60