My Project
OSOutput.h
Go to the documentation of this file.
1/* $Id: OSOutput.h 3172 2012-11-12 04:59:24Z Gassmann $ */
15#ifndef OSOUTPUT_H
16#define OSOUTPUT_H
17
18#include "OSConfig.h"
19#include "OSParameters.h"
20#include "OSReferenced.hpp"
21#include "OSSmartPtr.hpp"
22
23#include <string>
24#include <vector>
25
26#ifdef HAVE_CSTDIO
27# include <cstdio>
28#else
29# ifdef HAVE_STDIO_H
30# include <stdio.h>
31# else
32# error "don't have header file for stdio"
33# endif
34#endif
35
36
42{
43private:
47 std::string name;
48
52 FILE* file;
53
58
59
60public:
66 OSOutputChannel(std::string name);
67
72
76 std::string Name();
77
85
91
97 bool setAllPrintLevels(ENUM_OUTPUT_LEVEL* level, int dim);
98
103
114 void OSPrintf(ENUM_OUTPUT_AREA area, ENUM_OUTPUT_LEVEL level, std::string str);
115
119 void flushBuffer();
120
125 bool Open();
126};
127
147{
148private:
151public:
155 OSOutput();
156
160 ~OSOutput();
161
171 bool OSPrint(ENUM_OUTPUT_AREA area, ENUM_OUTPUT_LEVEL level, std::string outStr);
172
176 void FlushAllBuffers();
177
184 bool SetPrintLevel(std::string name, ENUM_OUTPUT_LEVEL* level, int dim);
185
193 bool SetPrintLevel(std::string name, ENUM_OUTPUT_LEVEL level);
194
203 int AddChannel(std::string name);
204
205
210 bool DeleteChannel(std::string name);
211
217 int FindChannel(std::string name);
218
219private:
224
229};
230
231
232// osoutput takes care of all output (see ticket 14)
233// It is declared here as a global variable
234// so as to minimize the changes to the API
235
236extern const OSSmartPtr<OSOutput> osoutput;
237
238#endif
const OSSmartPtr< OSOutput > osoutput
Definition OSOutput.cpp:39
a class that holds information about one output channel (file, device, stream, peripheral,...
Definition OSOutput.h:42
bool setAllPrintLevels(ENUM_OUTPUT_LEVEL level)
Set the print level for all areas.
Definition OSOutput.cpp:74
~OSOutputChannel()
Destructor.
Definition OSOutput.cpp:55
int printLevel[ENUM_OUTPUT_AREA_NUMBER_OF_AREAS]
vector of integers indicating the level for each area
Definition OSOutput.h:57
std::string name
used to give a name to the file or device
Definition OSOutput.h:47
void flushBuffer()
Flush output buffer.
Definition OSOutput.cpp:131
FILE * file
holds a pointer to the file or device
Definition OSOutput.h:52
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....
Definition OSOutput.cpp:114
std::string Name()
Get the name of the output channel.
Definition OSOutput.cpp:59
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.,...
Definition OSOutput.cpp:109
bool setPrintLevel(ENUM_OUTPUT_AREA area, ENUM_OUTPUT_LEVEL level)
Set the print level for a particular area.
Definition OSOutput.cpp:64
OSOutputChannel(std::string name)
Constructor.
Definition OSOutput.cpp:42
This class handles all the output from OSSolverService, OSAmplClient and other executables derived fr...
Definition OSOutput.h:147
OSOutput(const OSOutput &)
~OSOutput()
Destructor.
Definition OSOutput.cpp:169
int nOfOutputs
The number of output channels that have been defined.
Definition OSOutput.h:223
int FindChannel(std::string name)
Find the position of a channel within the array *outputChannel.
Definition OSOutput.cpp:312
int AddChannel(std::string name)
Add a channel to the array outputChannel.
Definition OSOutput.cpp:233
OSOutputChannel ** outputChannel
The array of output channels currently in use.
Definition OSOutput.h:228
bool DeleteChannel(std::string name)
Delete a channel from the array outputChannel.
Definition OSOutput.cpp:280
OSOutput()
Constructor.
Definition OSOutput.cpp:161
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 ...
Definition OSOutput.cpp:178
void FlushAllBuffers()
Flush all buffers.
Definition OSOutput.cpp:188
bool SetPrintLevel(std::string name, ENUM_OUTPUT_LEVEL *level, int dim)
Modify all print levels associated with a channel.
Definition OSOutput.cpp:194
OSOutput & operator=(const OSOutput &)
ReferencedObject class.
Template class for Smart Pointers.
ENUM_OUTPUT_LEVEL
Enumeration for the different verbosity levels that can be used in producing output.
ENUM_OUTPUT_AREA
Enumeration for the different areas that can produce output.
@ ENUM_OUTPUT_AREA_NUMBER_OF_AREAS