Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
orxonox::OutputStream Class Reference

This class is used to buffer output and send it to OutputManager whenever std::endl is passed to it. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/util/output/OutputStream.h>

Inheritance diagram for orxonox::OutputStream:

Public Member Functions

_UtilExport OutputStream ()
 Default constructor, initializes level and context with default values. More...
 
_UtilExport OutputStream (OutputLevel level, const OutputContextContainer &context)
 Constructor, initializes level and context with the provided values. More...
 
_UtilExport ~OutputStream ()
 Destructor, sends remaining output to OutputManager (if any). More...
 
bool acceptsOutput () const
 
const OutputContextContainergetOutputContext () const
 
const OutputLevel getOutputLevel () const
 
template<class T >
OutputStreamoperator<< (const T &val)
 Generic << operator which adds output to the stream. More...
 
OutputStreamoperator<< (std::ios_base &(*manipulator)(std::ios_base &))
 Sends a manipulator to the output stream. More...
 
OutputStreamoperator<< (std::ios &(*manipulator)(std::ios &))
 Sends a manipulator to the output stream. More...
 
OutputStreamoperator<< (std::ostream &(*manipulator)(std::ostream &))
 Sends a manipulator to the output stream and flushes the message if the manipulator is std::endl. More...
 
void _UtilExport setOutputAttributes (OutputLevel level, const OutputContextContainer &context)
 Defines level and context of the following output. More...
 

Private Types

typedef std::ostream &(* EndlType) (std::ostream &)
 

Private Member Functions

template<class T >
OutputStreamoutput (const T &val)
 Generic function to add values to the output stream, using the inherited << operator from std::ostringstream. More...
 
void _UtilExport sendMessage ()
 Sends the buffered message to OutputManager together with the stored level and context. More...
 

Private Attributes

bool bAcceptsOutput_
 After defining level and context of the following message, this flag is set according to the masks defined in OutputManager. If it is false, the OutputStream will throw away every output sent using the << operator. More...
 
const OutputContextContainercontext_
 The output context of the current message. More...
 
OutputLevel level_
 The output level of the current message. More...
 

Detailed Description

This class is used to buffer output and send it to OutputManager whenever std::endl is passed to it.

OutputStream inherits from std::ostringstream and acts like std::cout. This means you can use the << operator to write output to the stream. This class is used by the orxout() function.

Attention
You must end an output message with std::endl, otherwise the message won't be flushed. '\n' only adds a new line to the message.

The following code samples are all equivalent:

OutputStream stream;
stream.setOutputAttributes(user_info, context::example());
stream << "Hello World" << endl;
OutputStream stream(user_info, context::example());
stream << "Hello World" << endl;
orxout(user_info, context::example) << "Hello World" << endl;

Member Typedef Documentation

typedef std::ostream&(* orxonox::OutputStream::EndlType) (std::ostream &)
private

Constructor & Destructor Documentation

orxonox::OutputStream::OutputStream ( )

Default constructor, initializes level and context with default values.

orxonox::OutputStream::OutputStream ( OutputLevel  level,
const OutputContextContainer context 
)

Constructor, initializes level and context with the provided values.

orxonox::OutputStream::~OutputStream ( )

Destructor, sends remaining output to OutputManager (if any).

Member Function Documentation

bool orxonox::OutputStream::acceptsOutput ( ) const
inline
const OutputContextContainer* orxonox::OutputStream::getOutputContext ( ) const
inline
const OutputLevel orxonox::OutputStream::getOutputLevel ( ) const
inline
template<class T >
OutputStream& orxonox::OutputStream::operator<< ( const T &  val)
inline

Generic << operator which adds output to the stream.

OutputStream& orxonox::OutputStream::operator<< ( std::ios_base &(*)(std::ios_base &)  manipulator)
inline

Sends a manipulator to the output stream.

OutputStream& orxonox::OutputStream::operator<< ( std::ios &(*)(std::ios &)  manipulator)
inline

Sends a manipulator to the output stream.

OutputStream& orxonox::OutputStream::operator<< ( std::ostream &(*)(std::ostream &)  manipulator)
inline

Sends a manipulator to the output stream and flushes the message if the manipulator is std::endl.

template<class T >
OutputStream& orxonox::OutputStream::output ( const T &  val)
inlineprivate

Generic function to add values to the output stream, using the inherited << operator from std::ostringstream.

void orxonox::OutputStream::sendMessage ( )
private

Sends the buffered message to OutputManager together with the stored level and context.

Additionally empties the buffer.

void orxonox::OutputStream::setOutputAttributes ( OutputLevel  level,
const OutputContextContainer context 
)

Defines level and context of the following output.

Also sets the bAcceptsOutput_ flag according to the masks defined in OutputManager.

Member Data Documentation

bool orxonox::OutputStream::bAcceptsOutput_
private

After defining level and context of the following message, this flag is set according to the masks defined in OutputManager. If it is false, the OutputStream will throw away every output sent using the << operator.

const OutputContextContainer* orxonox::OutputStream::context_
private

The output context of the current message.

OutputLevel orxonox::OutputStream::level_
private

The output level of the current message.


The documentation for this class was generated from the following files: