satellite-position-input-trace-container.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2018 CNES
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathias Ettinger <mettinger@toulouse.viveris.com>
19  */
20 
22 
23 #include "../utils/satellite-env-variables.h"
24 
25 #include <ns3/log.h>
26 
27 #include <ios>
28 #include <stdint.h>
29 #include <string>
30 #include <utility>
31 #include <vector>
32 
33 NS_LOG_COMPONENT_DEFINE("SatPositionInputTraceContainer");
34 
35 namespace ns3
36 {
37 
38 NS_OBJECT_ENSURE_REGISTERED(SatPositionInputTraceContainer);
39 
40 TypeId
42 {
43  static TypeId tid = TypeId("ns3::SatPositionInputTraceContainer")
44  .SetParent<SatBaseTraceContainer>()
45  .AddConstructor<SatPositionInputTraceContainer>();
46  return tid;
47 }
48 
49 TypeId
51 {
52  NS_LOG_FUNCTION(this);
53 
54  return GetTypeId();
55 }
56 
58 {
59  NS_LOG_FUNCTION(this);
60 }
61 
63 {
64  NS_LOG_FUNCTION(this);
65 
66  Reset();
67 }
68 
69 void
71 {
72  NS_LOG_FUNCTION(this);
73 
74  Reset();
75 
76  SatBaseTraceContainer::DoDispose();
77 }
78 
79 void
81 {
82  NS_LOG_FUNCTION(this);
83 
84  if (!m_container.empty())
85  {
86  m_container.clear();
87  }
88 }
89 
90 Ptr<SatInputFileStreamTimeDoubleContainer>
91 SatPositionInputTraceContainer::AddNode(const std::string& filename)
92 {
93  NS_LOG_FUNCTION(this << filename);
94 
95  std::pair<container_t::iterator, bool> result = m_container.insert(
96  std::make_pair(filename,
97  CreateObject<SatInputFileStreamTimeDoubleContainer>(
98  filename.c_str(),
99  std::ios::in,
101 
102  if (result.second == false)
103  {
104  NS_FATAL_ERROR("SatPositionInputTraceContainer::AddNode failed");
105  }
106 
107  return result.first->second;
108 }
109 
110 Ptr<SatInputFileStreamTimeDoubleContainer>
112 {
113  NS_LOG_FUNCTION(this);
114 
115  container_t::iterator iter = m_container.find(key);
116 
117  if (iter == m_container.end())
118  {
119  return AddNode(key);
120  }
121 
122  return iter->second;
123 }
124 
128 {
129  NS_LOG_FUNCTION(this);
130 
131  std::vector<double> row = FindNode(key)->InterpolateBetweenClosestTimeSamples();
135  refEllipsoid);
136 }
137 
138 } // namespace ns3
GeoCoordinate class is used to store and operate with geodetic coordinates.
Base class for trace containers such as interference or fading traces.
static const uint32_t POSITION_TRACE_DEFAULT_ALTITUDE_INDEX
Default altitude value index for positions traces.
static const uint32_t POSITION_TRACE_DEFAULT_LATITUDE_INDEX
Default latitude value index for positions traces.
static const uint32_t POSITION_TRACE_DEFAULT_LONGITUDE_INDEX
Default longitude value index for positions traces.
static const uint32_t POSITION_TRACE_DEFAULT_NUMBER_OF_COLUMNS
Default number of columns for position traces.
Ptr< SatInputFileStreamTimeDoubleContainer > AddNode(const std::string &key)
Function for adding the node to the map.
static TypeId GetTypeId(void)
NS-3 type id function.
void Reset()
Function for resetting the variables.
TypeId GetInstanceTypeId(void) const
NS-3 instance type id function.
GeoCoordinate GetPosition(const std::string &key, GeoCoordinate::ReferenceEllipsoid_t refEllipsoid)
Function for getting the Rx power density.
Ptr< SatInputFileStreamTimeDoubleContainer > FindNode(const std::string &key)
Function for finding the container matching the key.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.