-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmessage_codec.h
More file actions
63 lines (44 loc) · 1.72 KB
/
Copy pathmessage_codec.h
File metadata and controls
63 lines (44 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef DELTIX_API_MESSAGE_CODEC_H_
#define DELTIX_API_MESSAGE_CODEC_H_
#include "Python.h"
#include "schema.h"
#include "data_reader.h"
#include "data_writer.h"
#include <algorithm>
#include <memory>
namespace TbApiImpl {
namespace Python {
class FieldCodec;
class PythonTbApiModule;
typedef std::vector<Schema::TickDbClassDescriptor> ClassDescriptors;
typedef std::shared_ptr<FieldCodec> FieldCodecPtr;
class MessageCodec {
public:
MessageCodec(const ClassDescriptors &descriptors, intptr_t num);
MessageCodec(PythonTbApiModule *tbapi_module, const ClassDescriptors &descriptors, intptr_t num);
~MessageCodec();
void decode(PyObject *message, DxApi::DataReader &reader);
void encode(PyObject *message, DxApi::DataWriter &writer);
private:
void buildDecoders(const ClassDescriptors &descriptors, intptr_t num);
void collectFields(std::vector<Schema::FieldInfo> &fields,
const ClassDescriptors &descriptors,
intptr_t index);
std::vector<FieldCodecPtr> buildFieldDecoders(
std::vector<Schema::FieldInfo> &fields,
const ClassDescriptors &descriptors);
FieldCodecPtr createFieldCodec(
Schema::DataType &data_type, std::string &field_name, std::string &relative_to,
const ClassDescriptors &descriptors);
int32_t findDescriptorByGuid(const ClassDescriptors &descriptors, const std::string &guid);
template<typename CODEC_TYPE>
CODEC_TYPE findRelativeTo(std::string &relativeTo);
private:
std::vector<FieldCodecPtr> field_codecs_;
std::unordered_map<std::string, FieldCodecPtr> codecs_search_map_;
PythonTbApiModule *tbapi_module_ = NULL;
};
typedef std::shared_ptr<MessageCodec> MessageCodecPtr;
}
}
#endif //DELTIX_API_MESSAGE_CODEC_H_