satellite-output-fstream-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_OUTPUT_FSTREAM_DOUBLE_CONTAINER_H
22 #define SAT_OUTPUT_FSTREAM_DOUBLE_CONTAINER_H
23 
25 
26 #include "ns3/object.h"
27 #include <ns3/gnuplot.h>
28 
29 #include <fstream>
30 
31 namespace ns3
32 {
33 
42 {
43  public:
44  typedef enum
45  {
46  RAW,
50 
55  static TypeId GetTypeId(void);
56 
63  SatOutputFileStreamDoubleContainer(std::string filename,
64  std::ios::openmode filemode,
65  uint32_t valuesInRow);
66 
71 
76 
80  void WriteContainerToFile();
81 
85  void AddToContainer(std::vector<double> newItem);
86 
90  void DoDispose();
91 
101  void EnableFigureOutput(std::string title,
102  std::string legendY,
103  std::string legendX,
104  std::string keyPosition,
105  FigureUnitConversion_t figureUnitConversionType,
106  Gnuplot2dDataset::Style style);
107 
108  private:
112  void Reset();
113 
117  void ResetStream();
118 
122  void ClearContainer();
123 
127  void OpenStream();
128 
132  void PrintFigure();
133 
139  double ConvertValue(double value);
140 
145  Gnuplot2dDataset GetGnuplotDataset();
146 
151  Gnuplot GetGnuplot();
152 
157 
161  std::ofstream* m_outputFileStream;
162 
166  std::vector<std::vector<double>> m_container;
167 
171  std::string m_fileName;
172 
176  std::ios::openmode m_fileMode;
177 
181  uint32_t m_valuesInRow;
182 
187 
191  std::string m_title;
192 
196  std::string m_legendY;
197 
201  std::string m_legendX;
202 
206  std::string m_keyPosition;
207 
212 
216  Gnuplot2dDataset::Style m_style;
217 };
218 
219 } // namespace ns3
220 
221 #endif /* SAT_OUTPUT_FSTREAM_DOUBLE_CONTAINER_H */
Class for output file stream container for double values.
double ConvertValue(double value)
Function for converting the container data samples.
void OpenStream()
Function for opening the output file stream.
std::vector< std::vector< double > > m_container
Container for value rows.
SatOutputFileStreamWrapper * m_outputFileStreamWrapper
Pointer to output file stream wrapper.
bool m_printFigure
Enable / disable printing of container contents into a figure.
Gnuplot2dDataset GetGnuplotDataset()
Function for creating Gnuplot datasets.
void ClearContainer()
Function for clearing the container.
Gnuplot2dDataset::Style m_style
2D dataset figure style
FigureUnitConversion_t m_figureUnitConversionType
Describes which unit conversion should be used with the figure.
void AddToContainer(std::vector< double > newItem)
Function for adding the values to container.
void PrintFigure()
Function for printing the container contents into a figure.
std::ofstream * m_outputFileStream
Pointer to output file stream.
void EnableFigureOutput(std::string title, std::string legendY, std::string legendX, std::string keyPosition, FigureUnitConversion_t figureUnitConversionType, Gnuplot2dDataset::Style style)
Function for enabling the figure output.
void WriteContainerToFile()
Function for writing the container contents to file.
static TypeId GetTypeId(void)
NS-3 function for type id.
A class encapsulating an STL output stream.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.