KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Header6.h
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright 2013 Karl Jones
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25 For Further Information Please Contact me at
26 Karljj1@yahoo.com
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
29 
30 /********************************************************************
31  class: Header6
32  DIS: (5) 1278.1 - 1995
33  created: 03/02/2011
34  author: Karl Jones
35 
36  purpose: PDU Header. Contains infomation used to identify
37  the PDU type that is represented by the datagram.
38  This header contains all features upto DIS version 6(1278.1a),
39  for DIS 7 features use Header7.
40  Size: 96 bits / 12 octets
41 *********************************************************************/
42 
43 #pragma once
44 
45 #include "./../KDefines.h"
46 #include "./../DataTypes/Enums/KDISEnums.h"
47 #include "./../KEncodersDecoders.h"
48 #include "./../KDataStream.h"
49 #include "./../DataTypes/TimeStamp.h"
50 #include "./../Extras/KUtils.h"
51 
52 namespace KDIS {
53 namespace PDU {
54 
56 {
57 protected:
58 
60 
62 
64 
66 
68 
70 
71  KUINT8 m_ui8Padding1; // Padding except for Live Entity family which uses it for Sub protocol Number, if DIS version > 6 then used for sub protocol.
72 
74 
75 public:
76 
77  static const KUINT16 HEADER6_PDU_SIZE = 12;
78 
79  Header6();
80 
81  Header6( KDataStream & stream ) throw( KException );
82 
85 
86  virtual ~Header6();
87 
88  //************************************
89  // FullName: KDIS::PDU::Header6::SetProtocolVersion
90  // KDIS::PDU::Header6::GetProtocolVersion
91  //!Description: DIS protocol version.
92  //! In KDIS the version is automatically set by each PDU
93  //! to the mimimum version of DIS required to support the current PDU.
94  // Parameter: ProtocolVersion PV
95  //************************************
96  void SetProtocolVersion( KDIS::DATA_TYPE::ENUMS::ProtocolVersion PV );
97  KDIS::DATA_TYPE::ENUMS::ProtocolVersion GetProtocolVersion() const;
98 
99  //************************************
100  // FullName: KDIS::PDU::Header6::SetExerciseID
101  // KDIS::PDU::Header6::GetExerciseID
102  //!Description: Unique to each exercise being
103  //! conducted simultaneously.
104  // Parameter: KUINT8 ID
105  //************************************
106  void SetExerciseID( KUINT8 EID );
107  KUINT8 GetExerciseID() const;
108 
109  //************************************
110  // FullName: KDIS::PDU::Header6::SetPDUType
111  // KDIS::PDU::Header6::GetPDUType
112  //!Description: The type of PDU. Set by PDU automatically.
113  //! Only change if you know what you are doing.
114  // Parameter: PDUType Type
115  //************************************
116  void SetPDUType( KDIS::DATA_TYPE::ENUMS::PDUType Type );
117  KDIS::DATA_TYPE::ENUMS::PDUType GetPDUType() const;
118 
119  //************************************
120  // FullName: KDIS::PDU::Header6::SetProtocolFamily
121  // KDIS::PDU::Header6::GetProtocolFamily
122  //!Description: Family of protocols to which the PDU belongs
123  //! Set by PDU automatically.
124  //! Only change if you know what you are doing.
125  // Parameter: ProtocolFamily PF
126  //************************************
127  void SetProtocolFamily( KDIS::DATA_TYPE::ENUMS::ProtocolFamily PF );
128  KDIS::DATA_TYPE::ENUMS::ProtocolFamily GetProtocolFamily() const;
129 
130  //************************************
131  // FullName: KDIS::PDU::Header6::SetTimeStamp
132  // KDIS::PDU::Header6::GetTimeStamp
133  //!Description: Specifies the time which the data
134  //! in the PDU is valid.
135  // Parameter: const TimeStamp & TS
136  //************************************
137  void SetTimeStamp( const KDIS::DATA_TYPE::TimeStamp & TS );
138  const KDIS::DATA_TYPE::TimeStamp & GetTimeStamp() const;
139  KDIS::DATA_TYPE::TimeStamp & GetTimeStamp();
140 
141  //************************************
142  // FullName: KDIS::PDU::Header6::SetPDULength
143  // KDIS::PDU::Header6::GetPDULength
144  //!Description: Specified the length of the PDU
145  //! in KOCTETs( 8 bits = 1 octet ). This value
146  //! will be set by each PDU, you should
147  //! not have to set this value manually.
148  // Parameter: KUINT16 PDUL
149  //************************************
150  void SetPDULength( KUINT16 PDUL );
151  KUINT16 GetPDULength() const;
152 
153  //************************************
154  // FullName: KDIS::PDU::Header6::GetAsString
155  //!Description: Returns a string representation of the PDU.
156  //************************************
157  virtual KString GetAsString() const;
158 
159  //************************************
160  // FullName: KDIS::PDU::Header6::Decode
161  //!Description: Convert From Network Data.
162  // Parameter: KDataStream & stream
163  // Parameter: bool ignoreHeader = false - Decode the header from the stream?
164  //************************************
165  virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) throw( KException );
166 
167  //************************************
168  // FullName: KDIS::PDU::Header6::Encode
169  //!Description: Convert To Network Data.
170  // Parameter: KDataStream & stream
171  //************************************
172  virtual KDataStream Encode() const;
173  virtual void Encode( KDataStream & stream ) const;
174 
175  friend KDataStream & operator >> ( KDataStream & stream, Header6 * H )
176  {
177  H->Decode( stream );
178  return stream;
179  };
180 
181  friend KDataStream & operator << ( KDataStream & stream, Header6 * H )
182  {
183  H->Encode( stream );
184  return stream;
185  };
186 
187  KBOOL operator == ( const Header6 & Value ) const;
188  KBOOL operator != ( const Header6 & Value ) const;
189 };
190 
191 } // END namespace PDU
192 } // END namespace KDIS
KDIS::DATA_TYPE::TimeStamp m_TimeStamp
Definition: Header6.h:67
KUINT16 m_ui16PDULength
Definition: Header6.h:69
unsigned short int KUINT16
Definition: KDefines.h:101
virtual KDataStream Encode() const
Description: Convert To Network Data.
KUINT8 m_ui8PDUType
Definition: Header6.h:63
Definition: EnumEntityManagement.h:362
ProtocolVersion
Definition: EnumHeader.h:53
KUINT8 m_ui8Padding2
Definition: Header6.h:73
Definition: KDefines.h:182
Definition: KDataStream.h:48
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
PDUType
Definition: EnumHeader.h:79
KUINT8 m_ui8Padding1
Definition: Header6.h:71
unsigned char KUINT8
Definition: KDefines.h:99
ProtocolFamily
Definition: EnumHeader.h:174
#define KDIS_EXPORT
Definition: KDefines.h:82
KUINT8 m_ui8ExerciseID
Definition: Header6.h:61
KUINT8 m_ui8ProtocolFamily
Definition: Header6.h:65
KUINT8 m_ui8ProtocolVersion
Definition: Header6.h:59
Definition: TimeStamp.h:68
Definition: Header6.h:55