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