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 NS_LOG_COMPONENT_DEFINE("SatPositionInputTraceContainer");
28 
29 namespace ns3
30 {
31 
32 NS_OBJECT_ENSURE_REGISTERED(SatPositionInputTraceContainer);
33 
34 TypeId
36 {
37  static TypeId tid = TypeId("ns3::SatPositionInputTraceContainer")
38  .SetParent<SatBaseTraceContainer>()
39  .AddConstructor<SatPositionInputTraceContainer>();
40  return tid;
41 }
42 
43 TypeId
45 {
46  NS_LOG_FUNCTION(this);
47 
48  return GetTypeId();
49 }
50 
52 {
53  NS_LOG_FUNCTION(this);
54 }
55 
57 {
58  NS_LOG_FUNCTION(this);
59 
60  Reset();
61 }
62 
63 void
65 {
66  NS_LOG_FUNCTION(this);
67 
68  Reset();
69 
70  SatBaseTraceContainer::DoDispose();
71 }
72 
73 void
75 {
76  NS_LOG_FUNCTION(this);
77 
78  if (!m_container.empty())
79  {
80  m_container.clear();
81  }
82 }
83 
84 Ptr<SatInputFileStreamTimeDoubleContainer>
85 SatPositionInputTraceContainer::AddNode(const std::string& filename)
86 {
87  NS_LOG_FUNCTION(this << filename);
88 
89  std::pair<container_t::iterator, bool> result = m_container.insert(
90  std::make_pair(filename,
91  CreateObject<SatInputFileStreamTimeDoubleContainer>(
92  filename.c_str(),
93  std::ios::in,
95 
96  if (result.second == false)
97  {
98  NS_FATAL_ERROR("SatPositionInputTraceContainer::AddNode failed");
99  }
100 
101  return result.first->second;
102 }
103 
104 Ptr<SatInputFileStreamTimeDoubleContainer>
106 {
107  NS_LOG_FUNCTION(this);
108 
109  container_t::iterator iter = m_container.find(key);
110 
111  if (iter == m_container.end())
112  {
113  return AddNode(key);
114  }
115 
116  return iter->second;
117 }
118 
122 {
123  NS_LOG_FUNCTION(this);
124 
125  std::vector<double> row = FindNode(key)->InterpolateBetweenClosestTimeSamples();
129  refEllipsoid);
130 }
131 
132 } // 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.