lestes::std::ostream_wrapper Class Reference

Wrapper for ostream. More...

#include <ostream_wrapper.hh>

Inheritance diagram for lestes::std::ostream_wrapper:

lestes::std::object lestes::std::mem::keystone List of all members.

Public Types

typedef ::std::ostream * stream_type

Public Member Functions

virtual ~ostream_wrapper (void)
 Finalizes the object.
void release (void)
 Releases the stream.
stream_type stream_get (void) const
 Returns underlying stream.
bool owned_get (void) const
 Returns the ownership flag.

Static Public Member Functions

static ptr< ostream_wrappercreate (stream_type a_stream, bool a_owned)
 Returns the wrapper.

Protected Member Functions

 ostream_wrapper (stream_type a_stream, bool owned)
 Creates the wrapper.

Private Member Functions

 ostream_wrapper (const ostream_wrapper &)
 Hides copy constructor.
ostream_wrapperoperator= (const ostream_wrapper &)
 Hides assignment operator.

Private Attributes

stream_type stream
 The wrapped ostream.
bool owned
 Ownership flag.

Detailed Description

Wrapper for ostream.

Represents output stream wrapper, with ownership policy of the stream.

Definition at line 48 of file ostream_wrapper.hh.


Member Typedef Documentation

typedef ::std::ostream* lestes::std::ostream_wrapper::stream_type

Definition at line 50 of file ostream_wrapper.hh.


Constructor & Destructor Documentation

lestes::std::ostream_wrapper::~ostream_wrapper ( void   )  [virtual]

Finalizes the object.

Finalizes the object. Releases the stream if owned.

Definition at line 59 of file ostream_wrapper.cc.

References release().

00060 {
00061         release();
00062 }

lestes::std::ostream_wrapper::ostream_wrapper ( stream_type  a_stream,
bool  a_owned 
) [protected]

Creates the wrapper.

Creates the wrapper.

Precondition:
a_stream != NULL
Parameters:
a_stream The stream to wrap.
a_owned The ownership flag.

Definition at line 49 of file ostream_wrapper.cc.

Referenced by create().

00049                                                                   :
00050         stream(checked(a_stream)),
00051         owned(a_owned)
00052 {
00053 }

lestes::std::ostream_wrapper::ostream_wrapper ( const ostream_wrapper  )  [private]

Hides copy constructor.


Member Function Documentation

void lestes::std::ostream_wrapper::release ( void   ) 

Releases the stream.

Releases the stream if it was owned.

Postcondition:
stream_get() == NULL

Definition at line 68 of file ostream_wrapper.cc.

References owned, and stream.

Referenced by ~ostream_wrapper().

00069 {
00070         if (owned) delete stream;
00071         // set to NULL anyway
00072         stream = NULL;
00073 }

ostream_wrapper::stream_type lestes::std::ostream_wrapper::stream_get ( void   )  const

Returns underlying stream.

Returns the wrapped stream.

Precondition:
release() was not called (stream_get() != NULL)
Returns:
The stream.

Definition at line 89 of file ostream_wrapper.cc.

References lassert2, and stream.

00090 {
00091         lassert2(stream,"The stream is invalid because release() was already called.");
00092         return stream;
00093 }

bool lestes::std::ostream_wrapper::owned_get ( void   )  const

Returns the ownership flag.

Returns the ownership.

Returns:
true If the stream is owned by the wrapper.

Definition at line 79 of file ostream_wrapper.cc.

References owned.

00080 {
00081         return owned;
00082 }

ptr< ostream_wrapper > lestes::std::ostream_wrapper::create ( stream_type  a_stream,
bool  a_owned 
) [static]

Returns the wrapper.

Creates the wrapper.

Precondition:
a_stream != NULL

a_stream is allocated via new when a_owned is true

Parameters:
a_stream The stream to wrap.
a_owned The ownership flag.
Returns:
The new wrapper of a_stream.

Definition at line 103 of file ostream_wrapper.cc.

References ostream_wrapper().

00104 {
00105         return new ostream_wrapper(a_stream,a_owned);
00106 }

ostream_wrapper& lestes::std::ostream_wrapper::operator= ( const ostream_wrapper  )  [private]

Hides assignment operator.


Member Data Documentation

stream_type lestes::std::ostream_wrapper::stream [private]

The wrapped ostream.

Definition at line 66 of file ostream_wrapper.hh.

Referenced by release(), and stream_get().

bool lestes::std::ostream_wrapper::owned [private]

Ownership flag.

Definition at line 68 of file ostream_wrapper.hh.

Referenced by owned_get(), and release().


The documentation for this class was generated from the following files:
Generated on Mon Feb 12 18:26:00 2007 for lestes by doxygen 1.5.1-20070107