RTI Connext Traditional C++ API Version 7.3.0
FlatSampleImpl.hpp
1/*
2(c) Copyright, Real-Time Innovations, 2018.
3All rights reserved.
4
5No duplications, whole or partial, manual or electronic, may be made
6without express written permission. Any such copies, or
7revisions thereof, must display this notice unaltered.
8This code contains trade secrets of Real-Time Innovations, Inc.
9*/
10
11#ifndef RTI_DDS_FLAT_FLATSAMPLEIMPL_HPP_
12#define RTI_DDS_FLAT_FLATSAMPLEIMPL_HPP_
13
14// This file includes the implementation of some templates that need to
15// appear after some types are defined in the generated code. This is a
16// a restriction on some platforms such as pentiumInty11.pcx64 and other Intys,
17// sparcSol2.10gcc3.4.2.
18
19// For example, type_programs<T> needs to be defined (as an specialization
20// for T) before its used in create_data().
21
22#include "rti/flat/FlatSample.hpp"
23
24namespace rti { namespace flat {
25
26namespace detail {
27
28template <typename OffsetType>
29Sample<OffsetType>* create_data_impl(fixed_size_type_tag_t)
30{
31 unsigned char *buffer = RTIXCdrFlatData_createSampleFinal(
32 OffsetType::serialized_size(0),
33 rti::xcdr::type_programs<Sample<OffsetType> >::get());
34
35 if (buffer == NULL) {
36 #ifndef RTI_FLAT_DATA_NO_EXCEPTIONS
37 throw std::bad_alloc();
38 #else
39 return NULL;
40 #endif
41 }
42
43 return reinterpret_cast<rti::flat::Sample<OffsetType> *>(buffer);
44}
45
46template <typename OffsetType>
47Sample<OffsetType>* create_data_impl(variable_size_type_tag_t)
48{
49 unsigned char *buffer = RTIXCdrFlatData_createSampleMutable(
50 rti::xcdr::type_programs<Sample<OffsetType> >::get());
51
52 if (buffer == NULL) {
53 #ifndef RTI_FLAT_DATA_NO_EXCEPTIONS
54 throw std::bad_alloc();
55 #else
56 return NULL;
57 #endif
58 }
59
60 return reinterpret_cast<rti::flat::Sample<OffsetType> *>(buffer);
61}
62
63}
64
65// Declared in FlatSample.hpp
66template <typename OffsetType>
68{
69 return detail::create_data_impl<OffsetType>(
70 typename OffsetType::offset_kind());
71}
72
73} }
74
75#endif // RTI_DDS_FLAT_FLATSAMPLEIMPL_HPP_
76
The generic definition of FlatData topic-types.
Definition: FlatSample.hpp:148
static Sample< OffsetType > * create_data()
Creates an unmanaged FlatData Sample.
Definition: FlatSampleImpl.hpp:67
The RTI namespace.
Definition: AggregationBuilders.hpp:17