My Project
OSOutput Class Reference

This class handles all the output from OSSolverService, OSAmplClient and other executables derived from them. Every output statement in the code uses methods in this class, passing information about the area that originated the request as well as the print, verbosity or severity level of the message. The message creates output only if the print level matches the user specifications. The main advantage of doing things this way is that multiple output streams can be maintained, each tailored to a specific need and containing only output that the user really wants to see. There can be as many output streams as needed; each one has an identifying name ("stdout" and "stderr" are reserved names) and an array of print levels, one for each area. The class is implemented as a Singleton, which means that two private methods must be defined in the header but must never be implemented: a copy constructor, and an equality operator. More...

#include <OSOutput.h>

Inheritance diagram for OSOutput:
OSReferencedObject

Public Member Functions

 OSOutput ()
 Constructor.
 
 ~OSOutput ()
 Destructor.
 
bool OSPrint (ENUM_OUTPUT_AREA area, ENUM_OUTPUT_LEVEL level, std::string outStr)
 This is the main method to output a string All output generated by the program should ultimately use this method.
 
void FlushAllBuffers ()
 Flush all buffers.
 
bool SetPrintLevel (std::string name, ENUM_OUTPUT_LEVEL *level, int dim)
 Modify all print levels associated with a channel.
 
bool SetPrintLevel (std::string name, ENUM_OUTPUT_LEVEL level)
 set the print level associated with a channel
 
int AddChannel (std::string name)
 Add a channel to the array outputChannel.
 
bool DeleteChannel (std::string name)
 Delete a channel from the array outputChannel.
 
int FindChannel (std::string name)
 Find the position of a channel within the array *outputChannel.
 
- Public Member Functions inherited from OSReferencedObject
 OSReferencedObject ()
 
virtual ~OSReferencedObject ()
 
int ReferenceCount () const
 
void AddRef (const OSReferencer *referencer) const
 
void ReleaseRef (const OSReferencer *referencer) const
 

Private Member Functions

 OSOutput (const OSOutput &)
 
OSOutputoperator= (const OSOutput &)
 

Private Attributes

int nOfOutputs
 The number of output channels that have been defined.
 
OSOutputChannel ** outputChannel
 The array of output channels currently in use.
 

Detailed Description

This class handles all the output from OSSolverService, OSAmplClient and other executables derived from them. Every output statement in the code uses methods in this class, passing information about the area that originated the request as well as the print, verbosity or severity level of the message. The message creates output only if the print level matches the user specifications. The main advantage of doing things this way is that multiple output streams can be maintained, each tailored to a specific need and containing only output that the user really wants to see. There can be as many output streams as needed; each one has an identifying name ("stdout" and "stderr" are reserved names) and an array of print levels, one for each area. The class is implemented as a Singleton, which means that two private methods must be defined in the header but must never be implemented: a copy constructor, and an equality operator.

Definition at line 146 of file OSOutput.h.

Constructor & Destructor Documentation

◆ OSOutput() [1/2]

OSOutput::OSOutput ( const OSOutput & )
private

◆ OSOutput() [2/2]

OSOutput::OSOutput ( )

Constructor.

Definition at line 161 of file OSOutput.cpp.

◆ ~OSOutput()

OSOutput::~OSOutput ( )

Destructor.

Definition at line 169 of file OSOutput.cpp.

Member Function Documentation

◆ operator=()

OSOutput & OSOutput::operator= ( const OSOutput & )
private

◆ OSPrint()

bool OSOutput::OSPrint ( ENUM_OUTPUT_AREA area,
ENUM_OUTPUT_LEVEL level,
std::string outStr )

This is the main method to output a string All output generated by the program should ultimately use this method.

Parameters
levelthe print level associated with the string
areathe area of the code in which the output was generated
outStrthe string to be output
Returns
whether the output operation was successful

Definition at line 178 of file OSOutput.cpp.

◆ FlushAllBuffers()

void OSOutput::FlushAllBuffers ( )

Flush all buffers.

Definition at line 188 of file OSOutput.cpp.

◆ SetPrintLevel() [1/2]

bool OSOutput::SetPrintLevel ( std::string name,
ENUM_OUTPUT_LEVEL * level,
int dim )

Modify all print levels associated with a channel.

Parameters
nameThe name of the channel ("stdout" and "stderr" are reserved names)
levelThe array of print levels used for the output to this channel
dimThe number of entries in this array
Returns
whether the operation was successful

Definition at line 194 of file OSOutput.cpp.

◆ SetPrintLevel() [2/2]

bool OSOutput::SetPrintLevel ( std::string name,
ENUM_OUTPUT_LEVEL level )

set the print level associated with a channel

Parameters
nameThe name of the channel ("stdout" and "stderr" are reserved names)
levelThe print level used for the output to this channel if < ENUM_OUTPUT_LEVEL_NUMBER_OF_LEVELS, set the (same) print level in all areas otherwise set the print level only in one particular area
Returns
whether the operation was successful

Definition at line 209 of file OSOutput.cpp.

◆ AddChannel()

int OSOutput::AddChannel ( std::string name)

Add a channel to the array outputChannel.

Parameters
nameThe name of the channel ("stdout" and "stderr" are reserved names)
Returns
the status of the operation: 0: completed successfully 1: channel previously defined 2: out of memory 3: other error condition

Definition at line 233 of file OSOutput.cpp.

◆ DeleteChannel()

bool OSOutput::DeleteChannel ( std::string name)

Delete a channel from the array outputChannel.

Parameters
nameThe name of the channel
Returns
whether the operation was completed successfully

Definition at line 280 of file OSOutput.cpp.

◆ FindChannel()

int OSOutput::FindChannel ( std::string name)

Find the position of a channel within the array *outputChannel.

Parameters
nameThe name of the channel
Returns
the position if found; -1 otherwise

Definition at line 312 of file OSOutput.cpp.

Member Data Documentation

◆ nOfOutputs

int OSOutput::nOfOutputs
private

The number of output channels that have been defined.

Definition at line 223 of file OSOutput.h.

◆ outputChannel

OSOutputChannel** OSOutput::outputChannel
private

The array of output channels currently in use.

Definition at line 228 of file OSOutput.h.


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