Merge pull request #5 from intothevoid/master
[KDIS.git] / KDIS / KDIS / PDU / Simulation_Management / Data_PDU.h
blob3ca4e2858bc960daad1e72817774285c8f3157e3
1 /*********************************************************************
2 Copyright 2013 Karl Jones
3 All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
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.
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.
25 For Further Information Please Contact me at
26 Karljj1@yahoo.com
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
30 /********************************************************************
31 class: Data_PDU
32 DIS: (5) 1278.1 - 1995
33 created: 2008/09/22
34 author: Karl Jones
36 purpose: Sent in response to a data query or set data request.
37 size: 320 bits/ 40 octets - not including variable param sizes
38 *********************************************************************/
40 #pragma once
42 #include "./Comment_PDU.h"
44 namespace KDIS {
45 namespace PDU {
47 class KDIS_EXPORT Data_PDU : public Comment_PDU
49 protected:
51 KUINT32 m_ui32RequestID;
53 KUINT32 m_ui32Padding;
55 public:
57 static const KUINT16 DATA_PDU_SIZE = 40;
59 Data_PDU();
61 explicit Data_PDU( const Header & H );
63 Data_PDU( KDataStream & stream ) ;
65 Data_PDU( const Header & H, KDataStream & stream ) ;
67 Data_PDU( const KDIS::DATA_TYPE::EntityIdentifier & OriginatingEntityID, const KDIS::DATA_TYPE::EntityIdentifier & ReceivingEntityID,
68 KUINT32 RequestID );
70 virtual ~Data_PDU();
72 //************************************
73 // FullName: KDIS::PDU::Data_PDU::SetRequestID
74 // KDIS::PDU::Data_PDU::GetRequestID
75 // Description: Request ID, identifies the matching response
76 // to a Data Query PDU or Set Data PDU.
77 // Parameter: KUINT32 ID
78 //************************************
79 void SetRequestID( KUINT32 ID );
80 KUINT32 GetRequestID() const;
82 //************************************
83 // FullName: KDIS::PDU::Data_PDU::SetVariableDatum
84 // Description: Sets variable datums and updates PDU length.
85 // Parameter: const vector<VarDtmPtr> & VD
86 //************************************
87 virtual void SetVariableDatum(const std::vector<KDIS::DATA_TYPE::VarDtmPtr> & VD);
89 //************************************
90 // FullName: KDIS::PDU::Data_PDU::GetAsString
91 // Description: Returns a string representation of the PDU.
92 //************************************
93 virtual KString GetAsString() const;
95 //************************************
96 // FullName: KDIS::PDU::Data_PDU::Decode
97 // Description: Convert From Network Data.
98 // Parameter: KDataStream & stream
99 // Parameter: bool ignoreHeader = false - Decode the header from the stream?
100 //************************************
101 virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) ;
103 //************************************
104 // FullName: KDIS::PDU::Data_PDU::Encode
105 // Description: Convert To Network Data.
106 // Parameter: KDataStream & stream
107 //************************************
108 virtual KDataStream Encode() const;
109 virtual void Encode( KDataStream & stream ) const;
111 KBOOL operator == ( const Data_PDU & Value ) const;
112 KBOOL operator != ( const Data_PDU & Value ) const;
115 } // END namespace PDU
116 } // END namespace KDIS