1 /*********************************************************************
2 Copyright 2013 Karl Jones
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
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.
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.
25 For Further Information Please Contact me at
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
30 #include "KDIS/DataTypes/PointObjectAppearance.hpp"
33 using namespace DATA_TYPE
;
34 using namespace ENUMS
;
36 //////////////////////////////////////////////////////////////////////////
38 //////////////////////////////////////////////////////////////////////////
40 PointObjectAppearance::PointObjectAppearance() {
41 m_SpecificAppearanceUnion
.m_ui32SpecificAppearance
= 0;
44 //////////////////////////////////////////////////////////////////////////
46 PointObjectAppearance::PointObjectAppearance(KDataStream
& stream
) {
50 //////////////////////////////////////////////////////////////////////////
52 PointObjectAppearance::~PointObjectAppearance() {}
54 //////////////////////////////////////////////////////////////////////////
56 void PointObjectAppearance::SetBreach(Breach2bit B
) {
57 m_SpecificAppearanceUnion
.m_LogCribAbatisVehicleDefiladeInf
.m_ui32Breach
= B
;
60 //////////////////////////////////////////////////////////////////////////
62 Breach2bit
PointObjectAppearance::GetBreach() const {
64 m_SpecificAppearanceUnion
.m_LogCribAbatisVehicleDefiladeInf
.m_ui32Breach
;
67 //////////////////////////////////////////////////////////////////////////
69 void PointObjectAppearance::SetOpacity(KUINT8 O
) {
71 throw KException(__FUNCTION__
, INVALID_DATA
,
72 "Acceptable values are 0-100.");
74 m_SpecificAppearanceUnion
.m_AirBurstGroundBurst
.m_ui32Opacity
= O
;
77 //////////////////////////////////////////////////////////////////////////
79 KUINT8
PointObjectAppearance::GetOpacity() const {
80 return m_SpecificAppearanceUnion
.m_AirBurstGroundBurst
.m_ui32Opacity
;
83 //////////////////////////////////////////////////////////////////////////
85 void PointObjectAppearance::SetBurstSize(KUINT8 S
) {
86 m_SpecificAppearanceUnion
.m_AirBurstGroundBurst
.m_ui32Size
= S
;
89 //////////////////////////////////////////////////////////////////////////
91 KUINT8
PointObjectAppearance::GetBurstSize() const {
92 return m_SpecificAppearanceUnion
.m_AirBurstGroundBurst
.m_ui32Size
;
95 //////////////////////////////////////////////////////////////////////////
97 void PointObjectAppearance::SetHeight(KUINT8 H
) {
98 m_SpecificAppearanceUnion
.m_AirBurstGroundBurst
.m_ui32Height
= H
;
101 //////////////////////////////////////////////////////////////////////////
103 KUINT8
PointObjectAppearance::GetHeight() const {
104 return m_SpecificAppearanceUnion
.m_AirBurstGroundBurst
.m_ui32Height
;
107 //////////////////////////////////////////////////////////////////////////
109 void PointObjectAppearance::SetNumBursts(KUINT8 N
) {
110 m_SpecificAppearanceUnion
.m_AirBurstGroundBurst
.m_ui32NumBurst
= N
;
113 //////////////////////////////////////////////////////////////////////////
115 KUINT8
PointObjectAppearance::GetNumBursts() const {
116 return m_SpecificAppearanceUnion
.m_AirBurstGroundBurst
.m_ui32NumBurst
;
119 //////////////////////////////////////////////////////////////////////////
121 void PointObjectAppearance::SetChemical(Chemical C
) {
122 m_SpecificAppearanceUnion
.m_AirBurstGroundBurst
.m_ui32Chemical
= C
;
125 //////////////////////////////////////////////////////////////////////////
127 Chemical
PointObjectAppearance::GetChemical() const {
129 m_SpecificAppearanceUnion
.m_AirBurstGroundBurst
.m_ui32Chemical
;
132 //////////////////////////////////////////////////////////////////////////
134 void PointObjectAppearance::SetCraterSize(KUINT8 S
) {
135 m_SpecificAppearanceUnion
.m_Crater
.m_ui32Size
= S
;
138 //////////////////////////////////////////////////////////////////////////
140 KUINT8
PointObjectAppearance::GetCraterSize() const {
141 return m_SpecificAppearanceUnion
.m_Crater
.m_ui32Size
;
144 //////////////////////////////////////////////////////////////////////////
146 void PointObjectAppearance::SetNumSegments(KUINT8 N
) {
147 m_SpecificAppearanceUnion
.m_RibbonBridge
.m_ui32NumSeg
= N
;
150 //////////////////////////////////////////////////////////////////////////
152 KUINT8
PointObjectAppearance::GetNumSegments() const {
153 return m_SpecificAppearanceUnion
.m_RibbonBridge
.m_ui32NumSeg
;
156 //////////////////////////////////////////////////////////////////////////
158 KString
PointObjectAppearance::GetAsString() const {
161 ss
<< ObjectAppearance::GetAsString() << "\tSpecific Appearance: "
162 << m_SpecificAppearanceUnion
.m_ui32SpecificAppearance
<< "\n";
167 //////////////////////////////////////////////////////////////////////////
169 void PointObjectAppearance::Decode(KDataStream
& stream
) {
170 if (stream
.GetBufferSize() < POINT_OBJECT_APPEARANCE_SIZE
)
171 throw KException(__FUNCTION__
, NOT_ENOUGH_DATA_IN_BUFFER
);
173 stream
>> m_SpecificAppearanceUnion
.m_ui32SpecificAppearance
>>
174 m_GeneralAppearanceUnion
.m_ui16GeneralAppearance
;
177 //////////////////////////////////////////////////////////////////////////
179 KDataStream
PointObjectAppearance::Encode() const {
182 PointObjectAppearance::Encode(stream
);
187 //////////////////////////////////////////////////////////////////////////
189 void PointObjectAppearance::Encode(KDataStream
& stream
) const {
190 // First add the specific bytes and then the general.
191 stream
<< m_SpecificAppearanceUnion
.m_ui32SpecificAppearance
192 << m_GeneralAppearanceUnion
.m_ui16GeneralAppearance
;
195 //////////////////////////////////////////////////////////////////////////
197 KBOOL
PointObjectAppearance::operator==(
198 const PointObjectAppearance
& Value
) const {
199 if (ObjectAppearance::operator!=(Value
)) return false;
200 if (m_SpecificAppearanceUnion
.m_ui32SpecificAppearance
!=
201 Value
.m_SpecificAppearanceUnion
.m_ui32SpecificAppearance
)
206 //////////////////////////////////////////////////////////////////////////
208 KBOOL
PointObjectAppearance::operator!=(
209 const PointObjectAppearance
& Value
) const {
210 return !(*this == Value
);
213 //////////////////////////////////////////////////////////////////////////