00001
00002
00003
00004
00005
00006
00007
00008 #ifndef OPENDDS_DCPS_DATASAMPLEHEADER_H
00009 #define OPENDDS_DCPS_DATASAMPLEHEADER_H
00010
00011 #include "Definitions.h"
00012 #include "GuidUtils.h"
00013
00014 #include <iosfwd>
00015
00016 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00017 #pragma once
00018 #endif
00019
00020 namespace OpenDDS {
00021 namespace DCPS {
00022
00023 class ReceivedDataSample;
00024
00025
00026 enum MessageId {
00027 SAMPLE_DATA,
00028 DATAWRITER_LIVELINESS,
00029 INSTANCE_REGISTRATION,
00030 UNREGISTER_INSTANCE,
00031 DISPOSE_INSTANCE,
00032 GRACEFUL_DISCONNECT,
00033 REQUEST_ACK,
00034 SAMPLE_ACK,
00035 END_COHERENT_CHANGES,
00036 TRANSPORT_CONTROL,
00037 DISPOSE_UNREGISTER_INSTANCE,
00038 END_HISTORIC_SAMPLES,
00039 MESSAGE_ID_MAX
00040 };
00041
00042 enum SubMessageId {
00043 SUBMESSAGE_NONE,
00044 MULTICAST_SYN,
00045 MULTICAST_SYNACK,
00046 MULTICAST_NAK,
00047 MULTICAST_NAKACK,
00048 SUBMESSAGE_ID_MAX
00049 };
00050
00051 enum DataSampleHeaderFlag {
00052 BYTE_ORDER_FLAG,
00053 COHERENT_CHANGE_FLAG,
00054 HISTORIC_SAMPLE_FLAG,
00055 LIFESPAN_DURATION_FLAG,
00056 GROUP_COHERENT_FLAG,
00057 CONTENT_FILTER_FLAG,
00058 SEQUENCE_REPAIR_FLAG,
00059 MORE_FRAGMENTS_FLAG
00060 };
00061
00062 enum DataSampleHeaderFlag2 {
00063 CDR_ENCAP_FLAG,
00064 KEY_ONLY_FLAG
00065 };
00066
00067
00068
00069
00070 struct OpenDDS_Dcps_Export DataSampleHeader {
00071 enum {
00072 MESSAGE_ID_OFFSET = 0,
00073 SUBMESSAGE_ID_OFFSET = 1,
00074 FLAGS_OFFSET = 2
00075 };
00076
00077
00078 char message_id_;
00079
00080
00081 char submessage_id_;
00082
00083
00084
00085 bool byte_order_ : 1;
00086
00087
00088
00089 bool coherent_change_ : 1;
00090
00091
00092
00093 bool historic_sample_ : 1;
00094
00095
00096
00097 bool lifespan_duration_ : 1;
00098
00099 bool group_coherent_ : 1;
00100
00101
00102
00103 bool content_filter_ : 1;
00104
00105
00106
00107
00108 bool sequence_repair_ : 1;
00109
00110
00111 bool more_fragments_ : 1;
00112
00113
00114
00115
00116
00117
00118
00119
00120 bool cdr_encapsulation_ : 1;
00121
00122
00123 bool key_fields_only_ : 1;
00124
00125 bool reserved_1 : 1;
00126 bool reserved_2 : 1;
00127 bool reserved_3 : 1;
00128 bool reserved_4 : 1;
00129 bool reserved_5 : 1;
00130 bool reserved_6 : 1;
00131
00132
00133
00134
00135 ACE_UINT32 message_length_;
00136
00137
00138
00139
00140 SequenceNumber sequence_;
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 ACE_INT32 source_timestamp_sec_;
00152 ACE_UINT32 source_timestamp_nanosec_;
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 ACE_INT32 lifespan_duration_sec_;
00163 ACE_UINT32 lifespan_duration_nanosec_;
00164
00165
00166
00167
00168 PublicationId publication_id_;
00169
00170
00171
00172 RepoId publisher_id_;
00173
00174
00175
00176 GUIDSeq content_filter_entries_;
00177
00178 static ACE_UINT8 mask_flag(DataSampleHeaderFlag flag) { return 1 << flag; }
00179 static ACE_UINT8 mask_flag(DataSampleHeaderFlag2 flag) { return 1 << flag; }
00180
00181 static void clear_flag(DataSampleHeaderFlag flag,
00182 ACE_Message_Block* buffer);
00183
00184 static void set_flag(DataSampleHeaderFlag flag,
00185 ACE_Message_Block* buffer);
00186
00187 static bool test_flag(DataSampleHeaderFlag flag,
00188 const ACE_Message_Block* buffer);
00189
00190
00191 static bool partial(const ACE_Message_Block& mb);
00192
00193
00194
00195
00196
00197 static void add_cfentries(const GUIDSeq* guids, ACE_Message_Block* mb);
00198
00199
00200
00201 static void split(const ACE_Message_Block& orig, size_t size,
00202 ACE_Message_Block*& head, ACE_Message_Block*& tail);
00203
00204
00205
00206
00207
00208 static bool join(const DataSampleHeader& first,
00209 const DataSampleHeader& second, DataSampleHeader& result);
00210
00211 DataSampleHeader();
00212
00213
00214 explicit DataSampleHeader(ACE_Message_Block& buffer);
00215
00216
00217 DataSampleHeader& operator=(ACE_Message_Block& buffer);
00218
00219
00220 size_t marshaled_size() const;
00221
00222
00223 static size_t max_marshaled_size();
00224
00225
00226 void init(ACE_Message_Block* buffer);
00227
00228 bool into_received_data_sample(ReceivedDataSample& rds);
00229
00230 ACE_UINT32 message_length() const { return this->message_length_; }
00231
00232 bool more_fragments() const { return this->more_fragments_; }
00233
00234 void pdu_remaining(size_t) { }
00235
00236 static ACE_Message_Block* alloc_msgblock(const ACE_Message_Block& mb,
00237 size_t size, bool use_data_alloc);
00238
00239 static void split_payload(const ACE_Message_Block& orig, size_t size,
00240 ACE_Message_Block*& head, ACE_Message_Block*& tail);
00241
00242 private:
00243
00244 size_t marshaled_size_;
00245 };
00246
00247 const char* to_string(const MessageId value);
00248 const char* to_string(const SubMessageId value);
00249 OPENDDS_STRING to_string(const DataSampleHeader& value);
00250
00251
00252 OpenDDS_Dcps_Export
00253 bool operator<<(ACE_Message_Block&, const DataSampleHeader& value);
00254
00255 #ifndef OPENDDS_SAFETY_PROFILE
00256
00257 OpenDDS_Dcps_Export
00258 std::ostream& operator<<(std::ostream& str, const MessageId value);
00259
00260
00261 OpenDDS_Dcps_Export
00262 std::ostream& operator<<(std::ostream& os, const SubMessageId rhs);
00263
00264
00265 OpenDDS_Dcps_Export
00266 std::ostream& operator<<(std::ostream& str, const DataSampleHeader& value);
00267 #endif //OPENDDS_SAFETY_PROFILE
00268
00269 }
00270 }
00271
00272 #if defined(__ACE_INLINE__)
00273 #include "DataSampleHeader.inl"
00274 #endif
00275
00276 #endif