KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
EncodingScheme.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: EncodingScheme
32  created: 18/09/2008
33  author: Karl Jones
34 
35  purpose: Scheme used to encode a set of data.
36 
37  size: 32 bits / 4 octets
38 *********************************************************************/
39 
40 #pragma once
41 
42 #include "./DataTypeBase.h"
43 
44 namespace KDIS {
45 namespace DATA_TYPE {
46 
48 {
49 protected:
50 
51  union
52  {
53  struct
54  {
55  KUINT16 m_ui16Type : 14;
56  KUINT16 m_ui16Class : 2;
57  };
59  } m_EncodingSchemeUnion;
60 
62 
63 public:
64 
65  static const KUINT16 ENCODING_SCHEME_SIZE = 4;
66 
68 
69  EncodingScheme( KDataStream & stream ) throw( KException );
70 
72 
74 
75  virtual ~EncodingScheme();
76 
77  //************************************
78  // FullName: KDIS::DATA_TYPE::EncodingScheme::SetEncodingClass
79  // KDIS::DATA_TYPE::EncodingScheme::GetEncodingClass
80  //!Description: Encoding Class
81  // Parameter: EncodingClass EC
82  //************************************
83  void SetEncodingClass( KDIS::DATA_TYPE::ENUMS::EncodingClass EC );
84  KDIS::DATA_TYPE::ENUMS::EncodingClass GetEncodingClass() const;
85 
86  //************************************
87  // FullName: KDIS::DATA_TYPE::EncodingScheme::SetEncodingTypeAudio
88  // KDIS::DATA_TYPE::EncodingScheme::SetEncodingType
89  // KDIS::DATA_TYPE::EncodingScheme::GetEncodingTypeAudio
90  // KDIS::DATA_TYPE::EncodingScheme::GetEncodingType
91  //!Description: When using encoded audio use an encoding type.
92  //! Can also be used to represent the number of TDL
93  //! (Tactical Data Links). If encoded class is not audio
94  //! and the TDL type is 0 then this value should also be 0.
95  // Parameter: EncodingType T, KUINT16 T
96  //************************************
97  void SetEncodingTypeAudio( KDIS::DATA_TYPE::ENUMS::EncodingType T );
98  void SetEncodingType( KUINT16 T );
99  KDIS::DATA_TYPE::ENUMS::EncodingType GetEncodingTypeAudio() const;
100  KUINT16 GetEncodingType() const;
101 
102  //************************************
103  // FullName: KDIS::DATA_TYPE::EncodingScheme::SetTDLType
104  // KDIS::DATA_TYPE::EncodingScheme::GetTDLType
105  //!Description: Tactical Data Link Type if the encoding class is
106  //! representing a TDL type, if not then set to 0.
107  // Parameter: TDLType T
108  //************************************
109  void SetTDLType( KDIS::DATA_TYPE::ENUMS::TDLType T );
110  KDIS::DATA_TYPE::ENUMS::TDLType GetTDLType() const;
111 
112  //************************************
113  // FullName: KDIS::DATA_TYPE::EncodingScheme::GetAsString
114  //!Description: Returns a string representation
115  //************************************
116  virtual KString GetAsString() const;
117 
118  //************************************
119  // FullName: KDIS::DATA_TYPE::EncodingScheme::Decode
120  //!Description: Convert From Network Data.
121  // Parameter: KDataStream & stream
122  //************************************
123  virtual void Decode( KDataStream & stream ) throw( KException );
124 
125  //************************************
126  // FullName: KDIS::DATA_TYPE::EncodingScheme::Encode
127  //!Description: Convert To Network Data.
128  // Parameter: KDataStream & stream
129  //************************************
130  virtual KDataStream Encode() const;
131  virtual void Encode( KDataStream & stream ) const;
132 
133  KBOOL operator == ( const EncodingScheme & Value ) const;
134  KBOOL operator != ( const EncodingScheme & Value ) const;
135 };
136 
137 } // END namespace DATA_TYPES
138 } // END namespace KDIS
139 
unsigned short int KUINT16
Definition: KDefines.h:101
KUINT16 m_ui16TDLType
Definition: EncodingScheme.h:61
Definition: KDefines.h:182
EncodingClass
Definition: EnumRadio.h:303
Definition: KDataStream.h:48
TDLType
Definition: EnumRadio.h:350
Definition: DataTypeBase.h:49
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
KUINT16 m_ui16EncodingScheme
Definition: EncodingScheme.h:58
EncodingType
Definition: EnumRadio.h:323
#define KDIS_EXPORT
Definition: KDefines.h:82
Definition: EncodingScheme.h:47