Scippy

SCIP

Solving Constraint Integer Programs

pub_message.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2015 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file pub_message.h
17  * @ingroup PUBLICMETHODS
18  * @brief public methods for message output
19  * @author Tobias Achterberg
20  * @author Stefan Heinz
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #ifndef __SCIP_PUB_MESSAGE_H__
26 #define __SCIP_PUB_MESSAGE_H__
27 
28 #include <stdarg.h>
29 
30 #include "scip/def.h"
31 #include "scip/type_message.h"
32 
33 #ifdef NDEBUG
34 #include "scip/struct_message.h"
35 #endif
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /** define to identify SCIP version with thread-safe version of message handlers */
42 #define SCIP_THREADSAFE_MESSAGEHDLRS
43 
44 /** prints an error message */
45 #define SCIPerrorMessage SCIPmessagePrintErrorHeader(__FILE__, __LINE__); \
46  SCIPmessagePrintError
47 
48 /** define used in blockmemshell/memory.c */
49 #define printErrorHeader SCIPmessagePrintErrorHeader
50 #define printError SCIPmessagePrintError
51 
52 #ifdef SCIP_DEBUG
53 
54 /** executes command only if SCIP_DEBUG flag is set */
55 #define SCIPdebug(x) x
56 
57 /** prints a debugging message if SCIP_DEBUG flag is set */
58 #define SCIPdebugMessage printf("[%s:%d] debug: ", __FILE__, __LINE__), printf
59 
60 /** executes printf command only if SCIP_DEBUG flag is set */
61 #define SCIPdebugPrintf printf
62 
63 /** executes SCIPprintCons() and prints termination symbol ";\n" only if SCIP_DEBUG flag is set */
64 #define SCIPdebugPrintCons(scip,cons,file) do \
65  { \
66  SCIP_CALL_ABORT( SCIPprintCons((scip), (cons), (file)) ); \
67  SCIPinfoMessage((scip), (file), ";\n"); \
68  } \
69  while( FALSE )
70 
71 #else
72 
73 /** executes command only if SCIP_DEBUG flag is set */
74 #define SCIPdebug(x) /**/
75 
76 /** prints a debugging message if SCIP_DEBUG flag is set */
77 #define SCIPdebugMessage while( FALSE ) printf
78 
79 /** executes printf command only if SCIP_DEBUG flag is set */
80 #define SCIPdebugPrintf while( FALSE ) printf
81 
82 /** executes SCIPprintCons() and prints termination symbol ";\n" only if SCIP_DEBUG flag is set */
83 #define SCIPdebugPrintCons(x,y,z) /**/
84 
85 #endif
86 
87 #ifdef SCIP_STATISTIC
88 
89 /** executes command only if SCIP_STATISTIC flag is set */
90 #define SCIPstatistic(x) x
91 
92 /** prints a statistic message if SCIP_STATISTIC flag is set */
93 #define SCIPstatisticMessage printf("[%s:%d] statistic: ", __FILE__, __LINE__), printf
94 
95 /** executes printf command only if SCIP_STATISTIC flag is set */
96 #define SCIPstatisticPrintf printf
97 
98 #else
99 
100 /** executes command only if SCIP_STATISTIC flag is set */
101 #define SCIPstatistic(x) /**/
102 
103 /** prints a statistic message if SCIP_STATISTIC flag is set */
104 #define SCIPstatisticMessage while( FALSE ) printf
105 
106 /** executes printf command only if SCIP_STATISTIC flag is set */
107 #define SCIPstatisticPrintf while( FALSE ) printf
108 
109 #endif
110 
111 
112 /** Creates and captures a message handler which deals with warning, information, and dialog (interactive shell) methods.
113  *
114  * @note The message handler does not handle error messages. For that see SCIPmessageSetErrorPrinting()
115  * @note Creating a message handler automatically captures it.
116  */
117 extern
119  SCIP_MESSAGEHDLR** messagehdlr, /**< pointer to store the message handler */
120  SCIP_Bool bufferedoutput, /**< should the output be buffered up to the next newline? */
121  const char* filename, /**< name of log file, or NULL for no log */
122  SCIP_Bool quiet, /**< should screen messages be suppressed? */
123  SCIP_DECL_MESSAGEWARNING((*messagewarning)),/**< warning message print method of message handler */
124  SCIP_DECL_MESSAGEDIALOG((*messagedialog)),/**< dialog message print method of message handler */
125  SCIP_DECL_MESSAGEINFO ((*messageinfo)), /**< info message print method of message handler */
126  SCIP_DECL_MESSAGEHDLRFREE((*messagehdlrfree)), /**< destructor of message handler to free message handler data */
127  SCIP_MESSAGEHDLRDATA* messagehdlrdata /**< message handler data */
128  );
129 
130 /** captures message handler */
131 extern
133  SCIP_MESSAGEHDLR* messagehdlr /**< message handler, or NULL */
134  );
135 
136 /** releases message handler */
137 extern
139  SCIP_MESSAGEHDLR** messagehdlr /**< pointer to the message handler */
140  );
141 
142 /** sets the user data of the message handler */
143 extern
145  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler; must not be NULL */
146  SCIP_MESSAGEHDLRDATA* messagehdlrdata /**< new message handler data to attach to the handler */
147  );
148 
149 /** sets the log file name for the message handler */
150 extern
152  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
153  const char* filename /**< log file name where to copy messages into, or NULL */
154  );
155 
156 /** sets the messages handler to be quiet */
157 extern
159  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
160  SCIP_Bool quiet /**< should screen messages be suppressed? */
161  );
162 
163 /** prints a message, acting like the printf() command */
164 extern
166  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
167  const char* formatstr, /**< format string like in printf() function */
168  ... /**< format arguments line in printf() function */
169  );
170 
171 /** prints a message, acting like the vprintf() command */
172 extern
174  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
175  const char* formatstr, /**< format string like in printf() function */
176  va_list ap /**< variable argument list */
177  );
178 
179 /** prints a message into a file, acting like the fprintf() command */
180 extern
182  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
183  FILE* file, /**< file stream to print into, or NULL for stdout */
184  const char* formatstr, /**< format string like in printf() function */
185  ... /**< format arguments line in printf() function */
186  );
187 
188 /** prints a message into a file, acting like the vfprintf() command */
189 extern
191  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
192  FILE* file, /**< file stream to print into, or NULL for stdout */
193  const char* formatstr, /**< format string like in printf() function */
194  va_list ap /**< variable argument list */
195  );
196 
197 /** prints a warning message, acting like the printf() command */
198 extern
200  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
201  const char* formatstr, /**< format string like in printf() function */
202  ... /**< format arguments line in printf() function */
203  );
204 
205 /** prints a warning message, acting like the vprintf() command */
206 extern
208  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
209  const char* formatstr, /**< format string like in printf() function */
210  va_list ap /**< variable argument list */
211  );
212 
213 /** prints a warning message into a file, acting like the fprintf() command */
214 extern
216  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
217  const char* formatstr, /**< format string like in printf() function */
218  ... /**< format arguments line in printf() function */
219  );
220 
221 /** prints a warning message into a file, acting like the vfprintf() command */
222 extern
224  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
225  const char* formatstr, /**< format string like in printf() function */
226  va_list ap /**< variable argument list */
227  );
228 
229 /** prints a dialog message that requests user interaction, acting like the printf() command */
230 extern
232  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
233  const char* formatstr, /**< format string like in printf() function */
234  ... /**< format arguments line in printf() function */
235  );
236 
237 /** prints a dialog message that requests user interaction, acting like the vprintf() command */
238 extern
240  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
241  const char* formatstr, /**< format string like in printf() function */
242  va_list ap /**< variable argument list */
243  );
244 
245 /** prints a dialog message that requests user interaction into a file, acting like the fprintf() command */
246 extern
248  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
249  FILE* file, /**< file stream to print into, or NULL for stdout */
250  const char* formatstr, /**< format string like in printf() function */
251  ... /**< format arguments line in printf() function */
252  );
253 
254 /** prints a dialog message that requests user interaction into a file, acting like the vfprintf() command */
255 extern
257  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
258  FILE* file, /**< file stream to print into, or NULL for stdout */
259  const char* formatstr, /**< format string like in printf() function */
260  va_list ap /**< variable argument list */
261  );
262 
263 /** prints a message depending on the verbosity level, acting like the printf() command */
264 extern
266  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
267  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
268  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
269  const char* formatstr, /**< format string like in printf() function */
270  ... /**< format arguments line in printf() function */
271  );
272 
273 /** prints a message depending on the verbosity level, acting like the vprintf() command */
274 extern
276  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
277  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
278  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
279  const char* formatstr, /**< format string like in printf() function */
280  va_list ap /**< variable argument list */
281  );
282 
283 /** prints a message into a file depending on the verbosity level, acting like the fprintf() command */
284 extern
286  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
287  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
288  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
289  FILE* file, /**< file stream to print into, or NULL for stdout */
290  const char* formatstr, /**< format string like in printf() function */
291  ... /**< format arguments line in printf() function */
292  );
293 
294 /** prints a message into a file depending on the verbosity level, acting like the vfprintf() command */
295 extern
297  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
298  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
299  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
300  FILE* file, /**< file stream to print into, or NULL for stdout */
301  const char* formatstr, /**< format string like in printf() function */
302  va_list ap /**< variable argument list */
303  );
304 
305 /** prints the header with source file location for an error message using the static message handler */
306 extern
308  const char* sourcefile, /**< name of the source file that called the function */
309  int sourceline /**< line in the source file where the function was called */
310  );
311 
312 /** prints an error message, acting like the printf() command using the static message handler */
313 extern
315  const char* formatstr, /**< format string like in printf() function */
316  ... /**< format arguments line in printf() function */
317  );
318 
319 /** prints an error message, acting like the vprintf() command using the static message handler */
320 extern
322  const char* formatstr, /**< format string like in printf() function */
323  va_list ap /**< variable argument list */
324  );
325 
326 /** Method to set the error printing method. Setting the error printing method to NULL will suspend all error methods.
327  *
328  * @note The error printing method is a static variable. This means that all occurring errors are handled via this method.
329  */
330 extern
332  SCIP_DECL_ERRORPRINTING((*errorPrinting)),/**< error message print method of message handler, or NULL */
333  void* data /**< data pointer which will be passed to the error printing method, or NULL */
334  );
335 
336 /** Method to set the error printing method to default version prints everything the stderr.
337  *
338  * @note The error printing method is a static variable. This means that all occurring errors are handled via this method.
339  */
340 extern
342  void
343  );
344 
345 
346 /** returns the user data of the message handler */
347 extern
349  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
350  );
351 
352 /** returns the log file or NULL for stdout */
353 extern
355  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
356  );
357 
358 /** returns TRUE if the message handler is set to be quiet */
359 extern
361  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
362  );
363 
364 #ifdef NDEBUG
365 
366 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
367  * speed up the algorithms.
368  */
369 
370 #define SCIPmessagehdlrGetData(messagehdlr) ((messagehdlr) != NULL) ? messagehdlr->messagehdlrdata : NULL
371 #define SCIPmessagehdlrGetLogfile(messagehdlr) ((messagehdlr) == NULL ? NULL : (messagehdlr)->logfile)
372 #define SCIPmessagehdlrIsQuiet(messagehdlr) ((messagehdlr) == NULL || (messagehdlr)->quiet)
373 
374 #endif
375 
376 #ifdef __cplusplus
377 }
378 #endif
379 
380 #endif
void SCIPmessageVPrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
struct SCIP_MessagehdlrData SCIP_MESSAGEHDLRDATA
Definition: type_message.h:51
SCIP_Bool SCIPmessagehdlrIsQuiet(SCIP_MESSAGEHDLR *messagehdlr)
void SCIPmessagePrintDialog(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
void SCIPmessageFPrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
#define SCIP_DECL_MESSAGEWARNING(x)
Definition: type_message.h:81
void SCIPmessageVFPrintDialog(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr, va_list ap)
void SCIPmessagePrintErrorHeader(const char *sourcefile, int sourceline)
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
struct SCIP_Messagehdlr SCIP_MESSAGEHDLR
Definition: type_message.h:50
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
enum SCIP_VerbLevel SCIP_VERBLEVEL
Definition: type_message.h:48
void SCIPmessagehdlrSetLogfile(SCIP_MESSAGEHDLR *messagehdlr, const char *filename)
void SCIPmessageVFPrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
FILE * SCIPmessagehdlrGetLogfile(SCIP_MESSAGEHDLR *messagehdlr)
SCIP_RETCODE SCIPmessagehdlrSetData(SCIP_MESSAGEHDLR *messagehdlr, SCIP_MESSAGEHDLRDATA *messagehdlrdata)
void SCIPmessageFPrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
SCIP_RETCODE SCIPmessagehdlrRelease(SCIP_MESSAGEHDLR **messagehdlr)
void SCIPmessageVPrintDialog(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
void SCIPmessageFPrintDialog(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
void SCIPmessageVFPrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr, va_list ap)
void SCIPmessageSetErrorPrinting(SCIP_DECL_ERRORPRINTING((*errorPrinting)), void *data)
#define SCIP_Bool
Definition: def.h:50
void SCIPmessageVPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
#define SCIP_DECL_ERRORPRINTING(x)
Definition: type_message.h:70
#define SCIP_DECL_MESSAGEHDLRFREE(x)
Definition: type_message.h:112
void SCIPmessageVPrintError(const char *formatstr, va_list ap)
SCIP_RETCODE SCIPmessagehdlrCreate(SCIP_MESSAGEHDLR **messagehdlr, SCIP_Bool bufferedoutput, const char *filename, SCIP_Bool quiet, SCIP_DECL_MESSAGEWARNING((*messagewarning)), SCIP_DECL_MESSAGEDIALOG((*messagedialog)), SCIP_DECL_MESSAGEINFO((*messageinfo)), SCIP_DECL_MESSAGEHDLRFREE((*messagehdlrfree)), SCIP_MESSAGEHDLRDATA *messagehdlrdata)
void SCIPmessagehdlrCapture(SCIP_MESSAGEHDLR *messagehdlr)
void SCIPmessagePrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
#define SCIP_DECL_MESSAGEDIALOG(x)
Definition: type_message.h:92
void SCIPmessageVPrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, const char *formatstr, va_list ap)
void SCIPmessagePrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, const char *formatstr,...)
void SCIPmessagehdlrSetQuiet(SCIP_MESSAGEHDLR *messagehdlr, SCIP_Bool quiet)
void SCIPmessagePrintError(const char *formatstr,...)
SCIP_MESSAGEHDLRDATA * SCIPmessagehdlrGetData(SCIP_MESSAGEHDLR *messagehdlr)
void SCIPmessageVFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr, va_list ap)
type definitions for message output methods
void SCIPmessageSetErrorPrintingDefault(void)
common defines and data types used in all packages of SCIP
#define SCIP_DECL_MESSAGEINFO(x)
Definition: type_message.h:103