KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ObjectAppearance.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: ObjectAppearance
32  created: 16/02/2010
33  author: Karl Jones
34 
35  purpose: Represents the general object appearance.
36  size: 16 Bits / 2 Octet
37 *********************************************************************/
38 
39 #pragma once
40 
41 #include "./DataTypeBase.h"
42 
43 namespace KDIS {
44 namespace DATA_TYPE {
45 
47 {
48 protected:
49 
50  union
51  {
52  struct
53  {
54  KUINT16 m_ui16PcComp : 8;
55  KUINT16 m_ui16Dmg : 2;
56  KUINT16 m_ui16Predistributed : 1;
57  KUINT16 m_ui16State : 1;
58  KUINT16 m_ui16Smoking : 1;
59  KUINT16 m_ui16Flaming : 1;
60  KUINT16 m_ui16Unused : 2;
61  };
62 
64  KUINT8 m_ui8GeneralAppearance[2]; // Used for encode/decode
65  } m_GeneralAppearanceUnion;
66 
67 public:
68 
69  static const KUINT16 OBJECT_APPEARANCE_SIZE = 2;
70 
72 
73  ObjectAppearance( KDataStream & stream ) throw( KException );
74 
76  KBOOL Smoking, KBOOL Flaming ) throw( KException );
77 
78  virtual ~ObjectAppearance();
79 
80  //************************************
81  // FullName: KDIS::DATA_TYPE::ObjectAppearance::SetGeneralAppearance
82  // KDIS::DATA_TYPE::ObjectAppearance::GetGeneralAppearance
83  //!Description: General appearance bit field.
84  // Parameter: KUINT16 GA, void
85  //************************************
86  void SetGeneralAppearance( KUINT16 GA );
87  KUINT16 GetGeneralAppearance() const;
88 
89  //************************************
90  // FullName: KDIS::DATA_TYPE::ObjectAppearance::SetPercentageComplete
91  // KDIS::DATA_TYPE::ObjectAppearance::GetPercentageComplete
92  //!Description: Indicates the percent completion of the object.
93  //! Acceptable values are 0 - 100 else throws INVALID_DATA exception.
94  // Parameter: KUINT8 P
95  //************************************
96  void SetPercentageComplete( KUINT8 P ) throw( KException );
97  KUINT8 GetPercentageComplete() const;
98 
99  //************************************
100  // FullName: KDIS::DATA_TYPE::ObjectAppearance::SetDamage
101  // KDIS::DATA_TYPE::ObjectAppearance::GetDamage
102  //!Description: Describes the damaged appearance of the object.
103  // Parameter: ObjectDamage OD
104  //************************************
105  void SetDamage( KDIS::DATA_TYPE::ENUMS::ObjectDamage OD );
106  KDIS::DATA_TYPE::ENUMS::ObjectDamage GetDamage() const;
107 
108  //************************************
109  // FullName: KDIS::DATA_TYPE::ObjectAppearance::SetPredistributed
110  // KDIS::DATA_TYPE::ObjectAppearance::IsPredistributed
111  //!Description: Describes whether the object was predistributed.
112  //! false - Object created during the exercise
113  //! true - Object predistributed prior to exercise start.
114  // Parameter: KBOOL P
115  //************************************
116  void SetPredistributed( KBOOL P );
117  KBOOL IsPredistributed() const;
118 
119  //************************************
120  // FullName: KDIS::DATA_TYPE::ObjectAppearance::SetState
121  // KDIS::DATA_TYPE::ObjectAppearance::GetState
122  //!Description: Describes the state of the object.
123  //! false - Deactivated.
124  //! true - Active.
125  // Parameter: KBOOL S
126  //************************************
127  void SetState( KBOOL S );
128  KBOOL GetState() const;
129 
130  //************************************
131  // FullName: KDIS::DATA_TYPE::ObjectAppearance::SetSmoking
132  // KDIS::DATA_TYPE::ObjectAppearance::IsSmoking
133  //!Description: Describes whether smoke is rising from an object.
134  //! false - No smoke.
135  //! true - Smoke present.
136  // Parameter: KBOOL S
137  //************************************
138  void SetSmoking( KBOOL S );
139  KBOOL IsSmoking() const;
140 
141  //************************************
142  // FullName: KDIS::DATA_TYPE::ObjectAppearance::SetFlaming
143  // KDIS::DATA_TYPE::ObjectAppearance::IsFlaming
144  //!Description: Describes whether Flames are rising from an object.
145  //! false - No Flames.
146  //! true - Flames present.
147  // Parameter: KBOOL F
148  //************************************
149  void SetFlaming( KBOOL F );
150  KBOOL IsFlaming() const;
151 
152  //************************************
153  // FullName: KDIS::DATA_TYPE::ObjectAppearance::GetAsString
154  //!Description: Returns a string representation of the appearance
155  // Parameter: const EntityType & EntType
156  //************************************
157  virtual KString GetAsString() const;
158 
159  //************************************
160  // FullName: KDIS::DATA_TYPE::ObjectAppearance::Decode
161  //!Description: Convert From Network Data.
162  // Parameter: KDataStream & stream
163  //************************************
164  virtual void Decode( KDataStream & stream ) throw( KException );
165 
166  //************************************
167  // FullName: KDIS::DATA_TYPE::ObjectAppearance::Encode
168  //!Description: Convert To Network Data.
169  // Parameter: KDataStream & stream
170  //************************************
171  virtual KDataStream Encode() const;
172  virtual void Encode( KDataStream & stream ) const;
173 
174  KBOOL operator == ( const ObjectAppearance & Value ) const;
175  KBOOL operator != ( const ObjectAppearance & Value ) const;
176 };
177 
178 } // END namespace DATA_TYPES
179 } // END namespace KDIS
unsigned short int KUINT16
Definition: KDefines.h:101
KUINT16 m_ui16GeneralAppearance
Definition: ObjectAppearance.h:63
Definition: KDefines.h:182
Definition: KDataStream.h:48
Definition: DataTypeBase.h:49
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
unsigned char KUINT8
Definition: KDefines.h:99
Definition: ObjectAppearance.h:46
#define KDIS_EXPORT
Definition: KDefines.h:82
ObjectDamage
Definition: EnumSyntheticEnviroment.h:174