-
Notifications
You must be signed in to change notification settings - Fork 82
/
HelloWorld.h
96 lines (78 loc) · 2.64 KB
/
HelloWorld.h
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
95
96
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// 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.
/*!
* @file HelloWorld.h
* This header file contains the declaration of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifndef _HelloWorld_H_
#define _HelloWorld_H_
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <micrortps/client/xrce_client.h>
/*!
* @brief This class represents the structure HelloWorld defined by the user in the IDL file.
* @ingroup HELLOWORLD
*/
typedef struct HelloWorld
{
uint32_t index;
char* message;
} HelloWorld;
static bool serialize_HelloWorld_topic(MicroBuffer* writer, const HelloWorld* topic)
{
serialize_uint32_t(writer, topic->index);
serialize_sequence_char(writer, topic->message, (uint32_t)(strlen(topic->message) + 1));
return writer->error == BUFFER_OK;
}
static bool deserialize_HelloWorld_topic(MicroBuffer* reader, HelloWorld* topic)
{
deserialize_uint32_t(reader, &topic->index);
uint32_t size_message = 0;
deserialize_sequence_char(reader, &topic->message, &size_message);
return reader->error == BUFFER_OK;
}
static uint32_t size_of_HelloWorld_topic(const HelloWorld* topic)
{
uint32_t size = 0;
size += 4 + get_alignment(size, 4);
size += 4 + get_alignment(size, 4) + (uint32_t)(strlen(topic->message) + 1);
return size;
}
static bool write_HelloWorld(Session* session, ObjectId datawriter_id, StreamId stream_id, HelloWorld* topic)
{
if (session == NULL)
{
return false;
}
bool result = false;
uint32_t topic_size = size_of_HelloWorld_topic(topic);
MicroBuffer* topic_buffer = NULL;
if (128 < stream_id)
{
topic_buffer = prepare_best_effort_stream_for_topic(&session->output_best_effort_stream, datawriter_id, (uint16_t)topic_size);
}
else
{
topic_buffer = prepare_reliable_stream_for_topic(&session->output_reliable_stream, datawriter_id, (uint16_t)topic_size);
}
if (topic_buffer != NULL)
{
result = serialize_HelloWorld_topic(topic_buffer, topic);
}
return result;
}
#endif // _HelloWorld_H_