Public Member Functions | Private Member Functions | Private Attributes | List of all members
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:
Inheritance graph
[legend]
Collaboration diagram for OSOutput:
Collaboration graph
[legend]

Public Member Functions

 OSOutput ()
 Constructor. More...
 
 ~OSOutput ()
 Destructor. More...
 
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. More...
 
void FlushAllBuffers ()
 Flush all buffers. More...
 
bool SetPrintLevel (std::string name, ENUM_OUTPUT_LEVEL *level, int dim)
 Modify all print levels associated with a channel. More...
 
bool SetPrintLevel (std::string name, ENUM_OUTPUT_LEVEL level)
 set the print level associated with a channel More...
 
int AddChannel (std::string name)
 Add a channel to the array outputChannel. More...
 
bool DeleteChannel (std::string name)
 Delete a channel from the array outputChannel. More...
 
int FindChannel (std::string name)
 Find the position of a channel within the array *outputChannel. More...
 
- 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. More...
 
OSOutputChannel ** outputChannel
 The array of output channels currently in use. More...
 

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::OSOutput ( const OSOutput )
private
OSOutput::OSOutput ( )

Constructor.

Definition at line 161 of file OSOutput.cpp.

OSOutput::~OSOutput ( )

Destructor.

Definition at line 169 of file OSOutput.cpp.

Member Function Documentation

OSOutput& OSOutput::operator= ( const OSOutput )
private
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
level,:the print level associated with the string
area,:the area of the code in which the output was generated
outStr,:the string to be output
Returns
whether the output operation was successful

Definition at line 178 of file OSOutput.cpp.

void OSOutput::FlushAllBuffers ( )

Flush all buffers.

Definition at line 188 of file OSOutput.cpp.

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

Modify all print levels associated with a channel.

Parameters
name,:The name of the channel ("stdout" and "stderr" are reserved names)
level,:The array of print levels used for the output to this channel
dim,:The number of entries in this array
Returns
whether the operation was successful

Definition at line 194 of file OSOutput.cpp.

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

set the print level associated with a channel

Parameters
name,:The name of the channel ("stdout" and "stderr" are reserved names)
level,:The 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.

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

Add a channel to the array outputChannel.

Parameters
name,:The 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.

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

Delete a channel from the array outputChannel.

Parameters
name,:The name of the channel
Returns
whether the operation was completed successfully

Definition at line 280 of file OSOutput.cpp.

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

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

Parameters
name,:The name of the channel
Returns
the position if found; -1 otherwise

Definition at line 312 of file OSOutput.cpp.

Member Data Documentation

int OSOutput::nOfOutputs
private

The number of output channels that have been defined.

Definition at line 223 of file OSOutput.h.

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: