SSCMA-Micro CPP SDK  v2.0.0
SSCMA-Micro is a cross-platform machine learning inference framework designed for embedded devices.
ma_codec_base.h
Go to the documentation of this file.
1 #ifndef _MA_CODEC_BASE_H_
2 #define _MA_CODEC_BASE_H_
3 
4 
5 #include <forward_list>
6 #include <string>
7 #include <vector>
8 
9 #include "core/ma_common.h"
10 #include "porting/ma_sensor.h"
11 
12 namespace ma {
13 
14 class Encoder {
15 public:
16  Encoder() = default;
17  virtual ~Encoder() = default;
18 
25  virtual operator bool() const = 0;
26 
32  virtual ma_err_t begin() = 0;
33 
42  virtual ma_err_t begin(ma_msg_type_t type, ma_err_t code, const std::string& name) = 0;
43 
53  virtual ma_err_t begin(ma_msg_type_t type, ma_err_t code, const std::string& name, const std::string& data) = 0;
54 
55 
65  virtual ma_err_t begin(ma_msg_type_t type, ma_err_t code, const std::string& name, uint64_t data) = 0;
66 
72  virtual ma_err_t end() = 0;
73 
79  virtual ma_err_t reset() = 0;
80 
81 
87  virtual const std::string& toString() const = 0;
88 
94  virtual const void* data() const = 0;
95 
101  virtual const size_t size() const = 0;
102 
109  virtual ma_err_t remove(const std::string& key) = 0;
110 
118  virtual ma_err_t write(const std::string& key, int8_t value) = 0;
119 
127  virtual ma_err_t write(const std::string& key, int16_t value) = 0;
128 
136  virtual ma_err_t write(const std::string& key, int32_t value) = 0;
137 
145  virtual ma_err_t write(const std::string& key, int64_t value) = 0;
146 
154  virtual ma_err_t write(const std::string& key, uint8_t value) = 0;
155 
163  virtual ma_err_t write(const std::string& key, uint16_t value) = 0;
164 
172  virtual ma_err_t write(const std::string& key, uint32_t value) = 0;
173 
181  virtual ma_err_t write(const std::string& key, uint64_t value) = 0;
182 
190  virtual ma_err_t write(const std::string& key, float value) = 0;
191 
199  virtual ma_err_t write(const std::string& key, double value) = 0;
200 
208  virtual ma_err_t write(const std::string& key, const std::string& value) = 0;
209 
217  virtual ma_err_t write(const std::string& key, ma_model_t value) = 0;
218 
225  virtual ma_err_t write(ma_perf_t value) = 0;
226 
233  virtual ma_err_t write(const std::forward_list<ma_class_t>& value) = 0;
234 
241  virtual ma_err_t write(const std::forward_list<ma_point_t>& value) = 0;
242 
249  virtual ma_err_t write(const std::forward_list<ma_bbox_t>& value) = 0;
250 
257  virtual ma_err_t write(const std::forward_list<ma_keypoint3f_t>& value) = 0;
258 
265  virtual ma_err_t write(const std::vector<ma_model_t>& value) = 0;
266 
267  virtual ma_err_t write(const std::vector<Sensor*>& value) = 0;
268 
269  virtual ma_err_t write(const Sensor* value, size_t preset) = 0;
270 
271  virtual ma_err_t write(const std::string& key, const char* buffer, size_t size) = 0;
272 
273 
274  virtual ma_err_t write(const in4_info_t& value) = 0;
275  virtual ma_err_t write(const in6_info_t& value) = 0;
276 
277  virtual ma_err_t write(const ma_wifi_config_t& value, int* stat = nullptr) = 0;
278 
279  virtual ma_err_t write(const ma_mqtt_config_t& value, int* stat = nullptr) = 0;
280 
281  virtual ma_err_t write(const ma_mqtt_topic_config_t& value) = 0;
282 
283  virtual ma_err_t write(int algo_id, int cat, int input_from, int tscore, int tiou) = 0;
284 };
285 
286 class Decoder {
287 public:
288  virtual ~Decoder() = default;
289 
290  virtual operator bool() const = 0;
291 
292  virtual ma_err_t begin(const void* data, size_t size) = 0;
293  virtual ma_err_t begin(const std::string& str) = 0;
294  virtual ma_err_t end() = 0;
295 
296  virtual ma_msg_type_t type() const = 0;
297  virtual ma_err_t code() const = 0;
298  virtual std::string name() const = 0;
299 
300 
301  virtual ma_err_t read(const std::string& key, int8_t& value) const = 0;
302  virtual ma_err_t read(const std::string& key, int16_t& value) const = 0;
303  virtual ma_err_t read(const std::string& key, int32_t& value) const = 0;
304  virtual ma_err_t read(const std::string& key, int64_t& value) const = 0;
305  virtual ma_err_t read(const std::string& key, uint8_t& value) const = 0;
306  virtual ma_err_t read(const std::string& key, uint16_t& value) const = 0;
307  virtual ma_err_t read(const std::string& key, uint32_t& value) const = 0;
308  virtual ma_err_t read(const std::string& key, uint64_t& value) const = 0;
309  virtual ma_err_t read(const std::string& key, float& value) const = 0;
310  virtual ma_err_t read(const std::string& key, double& value) const = 0;
311  virtual ma_err_t read(const std::string& key, std::string& value) const = 0;
312  virtual ma_err_t read(ma_perf_t& value) = 0;
313  virtual ma_err_t read(std::forward_list<ma_class_t>& value) = 0;
314  virtual ma_err_t read(std::forward_list<ma_point_t>& value) = 0;
315  virtual ma_err_t read(std::forward_list<ma_bbox_t>& value) = 0;
316 };
317 
318 } // namespace ma
319 
320 #endif // _MA_CODEC_BASE_H_
Definition: ma_codec_base.h:286
virtual ma_err_t read(const std::string &key, uint16_t &value) const =0
virtual ma_err_t read(const std::string &key, uint32_t &value) const =0
virtual ma_err_t read(ma_perf_t &value)=0
virtual ma_err_t begin(const void *data, size_t size)=0
virtual ma_err_t read(const std::string &key, int8_t &value) const =0
virtual ma_err_t read(std::forward_list< ma_point_t > &value)=0
virtual ma_err_t read(std::forward_list< ma_bbox_t > &value)=0
virtual ma_err_t read(const std::string &key, float &value) const =0
virtual ma_err_t read(const std::string &key, int64_t &value) const =0
virtual ma_err_t end()=0
virtual ma_err_t read(const std::string &key, uint8_t &value) const =0
virtual ma_msg_type_t type() const =0
virtual ma_err_t code() const =0
virtual ma_err_t read(std::forward_list< ma_class_t > &value)=0
virtual ma_err_t read(const std::string &key, int16_t &value) const =0
virtual ma_err_t begin(const std::string &str)=0
virtual ma_err_t read(const std::string &key, std::string &value) const =0
virtual ~Decoder()=default
virtual ma_err_t read(const std::string &key, double &value) const =0
virtual std::string name() const =0
virtual ma_err_t read(const std::string &key, int32_t &value) const =0
virtual ma_err_t read(const std::string &key, uint64_t &value) const =0
Definition: ma_codec_base.h:14
virtual ma_err_t end()=0
Encoder type for end.
Encoder()=default
virtual ma_err_t write(const std::string &key, uint32_t value)=0
Encoder type for write uint32_t value.
virtual ma_err_t write(const std::forward_list< ma_class_t > &value)=0
Encoder type for write std::forward_list<ma_class_t> value.
virtual ma_err_t begin(ma_msg_type_t type, ma_err_t code, const std::string &name)=0
Encoder type for begin.
virtual ma_err_t write(const std::string &key, double value)=0
Encoder type for write double value.
virtual const void * data() const =0
Encoder type for get data.
virtual ma_err_t write(const std::string &key, uint16_t value)=0
Encoder type for write uint16_t value.
virtual ma_err_t write(const std::string &key, const char *buffer, size_t size)=0
virtual ma_err_t write(const std::string &key, uint64_t value)=0
Encoder type for write uint64_t value.
virtual ma_err_t reset()=0
Reset the proto object.
virtual ma_err_t write(const std::string &key, float value)=0
Encoder type for write float value.
virtual ma_err_t remove(const std::string &key)=0
Encoder type for remove.
virtual ma_err_t write(const in4_info_t &value)=0
virtual ~Encoder()=default
virtual const std::string & toString() const =0
Encoder type for convert to string.
virtual ma_err_t write(const std::string &key, int32_t value)=0
Encoder type for write int32_t value.
virtual ma_err_t write(ma_perf_t value)=0
Encoder type for write ma_perf_t.
virtual ma_err_t write(const std::string &key, int16_t value)=0
Encoder type for write int16_t value.
virtual ma_err_t write(const ma_mqtt_config_t &value, int *stat=nullptr)=0
virtual ma_err_t write(const std::forward_list< ma_keypoint3f_t > &value)=0
Encoder type for write std::forward_list<ma_keypoint3f_t> value.
virtual ma_err_t write(const ma_mqtt_topic_config_t &value)=0
virtual ma_err_t begin()=0
Encoder type for begin.
virtual ma_err_t write(const std::string &key, int8_t value)=0
Encoder type for write int8_t value.
virtual ma_err_t write(const std::string &key, ma_model_t value)=0
Encoder type for write ma_model_t value.
virtual ma_err_t write(int algo_id, int cat, int input_from, int tscore, int tiou)=0
virtual const size_t size() const =0
Encoder type for get size.
virtual ma_err_t write(const ma_wifi_config_t &value, int *stat=nullptr)=0
virtual ma_err_t begin(ma_msg_type_t type, ma_err_t code, const std::string &name, uint64_t data)=0
Encoder type for begin.
virtual ma_err_t write(const std::forward_list< ma_point_t > &value)=0
Encoder type for write std::vector<ma_point_t> value.
virtual ma_err_t write(const std::string &key, int64_t value)=0
Encoder type for write int64_t value.
virtual ma_err_t write(const std::string &key, uint8_t value)=0
Encoder type for write uint8_t value.
virtual ma_err_t begin(ma_msg_type_t type, ma_err_t code, const std::string &name, const std::string &data)=0
Encoder type for begin.
virtual ma_err_t write(const Sensor *value, size_t preset)=0
virtual ma_err_t write(const std::vector< Sensor * > &value)=0
virtual ma_err_t write(const std::forward_list< ma_bbox_t > &value)=0
Encoder type for write std::forward_list<ma_bbox_t> value.
virtual ma_err_t write(const std::string &key, const std::string &value)=0
Encoder type for write const std::string value.
virtual ma_err_t write(const in6_info_t &value)=0
virtual ma_err_t write(const std::vector< ma_model_t > &value)=0
Encoder type for write std::forward_list<ma_model_t> value.
Definition: ma_sensor.h:12
ma_msg_type_t
Definition: ma_types.h:252
ma_err_t
Definition: ma_types.h:21
Definition: ma_cv.cpp:7
Definition: ma_types.h:289
Definition: ma_types.h:314
Definition: ma_types.h:323
Definition: ma_types.h:138
Definition: ma_types.h:300