KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Descriptor.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: Descriptor
32  created: 22/04/2013
33  author: Karl Jones
34 
35  purpose: Base class for Descriptor records.
36 
37  In DIS < 7:
38  All descriptors should use the Munition Descriptor record AKA Burst descriptor.
39 
40  In DIS 7 onwards:
41  A Fire PDU descriptor can be either a Munition(AKA Burst) or an Expendable descriptor.
42  A Detonation PDU descriptor can be either a Munition(AKA Burst), Expendable or an Explosion descriptor.
43 
44  size: 128 bits / 16 octets
45 *********************************************************************/
46 
47 #pragma once
48 
49 #include "./DataTypeBase.h"
50 #include "./EntityType.h"
51 #include "./../Extras/KRef_Ptr.h"
52 
53 namespace KDIS {
54 namespace DATA_TYPE {
55 
56 /************************************************************************/
57 // Define the type of pointer we are using for Descriptor Records,
58 // do we want a weak reference or a ref counter?
59 // By default we use a ref pointer, however if you want to use a standard
60 // pointer or one of your own then simply change it below.
61 /************************************************************************/
62 class Descriptor;
63 typedef KDIS::UTILS::KRef_Ptr<Descriptor> DescPtr; // Ref counter
64 //typedef Descriptor* DescPtr; // Weak ref
65 
66 #if DIS_VERSION > 6
68 #endif
69 
71 {
72 protected:
73 
75 
76 public:
77 
78  static const KUINT16 DESCRIPTOR_SIZE = 16;
79 
80  Descriptor();
81 
82  Descriptor( KDataStream & stream )throw( KException );
83 
84  Descriptor( const EntityType & T );
85 
86  virtual ~Descriptor();
87 
88  //************************************
89  // FullName: KDIS::DATA_TYPE::Descriptor::SetMunition
90  // KDIS::DATA_TYPE::Descriptor::GetMunition
91  //!Description: Munition, Explosion or Expendable Type.
92  // Parameter: const EntityType & T
93  //************************************
94  void SetType( const EntityType & T );
95  const EntityType & GetType() const;
96  EntityType & GetType();
97 
98  //************************************
99  // FullName: KDIS::DATA_TYPE::Descriptor::GetAsString
100  //!Description: Returns a string representation.
101  //************************************
102  virtual KString GetAsString() const;
103 
104  //************************************
105  // FullName: KDIS::DATA_TYPE::Descriptor::Decode
106  //!Description: Convert From Network Data.
107  // Parameter: KDataStream & stream
108  //************************************
109  virtual void Decode( KDataStream & stream ) throw( KException );
110 
111  //************************************
112  // FullName: KDIS::DATA_TYPE::Descriptor::Encode
113  //!Description: Convert To Network Data.
114  // Parameter: KDataStream & stream
115  //************************************
116  virtual KDataStream Encode() const;
117  virtual void Encode( KDataStream & stream ) const;
118 
119  KBOOL operator == ( const Descriptor & Value ) const;
120  KBOOL operator != ( const Descriptor & Value ) const;
121 };
122 
123 } // END namespace DATA_TYPES
124 } // END namespace KDIS
Descriptor ExpendableDescriptor
Definition: Descriptor.h:67
KDIS::UTILS::KRef_Ptr< Descriptor > DescPtr
Definition: Descriptor.h:62
Definition: EntityType.h:46
EntityType m_Type
Definition: Descriptor.h:74
unsigned short int KUINT16
Definition: KDefines.h:101
Definition: KDefines.h:182
Definition: Descriptor.h:70
Definition: KDataStream.h:48
Definition: DataTypeBase.h:49
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
#define KDIS_EXPORT
Definition: KDefines.h:82