KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
StandardVariable.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: StandardVariable
32  created: 17/11/2010
33  author: Karl Jones
34 
35  purpose: Used by the Standard Variable Specification record.
36  Provides base class for all standard variable records.
37 
38  Note: See FactoryDecoder for a guide to adding support for using your own VariableDatums.
39 
40  size: 48 bits / 6 octets - not including record-specific fields or padding.
41 *********************************************************************/
42 
43 #pragma once
44 
45 #include "./DataTypeBase.h"
46 #include "./FactoryDecoder.h"
47 #include "./../Extras/KRef_Ptr.h"
48 
49 namespace KDIS {
50 namespace DATA_TYPE {
51 
52 /************************************************************************/
53 // Define the type of pointer we are using for StandardVariable Records,
54 // do we want a weak reference or a ref counter?
55 // By default we use a ref pointer, however if you want to use a standard
56 // pointer or one of your own then simply change it below.
57 /************************************************************************/
60 //typedef StandardVariable* StdVarPtr; // Weak ref
61 
62 class KDIS_EXPORT StandardVariable : public DataTypeBase, public FactoryDecoderUser<StandardVariable>
63 {
64 protected:
65 
67 
69 
70 public:
71 
72  static const KUINT16 STANDARD_VARIABLE_SIZE = 6;
73 
75 
76  StandardVariable( KDataStream & stream ) throw( KException );
77 
78  virtual ~StandardVariable();
79 
80  //************************************
81  // FullName: KDIS::DATA_TYPE::StandardVariable::GetStandardVariableType
82  //!Description: The record type for this StandardVariable.
83  //************************************
84  KDIS::DATA_TYPE::ENUMS::StandardVariableType GetStandardVariableType() const;
85 
86  //************************************
87  // FullName: KDIS::DATA_TYPE::StandardVariable::GetAsString
88  //!Description: The total record length in octets.
89  //! The value of the Record Length shall be the sum of
90  //! the sizes of the Record Type field, the Record Length field,
91  //! all Record-Specific fields, and any padding required to end
92  //! the record on a 64-bit boundary.
93  //************************************
94  KUINT16 GetRecordLength() const;
95 
96  //************************************
97  // FullName: KDIS::DATA_TYPE::StandardVariable::GetAsString
98  //!Description: Returns a string representation.
99  //************************************
100  virtual KString GetAsString() const;
101 
102  //************************************
103  // FullName: KDIS::DATA_TYPE::StandardVariable::FactoryDecodeStandardVariable
104  //!Description: Decode method for decoding any StandardVariable child classes that are part of KDIS.
105  //! If you want to create a new StandardVariable child class then see the FactoryDecoder
106  // class for further info.
107  //! Throws exception for unknown records(UNSUPPORTED_DATATYPE) or when stream is
108  //! too small(NOT_ENOUGH_DATA_IN_BUFFER).
109  // Parameter: KDataStream & stream
110  //************************************
111  static StdVarPtr FactoryDecodeStandardVariable( KDataStream & stream ) throw( KException );
112 
113  //************************************
114  // FullName: KDIS::DATA_TYPE::StandardVariable::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::StandardVariable::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 StandardVariable & Value ) const;
129  KBOOL operator != ( const StandardVariable & Value ) const;
130 };
131 
132 } // END namespace DATA_TYPES
133 } // END namespace KDIS
unsigned int KUINT32
Definition: KDefines.h:103
unsigned short int KUINT16
Definition: KDefines.h:101
Definition: StandardVariable.h:62
KDIS::UTILS::KRef_Ptr< StandardVariable > StdVarPtr
Definition: StandardVariable.h:58
StandardVariableType
Definition: EnumInformationOperations.h:118
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
KUINT32 m_ui32Type
Definition: StandardVariable.h:66
Definition: FactoryDecoder.h:104
#define KDIS_EXPORT
Definition: KDefines.h:82
Definition: KRef_Ptr.h:73
KUINT16 m_ui16Length
Definition: StandardVariable.h:68