KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
GridDataType0.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: GridDataType0
32  created: 19/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 8-bit.
38 
39  NOTE: Data Representation Type 0 is specifcally designed to be fexible to accommodate anything
40  from character data to data expressed as foating point numbers.
41 
42  size: 64 bits / 8 octets - Min size
43 *********************************************************************/
44 
45 #pragma once
46 
47 #include "./GridData.h"
48 #include <vector>
49 
50 namespace KDIS {
51 namespace DATA_TYPE {
52 
53 using std::vector;
54 
56 {
57 protected:
58 
60 
61  std::vector<KUINT8> m_vui8DataVals;
62 
64 
65 public:
66 
67  static const KUINT16 GRID_DATA_TYPE0_SIZE = 8; // Min size
68 
69  GridDataType0();
70 
71  GridDataType0( KDataStream & stream ) throw( KException );
72 
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  GridDataType0( KUINT16 SampleType, KUINT16 DataRepresentation, KDataStream & stream );
76 
77  GridDataType0( KUINT16 SampleType, KUINT8 * Data, KUINT16 NumBytes );
78 
79  virtual ~GridDataType0();
80 
81  //************************************
82  // FullName: KDIS::DATA_TYPE::GridDataType0::Encode
83  //!Description: The number of bytes of environmental state variable data
84  //! values contained in this record.
85  // Parameter: KDataStream & stream
86  //************************************
87  KUINT16 GetNumberOfBytes() const;
88 
89  //************************************
90  // FullName: KDIS::DATA_TYPE::GridDataType0::AddGridAxisDescriptor
91  // KDIS::DATA_TYPE::GridDataType0::SetGridAxisDescriptors
92  // KDIS::DATA_TYPE::GridDataType0::GetSetGridAxisDescriptors
93  // KDIS::DATA_TYPE::GridDataType0::ClearValues
94  //!Description: Specifies the environmental state variable data values. The data shall
95  //! be represented as a stream of bytes, the interpretation of which shall be
96  //! agreed to prior to the start of the exercise.
97  // Parameter: KUINT8 D, KUINT8 * Data,, const vector<KUINT8> & DV
98  // Parameter: KUINT16 NumBytes
99  //************************************
100  void AddDataValue( KUINT8 D );
101  void SetDataValues( KUINT8 * Data, KUINT16 NumBytes );
102  void SetDataValues( const std::vector<KUINT8> & DV );
103  const std::vector<KUINT8> & GetDataValues() const;
104  void ClearValues();
105 
106  //************************************
107  // FullName: KDIS::DATA_TYPE::GridDataType0::GetDataRepresentation
108  //!Description: Returns the size of the whole Grid Data type object in octets.
109  //! Note: This information is not encoded into the PDU, it is here for the
110  //! internal calculation of the PDU length value.
111  //************************************
112  virtual KUINT16 GetSize() const;
113 
114  //************************************
115  // FullName: KDIS::DATA_TYPE::GridDataType0::GetAsString
116  //!Description: Returns a string representation
117  //************************************
118  virtual KString GetAsString() const;
119 
120  //************************************
121  // FullName: KDIS::DATA_TYPE::GridDataType0::Decode
122  //!Description: Convert From Network Data.
123  // Parameter: KDataStream & stream
124  //************************************
125  virtual void Decode( KDataStream & stream ) throw( KException );
126 
127  //************************************
128  // FullName: KDIS::DATA_TYPE::GridDataType0::Encode
129  //!Description: Convert To Network Data.
130  // Parameter: KDataStream & stream
131  //************************************
132  virtual KDataStream Encode() const;
133  virtual void Encode( KDataStream & stream ) const;
134 
135  KBOOL operator == ( const GridDataType0 & Value ) const;
136  KBOOL operator != ( const GridDataType0 & Value ) const;
137 };
138 
139 } // END namespace DATA_TYPES
140 } // END namespace KDIS
141 
unsigned short int KUINT16
Definition: KDefines.h:101
std::vector< KUINT8 > m_vui8DataVals
Definition: GridDataType0.h:61
Definition: GridData.h:48
Definition: GridDataType0.h:55
Definition: KDefines.h:182
Definition: KDataStream.h:48
KUINT8 m_ui8Padding
Definition: GridDataType0.h:63
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
KUINT16 m_ui16NumBytes
Definition: GridDataType0.h:59
unsigned char KUINT8
Definition: KDefines.h:99
#define KDIS_EXPORT
Definition: KDefines.h:82