KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LayerHeader.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: LayerHeader
32  created: 2008/12/07
33  author: Karl Jones
34 
35  purpose: Identifies the additional layer number, layer-specific
36  information and the length of the layer.
37 
38  size: 32 bits / 4 octets
39 *********************************************************************/
40 
41 #pragma once
42 
43 #include "./DataTypeBase.h"
44 #include "./../Extras/KRef_Ptr.h"
45 
46 namespace KDIS {
47 namespace DATA_TYPE {
48 
49 /************************************************************************/
50 // Define the type of pointer we are using for LayerHeader Records,
51 // do we want a weak reference or a ref counter?
52 // By default we use a ref pointer, however if you want to use a standard
53 // pointer or one of your own then simply change it below.
54 /************************************************************************/
56 typedef KDIS::UTILS::KRef_Ptr<LayerHeader> LyrHdrPtr; // Ref counter
57 //typedef VaLayerHeaderLyrHdrPtr; // Weak ref
58 
60 {
61 protected:
62 
64 
66 
68 
69 public:
70 
71  static const KUINT16 LAYER_HEADER_SIZE = 4;
72 
73  LayerHeader();
74 
75  LayerHeader( KDataStream & stream ) throw( KException );
76 
77  LayerHeader( KUINT8 LayerNumber, KUINT8 LayerSpecificInfo, KUINT16 LayerLength );
78 
79  virtual ~LayerHeader();
80 
81  //************************************
82  // FullName: KDIS::DATA_TYPE::LayerHeader::SetLayerNumber
83  // KDIS::DATA_TYPE::LayerHeader::GetLayerNumber
84  //!Description: Identifies the layer.
85  // Parameter: KUINT8 LN
86  //************************************
87  void SetLayerNumber( KUINT8 LN );
88  KUINT8 GetLayerNumber() const;
89 
90  //************************************
91  // FullName: KDIS::DATA_TYPE::LayerHeader::SetLayerSpecificInfomation
92  // KDIS::DATA_TYPE::LayerHeader::GetLayerSpecificInfomation
93  //!Description: This value varies by system type and layer number. Represented by an
94  //! enumeration however no values has been defined(as of SISO-REF-10-2006) other than 0 = Other.
95  // Parameter: KUINT8 LSI
96  //************************************
97  void SetLayerSpecificInfomation( KUINT8 LSI );
98  KUINT8 GetLayerSpecificInfomation() const;
99 
100  //************************************
101  // FullName: KDIS::DATA_TYPE::LayerHeader::SetLayerLength
102  // KDIS::DATA_TYPE::LayerHeader::GetLayerLength
103  //!Description: Specifies the length in octets of the layer including the layer header.
104  // Parameter: KUINT16 L
105  //************************************
106  void SetLayerLength( KUINT16 L );
107  KUINT16 GetLayerLength() const;
108 
109  //************************************
110  // FullName: KDIS::DATA_TYPE::LayerHeader::GetAsString
111  //!Description: Returns a string representation
112  //************************************
113  virtual KString GetAsString() const;
114 
115  //************************************
116  // FullName: KDIS::DATA_TYPE::LayerHeader::Decode
117  //!Description: Convert From Network Data.
118  // Parameter: KDataStream & stream
119  //************************************
120  virtual void Decode( KDataStream & stream ) throw( KException );
121 
122  //************************************
123  // FullName: KDIS::DATA_TYPE::LayerHeader::Encode
124  //!Description: Convert To Network Data.
125  // Parameter: KDataStream & stream
126  //************************************
127  virtual KDataStream Encode() const;
128  virtual void Encode( KDataStream & stream ) const;
129 
130  KBOOL operator == ( const LayerHeader & Value ) const;
131  KBOOL operator != ( const LayerHeader & Value ) const;
132 };
133 
134 } // END namespace DATA_TYPES
135 } // END namespace KDIS
136 
unsigned short int KUINT16
Definition: KDefines.h:101
Definition: LayerHeader.h:59
KUINT16 m_ui16LayerLength
Definition: LayerHeader.h:67
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
KUINT8 m_ui8LayerSpecificInfo
Definition: LayerHeader.h:65
#define KDIS_EXPORT
Definition: KDefines.h:82
Definition: KRef_Ptr.h:73
KDIS::UTILS::KRef_Ptr< LayerHeader > LyrHdrPtr
Definition: LayerHeader.h:55
KUINT8 m_ui8LayerNumber
Definition: LayerHeader.h:63