Loading...
Searching...
No Matches
satellite-output-fstream-wrapper.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/fatal-impl.h"
25#include "ns3/log.h"
26
27#include <fstream>
28#include <stdint.h>
29
30NS_LOG_COMPONENT_DEFINE("SatOutputFileStreamWrapper");
31
32namespace ns3
33{
34
36 std::ios::openmode filemode)
37 : m_destroyable(true)
38{
39 NS_LOG_FUNCTION(this << filename << filemode);
40
41 m_ofstream = new std::ofstream(filename.c_str(), filemode);
42
43 NS_ABORT_MSG_UNLESS(m_ofstream->is_open(),
44 "SatOutputFileStreamWrapper::SatOutputFileStreamWrapper(): "
45 << "Unable to Open " << filename << " for mode " << filemode);
46
47 FatalImpl::RegisterStream(m_ofstream);
48}
49
51{
52 NS_LOG_FUNCTION(this);
53
54 FatalImpl::UnregisterStream(m_ofstream);
55
56 if (m_destroyable)
57 {
58 delete m_ofstream;
59 m_ofstream = 0;
60 }
61 m_destroyable = false;
62}
63
64std::ofstream*
66{
67 NS_LOG_FUNCTION(this);
68
69 return m_ofstream;
70}
71
72} // namespace ns3
SatOutputFileStreamWrapper(std::string filename, std::ios::openmode filemode)
Constructor.
std::ofstream * GetStream(void)
Return a pointer to an ofstream previously set in the wrapper.
std::ofstream * m_ofstream
Output file stream.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.