EMANE  1.2.1
antennaprofileevent.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014,2016 - Adjacent Link LLC, Bridgewater,
3  * New Jersey
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Adjacent Link LLC nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
35 #include "antennaprofileevent.pb.h"
36 
37 class EMANE::Events::AntennaProfileEvent::Implementation
38 {
39 public:
40  Implementation(const AntennaProfiles & profiles):
41  profiles_{profiles}{}
42 
43  const AntennaProfiles & getAntennaProfiles() const
44  {
45  return profiles_;
46  }
47 
48 private:
49  AntennaProfiles profiles_;
50 };
51 
54 {
56 
57  if(!msg.ParseFromString(serialization))
58  {
59  throw SerializationException("unable to deserialize : AntennaProfileEvent");
60  }
61 
62  AntennaProfiles profiles;
63 
64  for(const auto & profile : msg.profiles())
65  {
66  profiles.push_back({static_cast<EMANE::NEMId>(profile.nemid()),
67  static_cast<EMANE::AntennaProfileId>(profile.profileid()),
68  profile.antennaazimuthdegrees(),
69  profile.antennaelevationdegrees()});
70  }
71 
72  pImpl_.reset(new Implementation{profiles});
73 }
74 
77  pImpl_{new Implementation{profiles}}{}
78 
81  pImpl_{new Implementation{rhs.getAntennaProfiles()}}{}
82 
84 {
85  pImpl_.reset(new Implementation{rhs.getAntennaProfiles()});
86  return *this;
87 }
88 
91  pImpl_{new Implementation{{}}}
92 {
93  rval.pImpl_.swap(pImpl_);
94 }
95 
97 {
98  rval.pImpl_.swap(pImpl_);
99  return *this;
100 }
101 
103 
105 {
106  return pImpl_->getAntennaProfiles();
107 }
108 
110 {
111  Serialization serialization;
112 
114 
115  for(auto & profile : pImpl_->getAntennaProfiles())
116  {
117  auto pAntennaProfileMessage = msg.add_profiles();
118 
119  pAntennaProfileMessage->set_nemid(profile.getNEMId());
120 
121  pAntennaProfileMessage->set_profileid(profile.getAntennaProfileId());
122 
123  pAntennaProfileMessage->set_antennaazimuthdegrees(profile.getAntennaAzimuthDegrees());
124 
125  pAntennaProfileMessage->set_antennaelevationdegrees(profile.getAntennaElevationDegrees());
126  }
127 
128  if(!msg.SerializeToString(&serialization))
129  {
130  throw SerializationException("unable to serialize : AntennaProfileEvent");
131  }
132 
133  return serialization;
134 }
std::string Serialization
Definition: serializable.h:42
An antenna profile event is used to set the antenna profile selection and pointing information for on...
SerializationException is thrown when an exception occurs during serialization or deserialization of ...
Event interface is the base for all events.
Definition: event.h:46
AntennaProfileEvent(const Serialization &serialization)
std::uint16_t NEMId
Definition: types.h:52
const AntennaProfiles & getAntennaProfiles() const
Serialization serialize() const override
std::list< AntennaProfile > AntennaProfiles
AntennaProfileEvent & operator=(const AntennaProfileEvent &rhs)