KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
GridDataType2.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: GridDataType2
32  created: 20/11/2009
33  author: Karl Jones
34 
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 and the actual data values in 32-bit.
38 
39  size: 64 bits / 8 octets - Min size
40 *********************************************************************/
41 
42 #pragma once
43 
44 #include "./GridData.h"
45 #include <vector>
46 
47 namespace KDIS {
48 namespace DATA_TYPE {
49 
51 {
52 protected:
53 
55 
56  std::vector<KFLOAT32> m_vf32Values;
57 
59 
60 public:
61 
62  static const KUINT16 GRID_DATA_TYPE2_SIZE = 8; // Min size
63 
64  GridDataType2();
65 
66  GridDataType2( KDataStream & stream ) throw( KException );
67 
68  // This constructor is used by the Gridded_Data_PDU. In order to know what type of grid
69  // data we have we must decode the first 2 values.So this constructor is here to aid in this process.
70  GridDataType2( KUINT16 SampleType, KUINT16 DataRepresentation, KDataStream & stream );
71 
72  GridDataType2( KUINT16 SampleType, const std::vector<KFLOAT32> & Values );
73 
74  virtual ~GridDataType2();
75 
76  //************************************
77  // FullName: KDIS::DATA_TYPE::GridDataType2::SetFieldOffset
78  // KDIS::DATA_TYPE::GridDataType2::GetFieldOffset
79  //!Description: The Number of environmental state variable data values contained in this record.
80  //************************************
81  KUINT16 GetNumberOfValues() const;
82 
83  //************************************
84  // FullName: KDIS::DATA_TYPE::GridDataType2::AddValue
85  // KDIS::DATA_TYPE::GridDataType2::SetValues
86  // KDIS::DATA_TYPE::GridDataType2::GetValues
87  // KDIS::DATA_TYPE::GridDataType2::ClearValues
88  //!Description: The environmental state variable data values.
89  // Parameter: KFLOAT32 V, const vector<KFLOAT32> & V
90  //************************************
91  void AddValue( KFLOAT32 V );
92  void SetValues( const std::vector<KFLOAT32> & V );
93  const std::vector<KFLOAT32> & GetValues() const;
94  void ClearValues();
95 
96  //************************************
97  // FullName: KDIS::DATA_TYPE::GridDataType2::GetDataRepresentation
98  //!Description: Returns the size of the whole Grid Data type object in octets.
99  //! Note: This information is not encoded into the PDU, it is here for the
100  //! internal calculation of the PDU length value.
101  //************************************
102  virtual KUINT16 GetSize() const;
103 
104  //************************************
105  // FullName: KDIS::DATA_TYPE::GridDataType2::GetAsString
106  //!Description: Returns a string representation
107  //************************************
108  virtual KString GetAsString() const;
109 
110  //************************************
111  // FullName: KDIS::DATA_TYPE::GridDataType2::Decode
112  //!Description: Convert From Network Data.
113  // Parameter: KDataStream & stream
114  //************************************
115  virtual void Decode( KDataStream & stream ) throw( KException );
116 
117  //************************************
118  // FullName: KDIS::DATA_TYPE::GridDataType2::Encode
119  //!Description: Convert To Network Data.
120  // Parameter: KDataStream & stream
121  //************************************
122  virtual KDataStream Encode() const;
123  virtual void Encode( KDataStream & stream ) const;
124 
125  KBOOL operator == ( const GridDataType2 & Value ) const;
126  KBOOL operator != ( const GridDataType2 & Value ) const;
127 };
128 
129 } // END namespace DATA_TYPES
130 } // END namespace KDIS
131 
unsigned short int KUINT16
Definition: KDefines.h:101
float KFLOAT32
Definition: KDefines.h:113
Definition: GridData.h:48
Definition: KDefines.h:182
Definition: KDataStream.h:48
bool KBOOL
Definition: KDefines.h:119
KUINT16 m_ui16NumValues
Definition: GridDataType2.h:54
std::string KString
Definition: KDefines.h:116
#define KDIS_EXPORT
Definition: KDefines.h:82
Definition: GridDataType2.h:50
std::vector< KFLOAT32 > m_vf32Values
Definition: GridDataType2.h:56
KUINT16 m_ui16Padding
Definition: GridDataType2.h:58