chore: KDIS datatypes
[KDIS.git] / KDIS / DataTypes / AntennaLocation.cpp
blob399124745e1f5d1c2b989eb6be4fc5c1a18b77c4
1 /*********************************************************************
2 Copyright 2013 Karl Jones
3 All rights reserved.
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
26 Karljj1@yahoo.com
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
30 #include "./AntennaLocation.h"
32 //////////////////////////////////////////////////////////////////////////
34 using namespace std;
35 using namespace KDIS;
36 using namespace DATA_TYPE;
38 //////////////////////////////////////////////////////////////////////////
39 // public:
40 //////////////////////////////////////////////////////////////////////////
42 AntennaLocation::AntennaLocation()
46 //////////////////////////////////////////////////////////////////////////
48 AntennaLocation::AntennaLocation( KDataStream & stream )
50 Decode( stream );
53 //////////////////////////////////////////////////////////////////////////
55 AntennaLocation::AntennaLocation( const WorldCoordinates & Location, const Vector & RelativeLocation ) :
56 m_AntennaLocation( Location ),
57 m_RelativeAntennaLocation( RelativeLocation )
61 //////////////////////////////////////////////////////////////////////////
63 AntennaLocation::~AntennaLocation()
67 //////////////////////////////////////////////////////////////////////////
69 void AntennaLocation::SetAntennaLocation( const WorldCoordinates & AL )
71 m_AntennaLocation = AL;
74 //////////////////////////////////////////////////////////////////////////
76 const WorldCoordinates & AntennaLocation::GetAntennaLocation() const
78 return m_AntennaLocation;
81 //////////////////////////////////////////////////////////////////////////
83 WorldCoordinates & AntennaLocation::GetAntennaLocation()
85 return m_AntennaLocation;
88 //////////////////////////////////////////////////////////////////////////
90 void AntennaLocation::SetRelativeAntennaLocation( const Vector & RAL )
92 m_RelativeAntennaLocation = RAL;
95 //////////////////////////////////////////////////////////////////////////
97 const Vector & AntennaLocation::GetRelativeAntennaLocation() const
99 return m_RelativeAntennaLocation;
102 //////////////////////////////////////////////////////////////////////////
104 Vector & AntennaLocation::GetRelativeAntennaLocation()
106 return m_RelativeAntennaLocation;
109 //////////////////////////////////////////////////////////////////////////
111 KString AntennaLocation::GetAsString() const
113 KStringStream ss;
115 ss << "Antenna Location:\n"
116 << "\tWorld Location: " << m_AntennaLocation.GetAsString()
117 << "\tEntity Location: " << m_RelativeAntennaLocation.GetAsString();
119 return ss.str();
122 //////////////////////////////////////////////////////////////////////////
124 void AntennaLocation::Decode( KDataStream & stream )
126 if( stream.GetBufferSize() < ANTENNA_LOCATION_SIZE )throw KException( __FUNCTION__, NOT_ENOUGH_DATA_IN_BUFFER );
128 stream >> KDIS_STREAM m_AntennaLocation
129 >> KDIS_STREAM m_RelativeAntennaLocation;
132 //////////////////////////////////////////////////////////////////////////
134 KDataStream AntennaLocation::Encode() const
136 KDataStream stream;
138 AntennaLocation::Encode( stream );
140 return stream;
143 //////////////////////////////////////////////////////////////////////////
145 void AntennaLocation::Encode( KDataStream & stream ) const
147 stream << KDIS_STREAM m_AntennaLocation
148 << KDIS_STREAM m_RelativeAntennaLocation;
151 //////////////////////////////////////////////////////////////////////////
153 KBOOL AntennaLocation::operator == ( const AntennaLocation & Value ) const
155 if( m_AntennaLocation != Value.m_AntennaLocation ) return false;
156 if( m_RelativeAntennaLocation != Value.m_RelativeAntennaLocation ) return false;
157 return true;
160 //////////////////////////////////////////////////////////////////////////
162 KBOOL AntennaLocation::operator != ( const AntennaLocation & Value ) const
164 return !( *this == Value );
167 //////////////////////////////////////////////////////////////////////////