OS  2.10.2
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 {
43 private:
47  std::string name;
48 
52  FILE* file;
53 
57  int printLevel[ENUM_OUTPUT_AREA_NUMBER_OF_AREAS];
58 
59 
60 public:
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 {
148 private:
149  OSOutput(const OSOutput&);
150  OSOutput& operator =(const OSOutput&);
151 public:
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 
219 private:
223  int nOfOutputs;
224 
228  OSOutputChannel** outputChannel;
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 
236 extern const OSSmartPtr<OSOutput> osoutput;
237 
238 #endif
bool DeleteChannel(std::string name)
Delete a channel from the array outputChannel.
void FlushAllBuffers()
Flush all buffers.
~OSOutput()
Destructor.
int AddChannel(std::string name)
Add a channel to the array outputChannel.
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....
ReferencedObject class.
bool SetPrintLevel(std::string name, ENUM_OUTPUT_LEVEL *level, int dim)
Modify all print levels associated with a channel.
This class handles all the output from OSSolverService, OSAmplClient and other executables derived fr...
Definition: OSOutput.h:146
bool setPrintLevel(ENUM_OUTPUT_AREA area, ENUM_OUTPUT_LEVEL level)
Set the print level for a particular area.
const OSSmartPtr< OSOutput > osoutput
bool setAllPrintLevels(ENUM_OUTPUT_LEVEL level)
Set the print level for all areas.
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 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 ...
~OSOutputChannel()
Destructor.
a class that holds information about one output channel (file, device, stream, peripheral,...
Definition: OSOutput.h:41
void flushBuffer()
Flush output buffer.
std::string Name()
Get the name of the output channel.
Template class for Smart Pointers.
Definition: OSSmartPtr.hpp:156
int FindChannel(std::string name)
Find the position of a channel within the array *outputChannel.
ENUM_OUTPUT_LEVEL
Enumeration for the different verbosity levels that can be used in producing output.
Definition: OSParameters.h:107
OSOutput()
Constructor.
OSOutputChannel(std::string name)
Constructor.
ENUM_OUTPUT_AREA
Enumeration for the different areas that can produce output.
Definition: OSParameters.h:128