satellite-input-fstream-time-double-container.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Magister Solutions Ltd.
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: Frans Laakso <frans.laakso@magister.fi>
19  */
20 
21 #ifndef SAT_INPUT_FSTREAM_TIME_DOUBLE_CONTAINER_H
22 #define SAT_INPUT_FSTREAM_TIME_DOUBLE_CONTAINER_H
23 
25 
26 #include "ns3/object.h"
27 
28 #include <fstream>
29 
30 namespace ns3
31 {
32 
43 {
44  public:
49  static TypeId GetTypeId(void);
50 
57  SatInputFileStreamTimeDoubleContainer(std::string filename,
58  std::ios::openmode filemode,
59  uint32_t valuesInRow);
60 
65 
70 
77  void UpdateContainer(std::string filename, std::ios::openmode filemode, uint32_t valuesInRow);
78 
83  std::vector<double> ProceedToNextClosestTimeSample();
84 
90  std::vector<double> InterpolateBetweenClosestTimeSamples();
91 
95  void DoDispose();
96 
97  private:
101  void Reset();
102 
106  void ResetStream();
107 
111  void ClearContainer();
112 
117  std::vector<double> ReadRow();
118 
126  bool FindNextClosest(uint32_t lastValidPosition,
127  double timeShiftValue,
128  double comparisonTimeValue);
129 
133  void CheckContainerSanity();
134 
139 
143  std::ifstream* m_inputFileStream;
144 
148  std::vector<std::vector<double>> m_container;
149 
153  std::string m_fileName;
154 
158  std::ios::openmode m_fileMode;
159 
163  uint32_t m_valuesInRow;
164 
169 
173  uint32_t m_numOfPasses;
174 
179 
183  uint32_t m_timeColumn;
184 };
185 
186 } // namespace ns3
187 
188 #endif /* SAT_INPUT_FSTREAM_TIME_DOUBLE_CONTAINER_H */
Class for input file stream container for storing double values.
bool FindNextClosest(uint32_t lastValidPosition, double timeShiftValue, double comparisonTimeValue)
Function for locating the next closest value index.
std::vector< std::vector< double > > m_container
Container for value rows.
uint32_t m_timeColumn
Index for column which contains time information.
std::vector< double > ReadRow()
Function for reading a row from file.
SatInputFileStreamWrapper * m_inputFileStreamWrapper
Pointer to input file stream wrapper.
std::vector< double > ProceedToNextClosestTimeSample()
Function for locating the next closest time sample and returning the values related to it.
uint32_t m_numOfPasses
Number for how many times the available samples have been looped over.
void UpdateContainer(std::string filename, std::ios::openmode filemode, uint32_t valuesInRow)
Function for updating the container.
std::vector< double > InterpolateBetweenClosestTimeSamples()
Function for locating time samples enclosing the current time and a linear interpolation between thes...
A class encapsulating an STL input stream.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.