ifw-daq  3.0.0-pre2
IFW Data Acquisition modules
daqifFake.hpp
Go to the documentation of this file.
1 #ifndef DAQ_OCM_SERVER_FAKE_OCM_SERVER_IF_HPP_
2 #define DAQ_OCM_SERVER_FAKE_OCM_SERVER_IF_HPP_
3 
4 #include <Daqif.hpp>
5 namespace daqif {
6 
7 struct DaqReplyFake : DaqReply {
8  std::string m_id;
9  bool m_error;
10 
11  std::string getId() const override {
12  return m_id;
13  }
14  void setId(std::string const& id) override {
15  m_id = id;
16  }
17 
18  bool getError() const override {
19  return m_error;
20  }
21  void setError(bool error) override {
22  m_error = error;
23  }
24  // Mal pub/sub API which has nothing to do with req rep.
25  bool hasKey() const override {
26  return false;
27  }
28  bool keyEquals(const DaqReply& other) const override {
29  return false;
30  }
31  std::unique_ptr<DaqReply> cloneKey() const override {
32  return {};
33  }
34  std::unique_ptr<DaqReply> clone() const override {
35  return {};
36  }
37 };
38 
39 struct DaqStatusFake : DaqStatus {
40  std::string m_id;
41  std::string m_file_id;
42  std::string m_message;
43  daqif::DaqState m_state;
44  daqif::DaqSubState m_sub_state;
45  bool m_error;
46  std::string m_result;
47  double m_timestamp;
48 
49  std::string getId() const override {
50  return m_id;
51  }
52  void setId(std::string const& id) override {
53  m_id = id;
54  }
55  std::string getFileId() const override {
56  return m_file_id;
57  }
58  void setFileId(std::string const& id) override {
59  m_file_id = id;
60  }
61  std::string getMessage() const override {
62  return m_message;
63  }
64  void setMessage(std::string const& message) override {
65  m_message = message;
66  }
67  daqif::DaqState getState() const override {
68  return m_state;
69  }
70  void setState(daqif::DaqState s) override {
71  m_state = s;
72  }
73  daqif::DaqSubState getSubState() const override {
74  return m_sub_state;
75  }
76  void setSubState(daqif::DaqSubState s) override {
77  m_sub_state = s;
78  }
79  bool getError() const override {
80  return m_error;
81  }
82  void setError(bool e) override {
83  m_error = e;
84  }
85  std::string getResult() const override {
86  return m_result;
87  }
88  void setResult(std::string const& result) override {
89  m_result = result;
90  }
91  double getTimestamp() const override {
92  return m_timestamp;
93  }
94  void setTimestamp(double d) override {
95  m_timestamp = d;
96  }
97 
98  // Mal pub/sub API which has nothing to do with req rep.
99  bool hasKey() const override {
100  return false;
101  }
102  bool keyEquals(const DaqStatus& other) const override {
103  return false;
104  }
105  std::unique_ptr<DaqStatus> cloneKey() const override {
106  return {};
107  }
108  std::unique_ptr<DaqStatus> clone() const override {
109  return {};
110  }
111 };
112 
113 struct AwaitDaqReplyFake : AwaitDaqReply {
114  AwaitDaqReplyFake() : m_timeout(false), m_status(std::make_shared<DaqStatusFake>()) {
115  }
116  bool getTimeout() const override {
117  return m_timeout;
118  }
119  void setTimeout(bool t) override {
120  m_timeout = t;
121  }
122  std::shared_ptr<daqif::DaqStatus> getStatus() const override {
123  return m_status;
124  }
125 
126  // Mal pub/sub API which has nothing to do with req rep.
127  bool hasKey() const override {
128  return false;
129  }
130  bool keyEquals(const AwaitDaqReply& other) const override {
131  return false;
132  }
133  std::unique_ptr<AwaitDaqReply> cloneKey() const override {
134  return {};
135  }
136  std::unique_ptr<AwaitDaqReply> clone() const override {
137  return {};
138  }
139 
140  bool m_timeout;
141  std::shared_ptr<DaqStatusFake> m_status;
142 };
143 
144 struct StorageStatusFake : StorageStatus {
145  uint64_t m_free = 0;
146  uint64_t m_available = 0;
147  uint64_t m_capacity = 0;
148 
149  uint64_t getFree() const override {
150  return m_free;
151  }
152  void setFree(uint64_t free) override {
153  m_free = free;
154  }
155  uint64_t getCapacity() const override {
156  return m_capacity;
157  }
158  void setCapacity(uint64_t capacity) override {
159  m_capacity = capacity;
160  }
161  uint64_t getAvailable() const override {
162  return m_available;
163  }
164  void setAvailable(uint64_t available) override {
165  m_available = available;
166  }
167  // Mal pub/sub API which has nothing to do with req rep.
168  bool hasKey() const override {
169  return false;
170  }
171  bool keyEquals(const StorageStatus& other) const override {
172  return false;
173  }
174  std::unique_ptr<StorageStatus> cloneKey() const override {
175  return {};
176  }
177  std::unique_ptr<StorageStatus> clone() const override {
178  return {};
179  }
180 };
181 
182 } // namespace daqif
183 #endif // #ifndef DAQ_OCM_SERVER_FAKE_OCM_SERVER_IF_HPP_
Definition: main.cpp:23
std::unique_ptr< AwaitDaqReply > clone() const override
Definition: daqifFake.hpp:136
std::unique_ptr< AwaitDaqReply > cloneKey() const override
Definition: daqifFake.hpp:133
bool getTimeout() const override
Definition: daqifFake.hpp:116
std::shared_ptr< DaqStatusFake > m_status
Definition: daqifFake.hpp:141
void setTimeout(bool t) override
Definition: daqifFake.hpp:119
bool hasKey() const override
Definition: daqifFake.hpp:127
std::shared_ptr< daqif::DaqStatus > getStatus() const override
Definition: daqifFake.hpp:122
bool keyEquals(const AwaitDaqReply &other) const override
Definition: daqifFake.hpp:130
std::unique_ptr< DaqReply > clone() const override
Definition: daqifFake.hpp:34
bool hasKey() const override
Definition: daqifFake.hpp:25
void setError(bool error) override
Definition: daqifFake.hpp:21
std::string m_id
Definition: daqifFake.hpp:8
bool getError() const override
Definition: daqifFake.hpp:18
void setId(std::string const &id) override
Definition: daqifFake.hpp:14
std::unique_ptr< DaqReply > cloneKey() const override
Definition: daqifFake.hpp:31
bool keyEquals(const DaqReply &other) const override
Definition: daqifFake.hpp:28
std::string getId() const override
Definition: daqifFake.hpp:11
void setError(bool e) override
Definition: daqifFake.hpp:82
std::string getMessage() const override
Definition: daqifFake.hpp:61
std::string getFileId() const override
Definition: daqifFake.hpp:55
daqif::DaqState getState() const override
Definition: daqifFake.hpp:67
void setSubState(daqif::DaqSubState s) override
Definition: daqifFake.hpp:76
std::string m_id
Definition: daqifFake.hpp:40
std::string getId() const override
Definition: daqifFake.hpp:49
std::string m_file_id
Definition: daqifFake.hpp:41
void setMessage(std::string const &message) override
Definition: daqifFake.hpp:64
bool getError() const override
Definition: daqifFake.hpp:79
bool hasKey() const override
Definition: daqifFake.hpp:99
void setTimestamp(double d) override
Definition: daqifFake.hpp:94
double getTimestamp() const override
Definition: daqifFake.hpp:91
daqif::DaqState m_state
Definition: daqifFake.hpp:43
void setId(std::string const &id) override
Definition: daqifFake.hpp:52
std::string m_result
Definition: daqifFake.hpp:46
std::string m_message
Definition: daqifFake.hpp:42
void setState(daqif::DaqState s) override
Definition: daqifFake.hpp:70
std::unique_ptr< DaqStatus > clone() const override
Definition: daqifFake.hpp:108
std::unique_ptr< DaqStatus > cloneKey() const override
Definition: daqifFake.hpp:105
daqif::DaqSubState getSubState() const override
Definition: daqifFake.hpp:73
bool keyEquals(const DaqStatus &other) const override
Definition: daqifFake.hpp:102
void setResult(std::string const &result) override
Definition: daqifFake.hpp:88
void setFileId(std::string const &id) override
Definition: daqifFake.hpp:58
daqif::DaqSubState m_sub_state
Definition: daqifFake.hpp:44
std::string getResult() const override
Definition: daqifFake.hpp:85
void setAvailable(uint64_t available) override
Definition: daqifFake.hpp:164
std::unique_ptr< StorageStatus > clone() const override
Definition: daqifFake.hpp:177
uint64_t getCapacity() const override
Definition: daqifFake.hpp:155
void setCapacity(uint64_t capacity) override
Definition: daqifFake.hpp:158
bool hasKey() const override
Definition: daqifFake.hpp:168
bool keyEquals(const StorageStatus &other) const override
Definition: daqifFake.hpp:171
uint64_t getFree() const override
Definition: daqifFake.hpp:149
uint64_t getAvailable() const override
Definition: daqifFake.hpp:161
void setFree(uint64_t free) override
Definition: daqifFake.hpp:152
std::unique_ptr< StorageStatus > cloneKey() const override
Definition: daqifFake.hpp:174