SoPlex Documentation
Loading...
Searching...
No Matches

Wrapper for several output streams. A verbosity level is used to decide which stream to use and whether to really print a given message. Regardless of whether the verbosity level is set via a manipulator or via the member function, it is persistent until a new value is set. More...

#include <spxout.h>

Classes

struct  struct_Verbosity
 helper struct for the output operator More...
 

Public Types

Output control types
enum  Verbosity {
  ERROR = 0 , WARNING = 1 , DEBUG = 2 , INFO1 = 3 ,
  INFO2 = 4 , INFO3 = 5
}
 Verbosity level. More...
 

Public Member Functions

Construction / destruction
 SPxOut ()
 constructor
 
virtual ~SPxOut ()
 destructor
 
 SPxOut (const SPxOut &)
 copy constructor
 
SPxOutoperator= (const SPxOut &)
 assignment operator
 
Verbosity
virtual void setVerbosity (const Verbosity &v)
 
Verbosity getVerbosity () const
 
Wrappers for the current stream
bool good () const
 
bool operator! () const
 
std::streamsize precision () const
 

Private Attributes

Private data
Verbosity m_verbosity
 verbosity level
 
std::ostream ** m_streams
 array of pointers to internal streams, indexed by verbosity level
 

Getting / setting streams

virtual void setStream (const Verbosity &verbosity, std::ostream &stream)
 Sets the stream for the specified verbosity level.
 
std::ostream & getStream (const Verbosity &verbosity) const
 Returns the stream for the specified verbosity level.
 
std::ostream & getCurrentStream () const
 Returns the stream for the current verbosity.
 
static void setScientific (std::ostream &stream, int precision=8)
 Sets the precision of the stream to 16 and the floatfield to scientifix.
 
static void setFixed (std::ostream &stream, int precision=8)
 Sets the precision of the stream to 8 and the floatfield to fixed.
 
template<typename T , typename... Args, typename std::enable_if< !std::is_base_of< EnableDebugOutput, T >::value, int >::type = 0>
static void debug (const T *, Args &&... args)
 
template<typename T , typename... Args, typename std::enable_if< std::is_base_of< EnableDebugOutput, T >::value, int >::type = 0>
static void debug (const T *, Args &&... args)
 

Detailed Description

Wrapper for several output streams. A verbosity level is used to decide which stream to use and whether to really print a given message. Regardless of whether the verbosity level is set via a manipulator or via the member function, it is persistent until a new value is set.

Most ostream member functions are not provided here; use the corresponding stream manipulators (e.g., setprecision()) instead. These are passed on to the current ostream, which is chosen according to the verbosity level. In particular, this means that the first element in an output stream should always be the verbosity. For instance, use

spxout << verb( SPxOut::WARNING ) << std::setw( 15 ) << 42 << std::endl;
SPxOut::struct_Verbosity verb(const SPxOut::Verbosity &v)
manipulator to be used in an output statement
Definition spxout.h:252

or

spxout.setVerbosity( SPxOut::WARNING );
spxout << std::setw( 15 ) << 42 << std::endl;

instead of

spxout << std::setw( 15 ) << verb( SPxOut::WARNING ) << 42 << std::endl;

in order to make sure that std::setw( 15 ) is applied to the warning stream.

Definition at line 77 of file spxout.h.

Member Enumeration Documentation

◆ Verbosity

enum Verbosity

Verbosity level.

Enumerator
ERROR 
WARNING 
DEBUG 
INFO1 
INFO2 
INFO3 

Definition at line 86 of file spxout.h.

Constructor & Destructor Documentation

◆ SPxOut() [1/2]

SPxOut ( )

constructor

Definition at line 32 of file spxout.cpp.

References SPxOut::DEBUG, SPxOut::ERROR, SPxOut::INFO3, SPxOut::m_streams, soplex::spx_alloc(), and SPxOut::WARNING.

◆ ~SPxOut()

~SPxOut ( )
virtual

destructor

Definition at line 47 of file spxout.cpp.

References SPxOut::m_streams, and soplex::spx_free().

◆ SPxOut() [2/2]

SPxOut ( const SPxOut & rhs)

Member Function Documentation

◆ debug() [1/2]

template<typename T , typename... Args, typename std::enable_if< !std::is_base_of< EnableDebugOutput, T >::value, int >::type = 0>
static void debug ( const T * ,
Args &&... args )
static

◆ debug() [2/2]

template<typename T , typename... Args, typename std::enable_if< std::is_base_of< EnableDebugOutput, T >::value, int >::type = 0>
static void debug ( const T * ,
Args &&... args )
static

Definition at line 211 of file spxout.h.

◆ getCurrentStream()

◆ getStream()

std::ostream & getStream ( const Verbosity & verbosity) const

Returns the stream for the specified verbosity level.

Definition at line 171 of file spxout.h.

References SPxOut::m_streams.

Referenced by SPxOut::getCurrentStream().

◆ getVerbosity()

Verbosity getVerbosity ( ) const

Definition at line 131 of file spxout.h.

References SPxOut::m_verbosity.

Referenced by SPxOut::getCurrentStream().

◆ good()

bool good ( ) const

Definition at line 143 of file spxout.h.

References SPxOut::getCurrentStream().

◆ operator!()

bool operator! ( ) const

Definition at line 148 of file spxout.h.

References SPxOut::getCurrentStream().

◆ operator=()

SPxOut & operator= ( const SPxOut & base)

assignment operator

Definition at line 52 of file spxout.cpp.

References SPxOut::DEBUG, SPxOut::INFO3, SPxOut::m_streams, and SPxOut::m_verbosity.

◆ precision()

std::streamsize precision ( ) const

Definition at line 153 of file spxout.h.

References SPxOut::getCurrentStream().

Referenced by SPxOut::setFixed(), and SPxOut::setScientific().

◆ setFixed()

static void setFixed ( std::ostream & stream,
int precision = 8 )
static

Sets the precision of the stream to 8 and the floatfield to fixed.

Definition at line 191 of file spxout.h.

References SPxOut::precision().

Referenced by SPxLPBase< R >::printProblemStatistics().

◆ setScientific()

static void setScientific ( std::ostream & stream,
int precision = 8 )
static

Sets the precision of the stream to 16 and the floatfield to scientifix.

Definition at line 185 of file spxout.h.

References SPxOut::precision().

◆ setStream()

virtual void setStream ( const Verbosity & verbosity,
std::ostream & stream )
virtual

Sets the stream for the specified verbosity level.

Definition at line 164 of file spxout.h.

References SPxOut::m_streams.

◆ setVerbosity()

virtual void setVerbosity ( const Verbosity & v)
virtual

Definition at line 125 of file spxout.h.

References SPxOut::m_verbosity.

Referenced by soplex::operator<<().

Member Data Documentation

◆ m_streams

std::ostream** m_streams
private

array of pointers to internal streams, indexed by verbosity level

Definition at line 225 of file spxout.h.

Referenced by SPxOut::getStream(), SPxOut::operator=(), SPxOut::setStream(), SPxOut::SPxOut(), SPxOut::SPxOut(), and SPxOut::~SPxOut().

◆ m_verbosity

Verbosity m_verbosity
private

verbosity level

Definition at line 223 of file spxout.h.

Referenced by SPxOut::getVerbosity(), SPxOut::operator=(), SPxOut::setVerbosity(), and SPxOut::SPxOut().