RTI Connext Traditional C++ API  Version 6.0.0
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FlatSampleImpl.hpp
1 /*
2 (c) Copyright, Real-Time Innovations, 2018.
3 All rights reserved.
4 
5 No duplications, whole or partial, manual or electronic, may be made
6 without express written permission. Any such copies, or
7 revisions thereof, must display this notice unaltered.
8 This 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 
24 namespace rti { namespace flat {
25 
26 namespace detail {
27 
28 template <typename OffsetType>
29 Sample<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 
46 template <typename OffsetType>
47 Sample<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
66 template <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 

RTI Connext Traditional C++ API Version 6.0.0 Copyright © Sun Mar 3 2019 Real-Time Innovations, Inc