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 
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:
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 
236 extern const OSSmartPtr<OSOutput> osoutput;
237 
238 #endif
OSOutputChannel(std::string name)
Constructor.
Definition: OSOutput.cpp:42
const OSSmartPtr< OSOutput > osoutput
Definition: OSOutput.cpp:39
bool setAllPrintLevels(ENUM_OUTPUT_LEVEL level)
Set the print level for all areas.
Definition: OSOutput.cpp:74
int AddChannel(std::string name)
Add a channel to the array outputChannel.
Definition: OSOutput.cpp:233
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
int printLevel[ENUM_OUTPUT_AREA_NUMBER_OF_AREAS]
vector of integers indicating the level for each area
Definition: OSOutput.h:57
OSOutput()
Constructor.
Definition: OSOutput.cpp:161
void flushBuffer()
Flush output buffer.
Definition: OSOutput.cpp:131
Template class for Smart Pointers.
Definition: OSSmartPtr.hpp:156
This class handles all the output from OSSolverService, OSAmplClient and other executables derived fr...
Definition: OSOutput.h:146
a class that holds information about one output channel (file, device, stream, peripheral, etc.)
Definition: OSOutput.h:41
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 &quot;accepts&quot; the output (i...
Definition: OSOutput.cpp:114
ReferencedObject class.
~OSOutputChannel()
Destructor.
Definition: OSOutput.cpp:55
ENUM_OUTPUT_LEVEL
Enumeration for the different verbosity levels that can be used in producing output.
Definition: OSParameters.h:107
bool DeleteChannel(std::string name)
Delete a channel from the array outputChannel.
Definition: OSOutput.cpp:280
OSOutput & operator=(const OSOutput &)
FILE * file
holds a pointer to the file or device
Definition: OSOutput.h:52
OSOutputChannel ** outputChannel
The array of output channels currently in use.
Definition: OSOutput.h:228
void FlushAllBuffers()
Flush all buffers.
Definition: OSOutput.cpp:188
ENUM_OUTPUT_AREA
Enumeration for the different areas that can produce output.
Definition: OSParameters.h:128
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., if the output should be printed)
Definition: OSOutput.cpp:109
std::string Name()
Get the name of the output channel.
Definition: OSOutput.cpp:59
int FindChannel(std::string name)
Find the position of a channel within the array *outputChannel.
Definition: OSOutput.cpp:312
~OSOutput()
Destructor.
Definition: OSOutput.cpp:169
bool setPrintLevel(ENUM_OUTPUT_AREA area, ENUM_OUTPUT_LEVEL level)
Set the print level for a particular area.
Definition: OSOutput.cpp:64
bool SetPrintLevel(std::string name, ENUM_OUTPUT_LEVEL *level, int dim)
Modify all print levels associated with a channel.
Definition: OSOutput.cpp:194
int nOfOutputs
The number of output channels that have been defined.
Definition: OSOutput.h:223
std::string name
used to give a name to the file or device
Definition: OSOutput.h:47