-
Notifications
You must be signed in to change notification settings - Fork 90
/
serdata.hpp
94 lines (81 loc) · 2.52 KB
/
serdata.hpp
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright 2019 ADLINK Technology
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SERDATA_HPP_
#define SERDATA_HPP_
#include <memory>
#include <string>
#include "TypeSupport2.hpp"
#include "bytewise.hpp"
#include "dds/ddsi/ddsi_serdata.h"
#include "dds/ddsi/ddsi_sertopic.h"
namespace rmw_cyclonedds_cpp
{
class BaseCDRWriter;
}
struct CddsTypeSupport
{
void * type_support_;
const char * typesupport_identifier_;
};
struct sertopic_rmw : ddsi_sertopic
{
CddsTypeSupport type_support;
bool is_request_header;
#if !DDSI_SERTOPIC_HAS_TOPICKIND_NO_KEY
std::string cpp_name;
std::string cpp_type_name;
std::string cpp_name_type_name;
#endif
std::unique_ptr<const rmw_cyclonedds_cpp::BaseCDRWriter> cdr_writer;
};
class serdata_rmw : public ddsi_serdata
{
protected:
size_t m_size {0};
/* first two bytes of data is CDR encoding
second two bytes are encoding options */
std::unique_ptr<byte[]> m_data {nullptr};
public:
serdata_rmw(const ddsi_sertopic * topic, ddsi_serdata_kind kind);
void resize(size_t requested_size);
size_t size() const {return m_size;}
void * data() const {return m_data.get();}
};
typedef struct cdds_request_header
{
uint64_t guid;
int64_t seq;
} cdds_request_header_t;
typedef struct cdds_request_wrapper
{
cdds_request_header_t header;
void * data;
} cdds_request_wrapper_t;
void * create_message_type_support(
const void * untyped_members,
const char * typesupport_identifier);
void * create_request_type_support(
const void * untyped_members,
const char * typesupport_identifier);
void * create_response_type_support(
const void * untyped_members,
const char * typesupport_identifier);
struct sertopic_rmw * create_sertopic(
const char * topicname, const char * type_support_identifier,
void * type_support, bool is_request_header,
std::unique_ptr<rmw_cyclonedds_cpp::StructValueType> message_type_support);
struct ddsi_serdata * serdata_rmw_from_serialized_message(
const struct ddsi_sertopic * topiccmn,
const void * raw, size_t size);
#endif // SERDATA_HPP_