KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LinearObjectAppearance.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: LinearObjectAppearance
32  created: 15/03/2010
33  author: Karl Jones
34 
35  purpose: Represents a linear objects appearance.
36  size: 48 Bits / 6 Octet
37 *********************************************************************/
38 
39 #pragma once
40 
41 #include "./ObjectAppearance.h"
42 #include <bitset>
43 
44 namespace KDIS {
45 namespace DATA_TYPE {
46 
48 {
49 protected:
50 
51  union
52  {
53  struct
54  {
55  KUINT32 m_ui32Breach : 2;
56  KUINT32 m_ui32Unused : 14;
57  KUINT32 m_ui32BreachLength : 8;
58  KUINT32 m_ui32BreachLoc : 8;
59  } m_TankDitchConcertinaWire;
60 
61  struct
62  {
63  KUINT32 m_ui32Opacity : 8;
64  KUINT32 m_ui32Attached : 1;
65  KUINT32 m_ui32Chemical : 2;
66  KUINT32 m_ui32Unused : 21;
67  } m_ExhaustSmoke;
68 
69  struct
70  {
71  KUINT32 m_ui32VisibleSide : 2;
72  KUINT32 m_ui32Unused : 30;
73  } m_MinefieldLaneMarker;
74 
76  } m_SpecificAppearanceUnion;
77 
78 public:
79 
80  static const KUINT16 LINEAR_OBJECT_APPEARANCE_SIZE = 6;
81 
83 
84  LinearObjectAppearance( KDataStream & stream ) throw( KException );
85 
86  virtual ~LinearObjectAppearance();
87 
88  /************************************************************************/
89  /* The following appearance values are only for linear's of the type: */
90  /* Tank ditch, and Concertina Wire */
91  /************************************************************************/
92 
93  //************************************
94  // FullName: KDIS::DATA_TYPE::LinearObjectAppearance::SetBreach
95  // KDIS::DATA_TYPE::LinearObjectAppearance::GetBreach
96  //!Description: Describes the breached appearance of the object.
97  // Parameter: Breach2bit B
98  //************************************
99  void SetBreach( KDIS::DATA_TYPE::ENUMS::Breach2bit B );
100  KDIS::DATA_TYPE::ENUMS::Breach2bit GetBreach() const;
101 
102  //************************************
103  // FullName: KDIS::DATA_TYPE::LinearObjectAppearance::SetBreachLength
104  // KDIS::DATA_TYPE::LinearObjectAppearance::GetBreachLength
105  //!Description: Integer indicating the fixed length in meters of a breached segment.
106  // Parameter: KUINT8 L
107  //************************************
108  void SetBreachLength( KUINT8 L );
109  KUINT8 GetBreachLength() const;
110 
111  //************************************
112  // FullName: KDIS::DATA_TYPE::LinearObjectAppearance::SetBreachLocation
113  // KDIS::DATA_TYPE::LinearObjectAppearance::GetBreachLocation
114  // KDIS::DATA_TYPE::LinearObjectAppearance::GetBreachLocationAsBitset
115  //!Description: Each bit indicates whether its associated segment is breached or not.
116  //! Bit 40+i indicates whether the portion of the segment beginning at the
117  //! segment origin + (i*Breach Length) and extending i* Breach
118  //! Length meters is breached or not.
119  //! For each bit:
120  //! 0 Associated portion of segment is not breached
121  //! 1 Associated portion of segment is breached
122  // Parameter: const bitset<8> & L, KUINT8 L
123  //************************************
124  void SetBreachLocation( const std::bitset<8> & L );
125  void SetBreachLocation( KUINT8 L );
126  KUINT8 GetBreachLocation() const;
127  std::bitset<8> GetBreachLocationAsBitset();
128 
129  /************************************************************************/
130  /* The following appearance values are only for linears of the type: */
131  /* Exhaust Smoke */
132  /************************************************************************/
133 
134  //************************************
135  // FullName: KDIS::DATA_TYPE::LinearObjectAppearance::SetOpacity
136  // KDIS::DATA_TYPE::LinearObjectAppearance::GetOpacity
137  //!Description: The percent opacity of the smoke, ranging from 0% opacity to 100%.
138  //! Acceptable values are 0 - 100 else throws INVALID_DATA exception.
139  // Parameter: KUINT8 O
140  //************************************
141  void SetOpacity( KUINT8 O ) throw( KException );
142  KUINT8 GetOpacity() const;
143 
144  //************************************
145  // FullName: KDIS::DATA_TYPE::LinearObjectAppearance::SetAttached
146  // KDIS::DATA_TYPE::LinearObjectAppearance::IsAttached
147  //!Description: Describes whether the smoke is attached to the vehicle.
148  // Parameter: KBOOL A
149  //************************************
150  void SetAttached( KBOOL A );
151  KBOOL IsAttached() const;
152 
153  //************************************
154  // FullName: KDIS::DATA_TYPE::LinearObjectAppearance::SetChemical
155  // KDIS::DATA_TYPE::LinearObjectAppearance::GetChemical
156  //!Description: The chemical content of the smoke.
157  // Parameter: Chemical C
158  //************************************
159  void SetChemical( KDIS::DATA_TYPE::ENUMS::Chemical C );
160  KDIS::DATA_TYPE::ENUMS::Chemical GetChemical() const;
161 
162  /************************************************************************/
163  /* The following appearance values are only for linears of the type: */
164  /* Minefield Lane Marker */
165  /************************************************************************/
166 
167  //************************************
168  // FullName: KDIS::DATA_TYPE::LinearObjectAppearance::SetVisibleSide
169  // KDIS::DATA_TYPE::LinearObjectAppearance::GetVisibleSide
170  //!Description: Describes the side of the lane marker which is visible.
171  // Parameter: VisibleSide V
172  //************************************
173  void SetVisibleSide( KDIS::DATA_TYPE::ENUMS::VisibleSide V );
174  KDIS::DATA_TYPE::ENUMS::VisibleSide GetVisibleSide() const;
175 
176  //************************************
177  // FullName: KDIS::DATA_TYPE::LinearObjectAppearance::GetAsString
178  //!Description: Returns a string representation of the appearance
179  // Parameter: const EntityType & EntType
180  //************************************
181  virtual KString GetAsString() const;
182 
183  //************************************
184  // FullName: KDIS::DATA_TYPE::LinearObjectAppearance::Decode
185  //!Description: Convert From Network Data.
186  // Parameter: KDataStream & stream
187  //************************************
188  virtual void Decode( KDataStream & stream ) throw( KException );
189 
190  //************************************
191  // FullName: KDIS::DATA_TYPE::LinearObjectAppearance::Encode
192  //!Description: Convert To Network Data.
193  // Parameter: KDataStream & stream
194  //************************************
195  virtual KDataStream Encode() const;
196  virtual void Encode( KDataStream & stream ) const;
197 
198  KBOOL operator == ( const LinearObjectAppearance & Value ) const;
199  KBOOL operator != ( const LinearObjectAppearance & Value ) const;
200 };
201 
202 } // END namespace DATA_TYPES
203 } // END namespace KDIS
Definition: LinearObjectAppearance.h:47
unsigned int KUINT32
Definition: KDefines.h:103
unsigned short int KUINT16
Definition: KDefines.h:101
Breach2bit
Definition: EnumSyntheticEnviroment.h:196
VisibleSide
Definition: EnumSyntheticEnviroment.h:237
Definition: KDefines.h:182
Definition: KDataStream.h:48
Chemical
Definition: EnumSyntheticEnviroment.h:217
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
unsigned char KUINT8
Definition: KDefines.h:99
KUINT32 m_ui32SpecificAppearance
Definition: LinearObjectAppearance.h:75
Definition: ObjectAppearance.h:46
#define KDIS_EXPORT
Definition: KDefines.h:82