merge new TCP code

This commit is contained in:
Josh Pelkey
2010-12-17 13:57:22 -05:00
parent a650f91b57
commit da85b34487
35 changed files with 4397 additions and 2548 deletions

View File

@@ -27,18 +27,27 @@ NS_LOG_COMPONENT_DEFINE ("OutputStreamWrapper");
namespace ns3 {
OutputStreamWrapper::OutputStreamWrapper (std::string filename, std::ios::openmode filemode)
: m_ostream (new std::ofstream ())
: m_destroyable (true)
{
std::ofstream* os = new std::ofstream ();
os->open (filename.c_str (), filemode);
m_ostream = os;
FatalImpl::RegisterStream (m_ostream);
NS_ABORT_MSG_UNLESS (os->is_open (), "AsciiTraceHelper::CreateFileStream(): " <<
"Unable to Open " << filename << " for mode " << filemode);
}
OutputStreamWrapper::OutputStreamWrapper (std::ostream* os)
: m_ostream (os), m_destroyable (false)
{
FatalImpl::RegisterStream (m_ostream);
m_ostream->open (filename.c_str (), filemode);
NS_ABORT_MSG_UNLESS (m_ostream->is_open (), "AsciiTraceHelper::CreateFileStream(): " <<
"Unable to Open " << filename << " for mode " << filemode);
NS_ABORT_MSG_UNLESS (m_ostream->good (), "Output stream is not vaild for writing.");
}
OutputStreamWrapper::~OutputStreamWrapper ()
{
FatalImpl::UnregisterStream (m_ostream);
delete m_ostream;
if (m_destroyable) delete m_ostream;
m_ostream = 0;
}

View File

@@ -71,6 +71,7 @@ class OutputStreamWrapper : public SimpleRefCount<OutputStreamWrapper>
{
public:
OutputStreamWrapper (std::string filename, std::ios::openmode filemode);
OutputStreamWrapper (std::ostream* os);
~OutputStreamWrapper ();
/**
@@ -83,7 +84,8 @@ public:
std::ostream *GetStream (void);
private:
std::ofstream *m_ostream;
std::ostream *m_ostream;
bool m_destroyable;
};
} //namespace ns3