KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LE_Vector.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: LE_Vector
32  created: 29/07/2010
33  author: Karl Jones
34 
35  purpose: Template Vector class used for Live Entity PDU's.
36  Supports KFIXED16_3 and KFIXED8_3 data types.
37  To add support for other's see the bottom of the cpp file.
38 *********************************************************************/
39 
40 #pragma once
41 
42 #include "./KFIXED.h"
43 
44 namespace KDIS {
45 namespace DATA_TYPE {
46 
47 template<class Type>
49 {
50 protected:
51 
52  Type m_X;
53 
54  Type m_Y;
55 
56  Type m_Z;
57 
58 public:
59 
60  static const KUINT16 LE_VECTOR_SIZE = sizeof( Type ) * 3;
61 
62  LE_Vector();
63 
64  LE_Vector( Type X, Type Y, Type Z );
65 
66  LE_Vector( KDataStream & stream ) throw( KException );
67 
68  virtual ~LE_Vector();
69 
70  //************************************
71  // FullName: KDIS::DATA_TYPE::LE_Vector::SetX
72  // KDIS::DATA_TYPE::LE_Vector::GetX
73  //!Description: First Value / X
74  // Parameter: Type X
75  //************************************
76  void SetX( Type X );
77  Type GetX() const;
78 
79  //************************************
80  // FullName: KDIS::DATA_TYPE::LE_Vector::SetY
81  // KDIS::DATA_TYPE::LE_Vector::GetY
82  //!Description: Second Value / Y
83  // Parameter: Type Y
84  //************************************
85  void SetY( Type Y );
86  Type GetY() const;
87 
88  //************************************
89  // FullName: KDIS::DATA_TYPE::LE_Vector::SetZ
90  // KDIS::DATA_TYPE::LE_Vector::GetZ
91  //!Description: Third Value / Z
92  // Parameter: Type Z
93  //************************************
94  void SetZ( Type Z );
95  Type GetZ() const;
96 
97  //************************************
98  // FullName: KDIS::DATA_TYPE::LE_Vector::GetAsString
99  //!Description: Returns a string representation
100  //************************************
101  virtual KString GetAsString() const;
102 
103  //************************************
104  // FullName: KDIS::DATA_TYPE::LE_Vector::Decode
105  //!Description: Convert From Network Data.
106  // Parameter: KDataStream & stream
107  //************************************
108  virtual void Decode( KDataStream & stream ) throw( KException );
109 
110  //************************************
111  // FullName: KDIS::DATA_TYPE::LE_Vector::Encode
112  //!Description: Convert To Network Data.
113  // Parameter: KDataStream & stream
114  //************************************
115  virtual KDataStream Encode() const;
116  virtual void Encode( KDataStream & stream ) const;
117 
118  KBOOL operator == ( const LE_Vector & Value ) const;
119  KBOOL operator != ( const LE_Vector & Value ) const;
120  LE_Vector operator * ( const LE_Vector & Value ) const;
121  LE_Vector operator * ( KFLOAT64 Value ) const;
122  LE_Vector operator + ( const LE_Vector & Value ) const;
123  LE_Vector & operator += ( const LE_Vector & Value );
124  LE_Vector operator - ( const LE_Vector & Value ) const;
125  LE_Vector & operator -= ( const LE_Vector & Value );
126 
127  // Valid values 0 - X, 1 - Y, 2 - Z. throws OUT_OF_BOUNDS exception for any other value.
128  Type & operator[] ( KUINT16 i ) throw( KException );
129  const Type & operator[] ( KUINT16 i ) const throw( KException );
130 };
131 
132 // Predefined LE_Vector types.
133 // LE_Vectorx_y
134 // x = Size of data type in bits
135 // y = The position of the binary point.
138 
139 } // END namespace DATA_TYPES
140 } // END namespace KDIS
Definition: LE_Vector.h:48
unsigned short int KUINT16
Definition: KDefines.h:101
Definition: KDefines.h:182
Type m_Y
Definition: LE_Vector.h:54
Definition: KDataStream.h:48
Definition: DataTypeBase.h:49
bool KBOOL
Definition: KDefines.h:119
Type m_Z
Definition: LE_Vector.h:56
std::string KString
Definition: KDefines.h:116
Type m_X
Definition: LE_Vector.h:52
double KFLOAT64
Definition: KDefines.h:114
LE_Vector< KFIXED16_3 > LE_Vector8_3
Definition: LE_Vector.h:136
#define KDIS_EXPORT
Definition: KDefines.h:82
LE_Vector< KFIXED8_3 > LE_Vector16_3
Definition: LE_Vector.h:137