Loading...
Searching...
No Matches
satellite-output-fstream-string-container.cc
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
22
23#include "ns3/abort.h"
24#include "ns3/log.h"
25#include "ns3/simulator.h"
26
27#include <stdint.h>
28
29NS_LOG_COMPONENT_DEFINE("SatOutputFileStreamStringContainer");
30
31namespace ns3
32{
33
34TypeId
36{
37 static TypeId tid = TypeId("ns3::SatOutputFileStreamStringContainer")
38 .SetParent<Object>()
39 .AddConstructor<SatOutputFileStreamStringContainer>();
40 return tid;
41}
42
44 std::ios::openmode filemode)
48 m_fileName(filename),
49 m_fileMode(filemode)
50{
51 NS_LOG_FUNCTION(this << m_fileName << m_fileMode);
52}
53
58 m_fileName(),
60{
61 NS_LOG_FUNCTION(this);
62 NS_FATAL_ERROR("SatOutputFileStreamStringContainer::SatOutputFileStreamStringContainer - "
63 "Constructor not in use");
64}
65
72
73void
75{
76 NS_LOG_FUNCTION(this);
77
78 Reset();
79 Object::DoDispose();
80}
81
82void
84{
85 NS_LOG_FUNCTION(this);
86
87 OpenStream();
88
89 if (m_outputFileStream->is_open())
90 {
91 for (uint32_t i = 0; i < m_container.size(); i++)
92 {
93 *m_outputFileStream << m_container[i] << std::endl;
94 }
95 m_outputFileStream->close();
96 }
97 else
98 {
99 NS_ABORT_MSG("Output stream is not valid for writing.");
100 }
101
102 Reset();
103}
104
105void
107{
108 NS_LOG_FUNCTION(this);
109
110 m_container.push_back(newLine);
111}
112
113void
121
122void
124{
125 NS_LOG_FUNCTION(this);
126
127 ResetStream();
129}
130
131void
133{
134 NS_LOG_FUNCTION(this);
135
136 if (m_outputFileStreamWrapper != NULL)
137 {
140 }
142
143 m_fileName = "";
144 m_fileMode = std::ofstream::out;
145}
146
147void
149{
150 NS_LOG_FUNCTION(this);
151
152 if (!m_container.empty())
153 {
154 m_container.clear();
155 }
156}
157
158} // namespace ns3
void AddToContainer(std::string newLine)
Function for adding the line to container.
void OpenStream()
Function for opening the output file stream.
void WriteContainerToFile()
Function for writing the container contents to file.
std::ofstream * m_outputFileStream
Pointer to output file stream.
std::vector< std::string > m_container
Container for lines.
static TypeId GetTypeId(void)
NS-3 function for type id.
SatOutputFileStreamWrapper * m_outputFileStreamWrapper
Pointer to output file stream wrapper.
A class encapsulating an STL output stream.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.