KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
VariableParameter.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: VariableParameter
32  created: 08/03/2013
33  author: Karl Jones
34 
35  purpose: Information associated with an entity or detonation, not otherwise accounted
36  for in a PDU.
37  Currently implemented types:
38  ArticulatedParts
39  AttachedPart
40 
41  Note: See FactoryDecoder for a guide to adding support for using your own VariableParameters.
42 
43  size: 128 bits / 16 octets
44 *********************************************************************/
45 
46 #pragma once
47 
48 #include "./DataTypeBase.h"
49 #include "./FactoryDecoder.h"
50 #include "./../Extras/KRef_Ptr.h"
51 
52 namespace KDIS {
53 namespace DATA_TYPE {
54 
55 /************************************************************************/
56 // Define the type of pointer we are using for VariableParameter Records,
57 // do we want a weak reference or a ref counter?
58 // By default we use a ref pointer, however if you want to use a standard
59 // pointer or one of your own then simply change it below.
60 /************************************************************************/
63 //typedef VariableParameter* VarPrmPtr; // Weak ref
64 
66 
67 class KDIS_EXPORT VariableParameter : public DataTypeBase, public FactoryDecoderUser<VariableParameter>
68 {
69 protected:
70 
72 
73  KUINT8 m_Data[15];
74 
75 public:
76 
77  static const KUINT16 VARIABLE_PARAMETER_SIZE = 16;
78 
80 
81  VariableParameter( VariableParameterType VPT, KUINT8 * Data, KUINT8 DataSize ) throw( KException );
82 
83  VariableParameter( KDataStream & stream ) throw( KException );
84 
85  virtual ~VariableParameter();
86 
87  //************************************
88  // FullName: KDIS::DATA_TYPE::VariableParameter::SetVariableParameterType
89  // KDIS::DATA_TYPE::VariableParameter::GetVariableParameterType
90  //!Description: VP record type.
91  // Parameter: VariableParameterType VPT
92  //************************************
93  void SetVariableParameterType( VariableParameterType VPT );
94  VariableParameterType GetVariableParameterType() const;
95 
96  //************************************
97  // FullName: KDIS::DATA_TYPE::VariableParameter::SetVariableParameterType
98  // KDIS::DATA_TYPE::VariableParameter::GetVariableParameterType
99  //!Description: Raw VP data. 15 byte array.
100  // Parameter: const KUINT8 * D
101  // Parameter: KUINT8 DataSize - Exception thrown if data size is greater than 15.
102  //************************************
103  void SetData( const KUINT8 * D, KUINT8 DataSize ) throw( KException );
104  const KUINT8 * GetData() const;
105  KUINT8 * GetData();
106 
107  //************************************
108  // FullName: KDIS::DATA_TYPE::VariableParameter::GetAsString
109  //!Description: Returns a string representation.
110  //************************************
111  virtual KString GetAsString() const;
112 
113  //************************************
114  // FullName: KDIS::DATA_TYPE::VariableParameter::Decode
115  //!Description: Convert From Network Data.
116  // Parameter: KDataStream & stream
117  //************************************
118  virtual void Decode( KDataStream & stream ) throw( KException );
119 
120  //************************************
121  // FullName: KDIS::DATA_TYPE::VariableParameter::Encode
122  //!Description: Convert To Network Data.
123  // Parameter: KDataStream & stream
124  //************************************
125  virtual KDataStream Encode() const;
126  virtual void Encode( KDataStream & stream ) const;
127 
128  KBOOL operator == ( const VariableParameter & Value ) const;
129  KBOOL operator != ( const VariableParameter & Value ) const;
130 };
131 
132 } // END namespace DATA_TYPES
133 } // END namespace KDIS
unsigned short int KUINT16
Definition: KDefines.h:101
KDIS::UTILS::KRef_Ptr< VariableParameter > VarPrmPtr
Definition: VariableParameter.h:61
KUINT8 m_ui8VarParamType
Definition: VariableParameter.h:71
Definition: KDefines.h:182
Definition: KDataStream.h:48
Definition: DataTypeBase.h:49
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
unsigned char KUINT8
Definition: KDefines.h:99
Definition: FactoryDecoder.h:104
VariableParameterType
Definition: EnumEntityInfoInteraction.h:380
#define KDIS_EXPORT
Definition: KDefines.h:82
Definition: KRef_Ptr.h:73
Definition: VariableParameter.h:67