kvh_geo_fog_3d_packet_storage.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (Apache 2.0)
3  *
4  * Copyright (c) 2019, The MITRE Corporation.
5  * All rights reserved.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * https://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * Sections of this project contains content developed by The MITRE Corporation.
20  * If this code is used in a deployment or embedded within another project,
21  * it is requested that you send an email to opensource@mitre.org in order to
22  * let us know where this software is being used.
23  *********************************************************************/
24 
34 #pragma once
35 
36 // STD
37 #include <map>
38 #include <memory> // share_ptr
39 #include <vector>
40 #include <typeinfo>
41 
42 
43 // GEO-FOG SDK
44 #include "an_packet_protocol.h"
45 #include "spatial_packets.h"
47 
48 namespace kvh
49 {
50 
58  typedef std::map<packet_id_e, std::pair<bool, std::shared_ptr<void>>> KvhPacketMap;
59 
65  typedef std::vector<std::pair<packet_id_e, uint16_t>> KvhPacketRequest;
66 
68  {
69 
70  private:
72 
75  public:
77 
84  int Init(KvhPacketRequest &);
85 
92 
110  template <class T>
111  int UpdatePacket(packet_id_e _packetId, T& _packetData)
112  {
113  // Check if packet type matches packet id
114  if (supportedPackets_.count(_packetId) <= 0 || packetTypeStr_[_packetId] != typeid(T).name())
115  {
116  return -1;
117  }
118  else if (this->Contains(_packetId))
119  {
120  *static_cast<T*>(packetMap_[_packetId].second.get()) = _packetData;
121  return 0;
122  }
123 
124  return -2;
125  }
126 
133  int SetPacketUpdated(packet_id_e, bool);
134 
142 
150  template <class T>
151  int GetPacket(packet_id_e _packetId, T& _packet)
152  {
153  // Check if packet types matches id
154  if (supportedPackets_.count(_packetId) <= 0 || packetTypeStr_[_packetId] != typeid(T).name())
155  {
156  return -1;
157  }
158  else if (this->Contains(_packetId))
159  {
160  _packet = *static_cast<T*>(packetMap_[_packetId].second.get());
161  return 0;
162  }
163 
164  return -2;
165  }
166 
174  bool Contains(packet_id_e);
175 
182  int Size();
183 
189  static void PrintPacketTypes();
190 
196  static void PrintPacketSizes();
197  };
198 } // namespace kvh
kvh::KvhPacketRequest
std::vector< std::pair< packet_id_e, uint16_t > > KvhPacketRequest
Definition: kvh_geo_fog_3d_packet_storage.hpp:65
kvh::KvhPacketStorage::Contains
bool Contains(packet_id_e)
Definition: packet_storage.cpp:179
kvh::KvhPacketStorage::PacketIsUpdated
bool PacketIsUpdated(packet_id_e)
Definition: packet_storage.cpp:164
kvh
Definition: kvh_geo_fog_3d_device_configuration.hpp:44
kvh::KvhPacketStorage::Size
int Size()
Definition: packet_storage.cpp:188
an_packet_protocol.h
kvh::KvhPacketMap
std::map< packet_id_e, std::pair< bool, std::shared_ptr< void > > > KvhPacketMap
Definition: kvh_geo_fog_3d_packet_storage.hpp:58
kvh::KvhPacketStorage::Init
int Init(KvhPacketRequest &)
Correctly sets up a KvhPacketMap for the requested packets.
Definition: packet_storage.cpp:37
kvh_geo_fog_3d_global_vars.hpp
global variables used to store packet information.
kvh::KvhPacketStorage
Definition: kvh_geo_fog_3d_packet_storage.hpp:67
kvh::KvhPacketStorage::packetMap_
KvhPacketMap packetMap_
Definition: kvh_geo_fog_3d_packet_storage.hpp:71
kvh::KvhPacketStorage::PrintPacketSizes
static void PrintPacketSizes()
Definition: packet_storage.cpp:211
kvh::KvhPacketStorage::AddPacket
int AddPacket(packet_id_e)
Definition: packet_storage.cpp:72
kvh::packetTypeStr_
std::map< packet_id_e, std::string > packetTypeStr_
Holds the string value for the different types of structs.
Definition: kvh_global_vars.cpp:74
kvh::KvhPacketStorage::PrintPacketTypes
static void PrintPacketTypes()
Definition: packet_storage.cpp:198
packet_id_e
packet_id_e
Definition: spatial_packets.h:45
kvh::KvhPacketStorage::UpdatePacket
int UpdatePacket(packet_id_e _packetId, T &_packetData)
Definition: kvh_geo_fog_3d_packet_storage.hpp:111
kvh::KvhPacketStorage::GetPacket
int GetPacket(packet_id_e _packetId, T &_packet)
Definition: kvh_geo_fog_3d_packet_storage.hpp:151
kvh::KvhPacketStorage::SetPacketUpdated
int SetPacketUpdated(packet_id_e, bool)
Definition: packet_storage.cpp:148
kvh::supportedPackets_
std::set< packet_id_e > supportedPackets_
Set of packets containing all packet_id's we support.
Definition: kvh_global_vars.cpp:37
kvh::KvhPacketStorage::KvhPacketStorage
KvhPacketStorage()
Definition: packet_storage.cpp:37
spatial_packets.h


kvh_geo_fog_3d_driver
Author(s): Trevor Bostic , Zach LaCelle
autogenerated on Wed Mar 2 2022 00:28:57