chore(include): changed include files from .h to .hpp
[KDIS.git] / include / KDIS / DataTypes / GridDataType1.hpp
blobc5c19a95733d1c5a4f545ac7e99ad790520c210e
1 /*********************************************************************
2 Copyright 2013 Karl Jones
3 All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
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.
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.
25 For Further Information Please Contact me at
26 Karljj1@yahoo.com
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
30 /********************************************************************
31 class: GridDataType1
32 updated: 21/01/2016
33 author: Karl Jones
35 purpose: The Grid Data record contains the actual environmental state variable data for
36 each grid location. This record specifes the data sample type, the format by
37 which the data are represented, feld scale factor and offset values,
38 and the actual data values in 16-bit.
40 size: 112 bits / 14 octets - Min size
41 *********************************************************************/
43 #pragma once
45 #include "./GridData.h"
46 #include <vector>
48 namespace KDIS {
49 namespace DATA_TYPE {
51 class KDIS_EXPORT GridDataType1 : public GridData
53 protected:
55 KFLOAT32 m_f32FieldScale;
57 KFLOAT32 m_f32FieldOffset;
59 KUINT16 m_ui16NumValues;
61 std::vector<KUINT16> m_vui16Values;
63 KUINT16 m_ui16Padding;
65 public:
67 static const KUINT16 GRID_DATA_TYPE1_SIZE = 14; // Min size
69 GridDataType1();
71 GridDataType1( KDataStream & stream ) ;
73 // This constructor is used by the Gridded_Data_PDU. In order to know what type of grid
74 // data we have we must decode the first 2 values.So this constructor is here to aid in this process.
75 GridDataType1( KUINT16 SampleType, KUINT16 DataRepresentation, KDataStream & stream );
77 GridDataType1( KUINT16 SampleType, KFLOAT32 FieldScale, KFLOAT32 FieldOffset,
78 const std::vector<KUINT16> & Values );
80 virtual ~GridDataType1();
82 //************************************
83 // FullName: KDIS::DATA_TYPE::GridDataType1::SetFieldScale
84 // KDIS::DATA_TYPE::GridDataType1::GetFieldScale
85 // Description: Specifies the constant scale factor used to scale the environmental
86 // state variable data values contained in this record.
87 // Parameter: KFLOAT32 FS
88 //************************************
89 void SetFieldScale( KFLOAT32 FS );
90 KFLOAT32 GetFieldScale() const;
92 //************************************
93 // FullName: KDIS::DATA_TYPE::GridDataType1::SetFieldOffset
94 // KDIS::DATA_TYPE::GridDataType1::GetFieldOffset
95 // Description: Specifies the constant offset used to scale the environmental state
96 // variable data values contained in this record.
97 // Parameter: KFLOAT32 FO
98 //************************************
99 void SetFieldOffset( KFLOAT32 FO );
100 KFLOAT32 GetFieldOffset() const;
102 //************************************
103 // FullName: KDIS::DATA_TYPE::GridDataType1::SetFieldOffset
104 // KDIS::DATA_TYPE::GridDataType1::GetFieldOffset
105 // Description: The Number of environmental state variable data values contained in this record.
106 //************************************
107 KUINT16 GetNumberOfValues() const;
109 //************************************
110 // FullName: KDIS::DATA_TYPE::GridDataType1::AddValue
111 // KDIS::DATA_TYPE::GridDataType1::SetValues
112 // KDIS::DATA_TYPE::GridDataType1::GetValues
113 // KDIS::DATA_TYPE::GridDataType1::ClearValues
114 // Description: The environmental state variable data values.
115 // Parameter: KUINT16 V, const vector<KUINT16> & V
116 //************************************
117 void AddValue( KUINT16 V );
118 void SetValues( const std::vector<KUINT16> & V );
119 const std::vector<KUINT16> & GetValues() const;
120 void ClearValues();
122 //************************************
123 // FullName: KDIS::DATA_TYPE::GridDataType1::GetDataRepresentation
124 // Description: Returns the size of the whole Grid Data type object in octets.
125 // Note: This information is not encoded into the PDU, it is here for the
126 // internal calculation of the PDU length value.
127 //************************************
128 virtual KUINT16 GetSize() const;
130 //************************************
131 // FullName: KDIS::DATA_TYPE::GridDataType1::GetAsString
132 // Description: Returns a string representation
133 //************************************
134 virtual KString GetAsString() const;
136 //************************************
137 // FullName: KDIS::DATA_TYPE::GridDataType1::Decode
138 // Description: Convert From Network Data.
139 // Parameter: KDataStream & stream
140 //************************************
141 virtual void Decode( KDataStream & stream ) ;
143 //************************************
144 // FullName: KDIS::DATA_TYPE::GridDataType1::Encode
145 // Description: Convert To Network Data.
146 // Parameter: KDataStream & stream
147 //************************************
148 virtual KDataStream Encode() const;
149 virtual void Encode( KDataStream & stream ) const;
151 KBOOL operator == ( const GridDataType1 & Value ) const;
152 KBOOL operator != ( const GridDataType1 & Value ) const;
155 } // END namespace DATA_TYPES
156 } // END namespace KDIS