32# error "don't have header file for stdio"
47 if (this->name !=
"stderr" && this->name !=
"stdout")
49 this->
file = fopen (this->name.c_str(),
"w+" );
50 std::string temp = (
"Could not open file " + this->
name);
68 throw ErrorClass(
"Encountered print level not supported in production code.\n Recompile with debug enabled.");
78 throw ErrorClass(
"Encountered print level not supported in production code.\n Recompile with debug enabled.");
94 throw ErrorClass(
"Array of output levels must have nonnegative size.");
96 for (
int i=0; i < n; i++)
100 throw ErrorClass(
"Encountered print level not supported in production code.\n Recompile with debug enabled.");
118 if (this->
name ==
"stderr")
119 fprintf(stderr,
"%s\n", str.c_str());
120 else if (this->
name ==
"stdout")
121 printf(
"%s\n", str.c_str());
123 if (this->
file != NULL)
124 fprintf(
file,
"%s\n", str.c_str());
142 if (
name ==
"stdout")
147 if (
name ==
"stderr")
163 std::string temp =
"stdout";
198 throw ErrorClass(
"Device was not defined before");
199 for (
int i=1; i<dim; i++)
202 throw ErrorClass(
"printLevel must be nonnegative");
204 throw ErrorClass(
"illegal printLevel specified");
214 throw ErrorClass(
"Device was not defined before");
216 throw ErrorClass(
"printLevel must be nonnegative");
219 throw ErrorClass(
"illegal printLevel specified");
224 aLevel = level % 100;
227 throw ErrorClass(
"illegal printLevel specified");
237 if (name ==
"stdout")
258 for (i = 0; i < ndev; i++)
298 for (i = 0; i < k; i++)
300 for (i = k+1; i < ndev; i++)
const OSSmartPtr< OSOutput > osoutput
used for throwing exceptions.
a class that holds information about one output channel (file, device, stream, peripheral,...
bool setAllPrintLevels(ENUM_OUTPUT_LEVEL level)
Set the print level for all areas.
~OSOutputChannel()
Destructor.
int printLevel[ENUM_OUTPUT_AREA_NUMBER_OF_AREAS]
vector of integers indicating the level for each area
std::string name
used to give a name to the file or device
void flushBuffer()
Flush output buffer.
FILE * file
holds a pointer to the file or device
void OSPrintf(ENUM_OUTPUT_AREA area, ENUM_OUTPUT_LEVEL level, std::string str)
Send one string to the output device provided that the output device "accepts" the output (i....
std::string Name()
Get the name of the output channel.
bool isAccepted(ENUM_OUTPUT_AREA area, ENUM_OUTPUT_LEVEL level)
Test if the device accepts a particular combination of print level and area (i.e.,...
bool setPrintLevel(ENUM_OUTPUT_AREA area, ENUM_OUTPUT_LEVEL level)
Set the print level for a particular area.
OSOutputChannel(std::string name)
Constructor.
This class handles all the output from OSSolverService, OSAmplClient and other executables derived fr...
int nOfOutputs
The number of output channels that have been defined.
int FindChannel(std::string name)
Find the position of a channel within the array *outputChannel.
int AddChannel(std::string name)
Add a channel to the array outputChannel.
OSOutputChannel ** outputChannel
The array of output channels currently in use.
bool DeleteChannel(std::string name)
Delete a channel from the array outputChannel.
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 ...
void FlushAllBuffers()
Flush all buffers.
bool SetPrintLevel(std::string name, ENUM_OUTPUT_LEVEL *level, int dim)
Modify all print levels associated with a channel.
Template class for Smart Pointers.
#define DEFAULT_OUTPUT_LEVEL
ENUM_OUTPUT_LEVEL
Enumeration for the different verbosity levels that can be used in producing output.
@ ENUM_OUTPUT_LEVEL_debug
@ ENUM_OUTPUT_LEVEL_error
@ ENUM_OUTPUT_LEVEL_NUMBER_OF_LEVELS
ENUM_OUTPUT_AREA
Enumeration for the different areas that can produce output.
@ ENUM_OUTPUT_AREA_NUMBER_OF_AREAS