OS  2.10.2
Public Member Functions | List of all members
OSOutput Class Reference

This class handles all the output from OSSolverService, OSAmplClient and other executables derived from them. More...

#include <OSOutput.h>

+ Inheritance diagram for OSOutput:
+ Collaboration diagram for OSOutput:

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
 

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

Constructor.

◆ ~OSOutput()

OSOutput::~OSOutput ( )

Destructor.

Member Function Documentation

◆ 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

◆ FlushAllBuffers()

void OSOutput::FlushAllBuffers ( )

Flush all buffers.

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

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