KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Fire_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: Fire_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 firing of munitions.
37  Size: 768 bits / 96 octets
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 
47 namespace KDIS {
48 namespace PDU {
49 
51 {
52 protected:
53 
55 
57 
59 
61 
63 
64 public:
65 
66  static const KUINT16 FIRE_PDU_SIZE = 96;
67 
68  Fire_PDU();
69 
70  Fire_PDU( KDataStream & stream ) throw( KException );
71 
72  Fire_PDU( const Header & H, KDataStream & stream ) throw( KException );
73 
74  Fire_PDU( const Warfare_Header & WarfareHeader, KUINT32 FireMissionIndex, const KDIS::DATA_TYPE::WorldCoordinates & Location,
75  KDIS::DATA_TYPE::DescPtr Desc, const KDIS::DATA_TYPE::Vector & Velocity, KFLOAT32 Range );
76 
77  Fire_PDU( const KDIS::DATA_TYPE::EntityIdentifier & FiringEntID, const KDIS::DATA_TYPE::EntityIdentifier & TargetEntID,
79  KUINT32 FireMissionIndex, const KDIS::DATA_TYPE::WorldCoordinates & Location,
80  KDIS::DATA_TYPE::DescPtr Desc, const KDIS::DATA_TYPE::Vector & Velocity, KFLOAT32 Range );
81 
82  virtual ~Fire_PDU();
83 
84  #if DIS_VERSION > 6
85  //************************************
86  // FullName: KDIS::PDU::Fire_PDU::SetPDUStatusFireType
87  // KDIS::PDU::Fire_PDU::GetPDUStatusFireType
88  //!Description: Indicates the descriptor type used. FTI.
89  // Parameter: FireType FT
90  //************************************
91  void SetPDUStatusFireType( KDIS::DATA_TYPE::ENUMS::FireType FT );
92  KDIS::DATA_TYPE::ENUMS::FireType GetPDUStatusFireType() const;
93  #endif
94 
95  //************************************
96  // FullName: KDIS::PDU::Fire_PDU::SetFireMissionIndex
97  // KDIS::PDU::Fire_PDU::GetFireMissionIndex
98  //!Description: Identifies the fire mission. If unknown value will
99  //! be symbolic value: NO_FIRE_MISSION
100  // Parameter: KUINT32 FMI
101  //************************************
102  void SetFireMissionIndex( KUINT32 FMI );
103  KUINT32 GetFireMissionIndex() const;
104 
105  //************************************
106  // FullName: KDIS::PDU::Fire_PDU::SetLocation
107  // KDIS::PDU::Fire_PDU::GetLocation
108  //!Description: Location of fire event in world
109  //! coordinates.
110  // Parameter: const WorldCoordinates & L
111  //************************************
112  void SetLocation( const KDIS::DATA_TYPE::WorldCoordinates & L );
113  const KDIS::DATA_TYPE::WorldCoordinates & GetLocation() const;
114  KDIS::DATA_TYPE::WorldCoordinates & GetLocation();
115 
116  //************************************
117  // FullName: KDIS::PDU::Fire_PDU::SetDescriptor
118  // KDIS::PDU::Fire_PDU::GetDescriptor
119  //!Description: Descriptor, describes type of munition.
120  //! Pre DIS 7 this will always be a MunitionDescriptor.
121  //! In DIS 7 a Fire PDU can send a Munition Descriptor or an Expendable
122  //! Descriptor. Setting this in DIS 7 will automatically set the
123  //! FTI (PDUStatusFireType) field and will cause the protocol version to change to
124  //! 7 if the type is Expendable. I leave it as default if the type is Munition.
125  //! Note: By default this value will be a MunitionDescriptor, it is not null by default.
126  //! Example usage in DIS 7: SetDescriptor( DescPtr( new ExplosionDescriptor() ) );
127  // Parameter: DescPtr D
128  //************************************
129  void SetDescriptor( KDIS::DATA_TYPE::DescPtr D );
130  const KDIS::DATA_TYPE::DescPtr GetDescriptor() const;
131  KDIS::DATA_TYPE::DescPtr GetDescriptor();
132 
133  //************************************
134  // FullName: KDIS::PDU::Fire_PDU::SetVelocity
135  // KDIS::PDU::Fire_PDU::GetVelocity
136  //!Description: Velocity of fire munition.
137  // Parameter: const Vector & V
138  //************************************
139  void SetVelocity( const KDIS::DATA_TYPE::Vector & V );
140  const KDIS::DATA_TYPE::Vector & GetVelocity() const;
141  KDIS::DATA_TYPE::Vector & GetVelocity();
142 
143  //************************************
144  // FullName: KDIS::PDU::Fire_PDU::SetRange
145  // KDIS::PDU::Fire_PDU::GetRange
146  //!Description: Range. Range that firing entity has
147  //! calculated target to be.
148  // Parameter: KFLOAT32 R
149  //************************************
150  void SetRange( KFLOAT32 R );
151  KFLOAT32 GetRange() const;
152 
153  //************************************
154  // FullName: KDIS::PDU::Fire_PDU::GetAsString
155  //!Description: Returns a string representation of the PDU.
156  //************************************
157  virtual KString GetAsString() const;
158 
159  //************************************
160  // FullName: KDIS::PDU::Fire_PDU::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::Fire_PDU::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  KBOOL operator == ( const Fire_PDU & Value ) const;
176  KBOOL operator != ( const Fire_PDU & Value ) const;
177 };
178 
179 } // END namespace PDU
180 } // END namespace KDIS
unsigned int KUINT32
Definition: KDefines.h:103
unsigned short int KUINT16
Definition: KDefines.h:101
FireType
Definition: EnumBurstDescriptor.h:262
KDIS::DATA_TYPE::DescPtr m_pDescriptor
Definition: Fire_PDU.h:58
float KFLOAT32
Definition: KDefines.h:113
Definition: Vector.h:71
Definition: KDefines.h:182
Definition: KDataStream.h:48
Definition: WorldCoordinates.h:52
bool KBOOL
Definition: KDefines.h:119
Definition: Warfare_Header.h:48
KDIS::DATA_TYPE::WorldCoordinates m_Location
Definition: Fire_PDU.h:56
std::string KString
Definition: KDefines.h:116
Definition: EntityIdentifier.h:49
KFLOAT32 m_f32Range
Definition: Fire_PDU.h:62
Definition: Header7.h:142
Definition: Fire_PDU.h:50
KUINT32 m_ui32FireMissionIndex
Definition: Fire_PDU.h:54
Definition: EnumEntityManagement.h:561
#define KDIS_EXPORT
Definition: KDefines.h:82
KDIS::DATA_TYPE::Vector m_Velocity
Definition: Fire_PDU.h:60