KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Comment_PDU.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: Comment_PDU
32  DIS: (5) 1278.1 - 1995
33  created: 08/10/2008
34  author: Karl Jones
35 
36  purpose: Arbitrary message (E.G char strings) shall be entered into the data
37  stream by using a comment PDU. For use as comment, test message, error etc.
38  size: 256 bits/ 32 octets - not including fix and var datum sizes
39 *********************************************************************/
40 
41 #pragma once
42 
44 #include "./../../DataTypes/FixedDatum.h"
45 #include "./../../DataTypes/VariableDatum.h"
46 
47 namespace KDIS {
48 namespace PDU {
49 
55 using std::vector;
56 
58 {
59 protected:
60 
62 
64 
65  std::vector<KDIS::DATA_TYPE::FixDtmPtr> m_vFixedDatum;
66 
67  std::vector<KDIS::DATA_TYPE::VarDtmPtr> m_vVariableDatum;
68 
69 public:
70 
71  static const KUINT16 COMMENT_PDU_SIZE = 32; // Min size
72 
73  Comment_PDU();
74 
75  Comment_PDU( const Header & H );
76 
77  Comment_PDU( KDataStream & stream ) throw( KException );
78 
79  Comment_PDU( const Header & H, KDataStream & stream ) throw( KException );
80 
81  Comment_PDU( const KDIS::DATA_TYPE::EntityIdentifier & OriginatingEntityID, const KDIS::DATA_TYPE::EntityIdentifier & ReceivingEntityID );
82 
83  virtual ~Comment_PDU();
84 
85  //************************************
86  // FullName: KDIS::PDU::Comment_PDU::GetNumberFIxedDatum
87  //!Description: Returns number of fixed datum records
88  //************************************
89  KUINT32 GetNumberFIxedDatum() const;
90 
91  //************************************
92  // FullName: KDIS::PDU::Comment_PDU::GetNumberVariableDatum
93  //!Description: Returns number of variable datum records
94  //************************************
95  KUINT32 GetNumberVariableDatum() const;
96 
97  //************************************
98  // FullName: KDIS::PDU::Comment_PDU::AddFixedDatum
99  // KDIS::PDU::Comment_PDU::SetFixedDatum
100  // KDIS::PDU::Comment_PDU::GetFixedDatum
101  //!Description: Add, get fixed datums
102  // Parameter: FixedDatum FD, const vector<FixDtmPtr> & FD
103  //************************************
104  void AddFixedDatum( KDIS::DATA_TYPE::FixDtmPtr FD );
105  void SetFixedDatum( const std::vector<KDIS::DATA_TYPE::FixDtmPtr> & FD );
106  const std::vector<FixDtmPtr> & GetFixedDatum() const;
107 
108  //************************************
109  // FullName: KDIS::PDU::Comment_PDU::AddVariableDatum
110  // KDIS::PDU::Comment_PDU::SetVariableDatum
111  // KDIS::PDU::Comment_PDU::GetVariableDatum
112  //!Description: Add, get variable datums
113  // Parameter: VarDtmPtr VD, const vector<VarDtmPtr> & VD
114  //************************************
115  void AddVariableDatum( KDIS::DATA_TYPE::VarDtmPtr VD );
116  void SetVariableDatum( const std::vector<KDIS::DATA_TYPE::VarDtmPtr> & VD );
117  const std::vector<VarDtmPtr> & GetVariableDatum() const;
118 
119  //************************************
120  // FullName: KDIS::PDU::Comment_PDU::GetAsString
121  //!Description: Returns a string representation of the PDU.
122  //************************************
123  virtual KString GetAsString() const;
124 
125  //************************************
126  // FullName: KDIS::PDU::Comment_PDU::Decode
127  //!Description: Convert From Network Data.
128  // Parameter: KDataStream & stream
129  // Parameter: bool ignoreHeader = false - Decode the header from the stream?
130  //************************************
131  virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) throw( KException );
132 
133  //************************************
134  // FullName: KDIS::PDU::Comment_PDU::Encode
135  //!Description: Convert To Network Data.
136  //************************************
137  virtual KDataStream Encode() const;
138  virtual void Encode( KDataStream & stream ) const;
139 
140  KBOOL operator == ( const Comment_PDU & Value ) const;
141  KBOOL operator != ( const Comment_PDU & Value ) const;
142 };
143 
144 } // END namespace PDU
145 } // END namespace KDIS
unsigned int KUINT32
Definition: KDefines.h:103
Definition: Simulation_Management_Header.h:48
KUINT32 m_ui32NumVariableDatum
Definition: Comment_PDU.h:63
std::vector< KDIS::DATA_TYPE::FixDtmPtr > m_vFixedDatum
Definition: Comment_PDU.h:65
unsigned short int KUINT16
Definition: KDefines.h:101
Definition: Comment_PDU.h:57
Definition: FixedDatum.h:65
KUINT32 m_ui32NumFixedDatum
Definition: Comment_PDU.h:61
Definition: KDefines.h:182
KDIS::UTILS::KRef_Ptr< VariableDatum > VarDtmPtr
Definition: VariableDatum.h:59
Definition: KDataStream.h:48
bool KBOOL
Definition: KDefines.h:119
std::vector< KDIS::DATA_TYPE::VarDtmPtr > m_vVariableDatum
Definition: Comment_PDU.h:67
std::string KString
Definition: KDefines.h:116
Definition: EntityIdentifier.h:49
Definition: Header7.h:142
#define KDIS_EXPORT
Definition: KDefines.h:82
Definition: VariableDatum.h:63
Definition: KRef_Ptr.h:73
KDIS::UTILS::KRef_Ptr< FixedDatum > FixDtmPtr
Definition: FixedDatum.h:61