KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Detonation_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: Detonation_PDU
32  DIS: (5) 1278.1 - 1995 & (7) 1278.1-2012(when using descriptors that are not MunitionDescriptors)
33  updated: 22/04/2013
34  author: Karl Jones
35 
36  purpose: Communicates detonation or impact of munitions.
37  Size: 832 bits / 104 octets + 128n / 16n
38 *********************************************************************/
39 
40 #pragma once
41 
42 #include "./Warfare_Header.h"
43 #include "./../../DataTypes/WorldCoordinates.h"
44 #include "./../../DataTypes/Vector.h"
45 #include "./../../DataTypes/MunitionDescriptor.h"
46 #include "./../../DataTypes/VariableParameter.h"
47 
48 namespace KDIS {
49 namespace PDU {
50 
52 {
53 protected:
54 
56 
58 
60 
62 
64 
66 
68 
69  std::vector<KDIS::DATA_TYPE::VarPrmPtr> m_vVariableParameters;
70 
71 public:
72 
73  static const KUINT16 DETONATION_PDU_SIZE = 104;
74 
76 
77  Detonation_PDU( KDataStream & stream ) throw( KException );
78 
79  Detonation_PDU( const Header & H, KDataStream & stream ) throw( KException );
80 
83  const KDIS::DATA_TYPE::Vector & Velocity, const KDIS::DATA_TYPE::WorldCoordinates & LocationWorldCoords,
84  KDIS::DATA_TYPE::DescPtr Desc, const KDIS::DATA_TYPE::Vector & LocationEntityCoords,
86 
87  Detonation_PDU( const Warfare_Header & WarfareHeader, const KDIS::DATA_TYPE::Vector & Velocity,
88  const KDIS::DATA_TYPE::WorldCoordinates & LocationWorldCoords, KDIS::DATA_TYPE::DescPtr Desc,
90 
91  virtual ~Detonation_PDU();
92 
93  #if DIS_VERSION > 6
94  //************************************
95  // FullName: KDIS::PDU::Detonation_PDU::SetPDUStatusDetonationType
96  // KDIS::PDU::Detonation_PDU::GetPDUStatusDetonationType
97  //!Description: Indicates the descriptor type used. DTI.
98  // Parameter: DetonationType FT
99  //************************************
100  void SetPDUStatusDetonationType( KDIS::DATA_TYPE::ENUMS::DetonationType DT );
101  KDIS::DATA_TYPE::ENUMS::DetonationType GetPDUStatusDetonationType() const;
102  #endif
103 
104  //************************************
105  // FullName: KDIS::PDU::Detonation_PDU::SetVelocity
106  // KDIS::PDU::Detonation_PDU::GetVelocity
107  //!Description: Velocity of fire munition.
108  // Parameter: const Vector & V
109  //************************************
110  void SetVelocity( const KDIS::DATA_TYPE::Vector & V );
111  const KDIS::DATA_TYPE::Vector & GetVelocity() const;
112  KDIS::DATA_TYPE::Vector & GetVelocity();
113 
114  //************************************
115  // FullName: KDIS::PDU::Detonation_PDU::SetLocationInWorldCoords
116  // KDIS::PDU::Detonation_PDU::GetLocationInWorldCoords
117  //!Description: Location of detonation event in world
118  //! coordinates.
119  // Parameter: const WorldCoordinates & L
120  //************************************
121  void SetLocationInWorldCoords( const KDIS::DATA_TYPE::WorldCoordinates & L );
122  const KDIS::DATA_TYPE::WorldCoordinates & GetLocationInWorldCoords() const;
123  KDIS::DATA_TYPE::WorldCoordinates & GetLocationInWorldCoords();
124 
125  //************************************
126  // FullName: KDIS::PDU::Detonation_PDU::SetDescriptor
127  // KDIS::PDU::Detonation_PDU::GetDescriptor
128  //!Description: Descriptor, describes type of detonation.
129  //! Pre DIS 7 this will always be a MunitionDescriptor.
130  //! In DIS 7 a Detonation PDU can send a Munition, Expendable or an Explosion descriptor.
131  //! Setting this in DIS 7 will automatically set the DTI (PDUStatusDetonationType) field and will
132  //! cause the protocol version to change to 7 if the type is Expendable or Explosion.
133  //! I leave it as default if the type is Munition.
134  //! Note: By default this value will be a MunitionDescriptor, it is not null by default.
135  //! Example usage in DIS 7: SetDescriptor( DescPtr( new MunitionDescriptor() ) );
136  // Parameter: DescPtr D
137  //************************************
138  void SetDescriptor( KDIS::DATA_TYPE::DescPtr D );
139  const KDIS::DATA_TYPE::DescPtr GetDescriptor() const;
140  KDIS::DATA_TYPE::DescPtr GetDescriptor();
141 
142  //************************************
143  // FullName: KDIS::PDU::Detonation_PDU::SetLocationInEntityCoords
144  // KDIS::PDU::Detonation_PDU::GetLocationInEntityCoords
145  //!Description: Location of detonation event in entity coordinates.
146  //! Use for damage assessment to the entity.
147  // Parameter: const Vector & L
148  //************************************
149  void SetLocationInEntityCoords( const KDIS::DATA_TYPE::Vector & L );
150  const KDIS::DATA_TYPE::Vector & GetLocationInEntityCoords() const;
151  KDIS::DATA_TYPE::Vector & GetLocationInEntityCoords();
152 
153  //************************************
154  // FullName: KDIS::PDU::Detonation_PDU::SetDetonationResult
155  // KDIS::PDU::Detonation_PDU::GetDetonationResult
156  //!Description: Represents the result of the detonation.
157  // Parameter: DetonationResult DR
158  //************************************
159  void SetDetonationResult( KDIS::DATA_TYPE::ENUMS::DetonationResult DR );
160  KDIS::DATA_TYPE::ENUMS::DetonationResult GetDetonationResult() const;
161 
162  //************************************
163  // FullName: KDIS::PDU::Detonation_PDU::GetNumberOfVariableParams
164  //!Description: Number of variable parameters.
165  //************************************
166  KUINT8 GetNumberOfVariableParams() const;
167 
168  //************************************
169  // FullName: KDIS::PDU::Detonation_PDU::AddVariableParameter
170  // KDIS::PDU::Detonation_PDU::SetVariableParameter
171  // KDIS::PDU::Detonation_PDU::GetVariableParameters
172  // KDIS::PDU::Detonation_PDU::ClearVariableParameters
173  //!Description: Information associated with an entity or detonation, not otherwise accounted
174  // for in a PDU such as Articulated and Attached Parts.
175  //! See VariableParameter for supported/implemented types.
176  // Parameter: VarPrmPtr VP, vector<VarPrmPtr> & VP
177  //************************************
178  void AddVariableParameter( KDIS::DATA_TYPE::VarPrmPtr VP );
179  void SetVariableParameters( const std::vector<KDIS::DATA_TYPE::VarPrmPtr> & VP );
180  const std::vector<KDIS::DATA_TYPE::VarPrmPtr> & GetVariableParameters() const;
181  void ClearVariableParameters();
182 
183  //************************************
184  // FullName: KDIS::PDU::Detonation_PDU::GetAsString
185  //!Description: Returns a string representation of the PDU.
186  //************************************
187  virtual KString GetAsString() const;
188 
189  //************************************
190  // FullName: KDIS::PDU::Detonation_PDU::Decode
191  //!Description: Convert From Network Data.
192  // Parameter: KDataStream & stream
193  // Parameter: bool ignoreHeader = false - Decode the header from the stream?
194  //************************************
195  virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) throw( KException );
196 
197  //************************************
198  // FullName: KDIS::PDU::Detonation_PDU::Encode
199  //!Description: Convert To Network Data.
200  // Parameter: KDataStream & stream
201  //************************************
202  virtual KDataStream Encode() const;
203  virtual void Encode( KDataStream & stream ) const;
204 
205  KBOOL operator == ( const Detonation_PDU & Value ) const;
206  KBOOL operator != ( const Detonation_PDU & Value ) const;
207 };
208 
209 } // END namespace PDU
210 } // END namespace KDIS
KUINT16 m_ui16Padding1
Definition: Detonation_PDU.h:67
KUINT8 m_ui8NumOfVariableParams
Definition: Detonation_PDU.h:65
unsigned short int KUINT16
Definition: KDefines.h:101
DetonationResult
Definition: EnumDetonationResult.h:54
Definition: Vector.h:71
Definition: KDefines.h:182
Definition: KDataStream.h:48
Definition: WorldCoordinates.h:52
std::vector< KDIS::DATA_TYPE::VarPrmPtr > m_vVariableParameters
Definition: Detonation_PDU.h:69
bool KBOOL
Definition: KDefines.h:119
Definition: Warfare_Header.h:48
KUINT8 m_ui8DetonationResult
Definition: Detonation_PDU.h:63
KDIS::DATA_TYPE::Vector m_Velocity
Definition: Detonation_PDU.h:55
std::string KString
Definition: KDefines.h:116
Definition: Detonation_PDU.h:51
KDIS::DATA_TYPE::WorldCoordinates m_LocationWorldCoords
Definition: Detonation_PDU.h:57
Definition: EntityIdentifier.h:49
KDIS::DATA_TYPE::Vector m_LocationEntityCoords
Definition: Detonation_PDU.h:61
Definition: Header7.h:142
unsigned char KUINT8
Definition: KDefines.h:99
Definition: EnumEntityManagement.h:561
#define KDIS_EXPORT
Definition: KDefines.h:82
DetonationType
Definition: EnumBurstDescriptor.h:281
KDIS::DATA_TYPE::DescPtr m_pDescriptor
Definition: Detonation_PDU.h:59