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-2021 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 visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file pub_message.h
17  * @ingroup PUBLICCOREAPI
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 #include <string.h>
30 
31 #include "scip/def.h"
32 #include "scip/type_message.h"
33 
34 #ifdef NDEBUG
35 #include "scip/struct_message.h"
36 #endif
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /** define to identify SCIP version with thread-safe version of message handlers */
43 #define SCIP_THREADSAFE_MESSAGEHDLRS
44 
45 /** define to get the filename of __FILE__ */
46 #if defined(_WIN32) || defined(_WIN64)
47 /*lint -e613*/
48 #define __FILENAME__ (strrchr("\\" __FILE__, '\\') + 1)
49 #else
50 /*lint -e613*/
51 #define __FILENAME__ (strrchr("/" __FILE__, '/') + 1)
52 #endif
53 
54 /** prints an error message */
55 #define SCIPerrorMessage SCIPmessagePrintErrorHeader(__FILENAME__, __LINE__); \
56  SCIPmessagePrintError
57 
58 /** define used in blockmemshell/memory.c */
59 #define printErrorHeader SCIPmessagePrintErrorHeader
60 #define printError SCIPmessagePrintError
61 
62 #ifdef SCIP_DEBUG
63 
64 /** executes command only if SCIP_DEBUG flag is set */
65 #define SCIPdebug(x) x
66 
67 /** prints a debugging message if SCIP_DEBUG flag is set - also consider using SCIPdebugMsg/SCIPsetDebugMsg */
68 #define SCIPdebugMessage printf("[%s:%d] debug: ", __FILENAME__, __LINE__), printf
69 
70 /** executes printf command only if SCIP_DEBUG flag is set */
71 #define SCIPdebugPrintf printf
72 
73 /** executes SCIPprintCons() and prints termination symbol ";\n" only if SCIP_DEBUG flag is set */
74 #define SCIPdebugPrintCons(scip,cons,file) do \
75  { \
76  SCIP_CALL_ABORT( SCIPprintCons((scip), (cons), (file)) ); \
77  SCIPinfoMessage((scip), (file), ";\n"); \
78  } \
79  while( FALSE )
80 
81 #else
82 
83 /** executes command only if SCIP_DEBUG flag is set */
84 #define SCIPdebug(x) /**/
85 
86 /** prints a debugging message if SCIP_DEBUG flag is set - also consider using SCIPdebugMsg/SCIPsetDebugMsg */
87 #define SCIPdebugMessage while( FALSE ) /*lint -e{530}*/ printf
88 
89 /** executes printf command only if SCIP_DEBUG flag is set */
90 #define SCIPdebugPrintf while( FALSE ) /*lint -e{530}*/ printf
91 
92 /** executes SCIPprintCons() and prints termination symbol ";\n" only if SCIP_DEBUG flag is set */
93 #define SCIPdebugPrintCons(x,y,z) /**/
94 
95 #endif
96 
97 #ifdef SCIP_STATISTIC
98 
99 /** executes command only if SCIP_STATISTIC flag is set */
100 #define SCIPstatistic(x) x
101 
102 /** prints a statistic message if SCIP_STATISTIC flag is set */
103 #define SCIPstatisticMessage printf("[%s:%d] statistic: ", __FILENAME__, __LINE__), printf
104 
105 /** executes printf command only if SCIP_STATISTIC flag is set */
106 #define SCIPstatisticPrintf printf
107 
108 #else
109 
110 /** executes command only if SCIP_STATISTIC flag is set */
111 #define SCIPstatistic(x) /**/
112 
113 /** prints a statistic message if SCIP_STATISTIC flag is set */
114 #define SCIPstatisticMessage while( FALSE ) /*lint -e{530}*/ printf
115 
116 /** executes printf command only if SCIP_STATISTIC flag is set */
117 #define SCIPstatisticPrintf while( FALSE ) /*lint -e{530}*/ printf
118 
119 #endif
120 
121 
122 /** Creates and captures a message handler which deals with warning, information, and dialog (interactive shell) methods.
123  *
124  * Use SCIPsetMessagehdlr() to make SCIP aware of the created message handler.
125  * @note The message handler does not handle error messages. For that see SCIPmessageSetErrorPrinting()
126  * @note Creating a message handler automatically captures it.
127  */
130  SCIP_MESSAGEHDLR** messagehdlr, /**< pointer to store the message handler */
131  SCIP_Bool bufferedoutput, /**< should the output be buffered up to the next newline? */
132  const char* filename, /**< name of log file, or NULL for no log */
133  SCIP_Bool quiet, /**< should screen messages be suppressed? */
134  SCIP_DECL_MESSAGEWARNING((*messagewarning)),/**< warning message print method of message handler */
135  SCIP_DECL_MESSAGEDIALOG((*messagedialog)),/**< dialog message print method of message handler */
136  SCIP_DECL_MESSAGEINFO ((*messageinfo)), /**< info message print method of message handler */
137  SCIP_DECL_MESSAGEHDLRFREE((*messagehdlrfree)), /**< destructor of message handler to free message handler data */
138  SCIP_MESSAGEHDLRDATA* messagehdlrdata /**< message handler data */
139  );
140 
141 /** captures message handler */
144  SCIP_MESSAGEHDLR* messagehdlr /**< message handler, or NULL */
145  );
146 
147 /** releases message handler */
150  SCIP_MESSAGEHDLR** messagehdlr /**< pointer to the message handler */
151  );
152 
153 /** sets the user data of the message handler */
156  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler; must not be NULL */
157  SCIP_MESSAGEHDLRDATA* messagehdlrdata /**< new message handler data to attach to the handler */
158  );
159 
160 /** sets the log file name for the message handler */
163  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
164  const char* filename /**< log file name where to copy messages into, or NULL */
165  );
166 
167 /** sets the messages handler to be quiet */
170  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
171  SCIP_Bool quiet /**< should screen messages be suppressed? */
172  );
173 
174 /** prints a message, acting like the printf() command */
175 #ifdef __GNUC__
176 __attribute__((format(printf, 2, 3)))
177 #endif
180  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
181  const char* formatstr, /**< format string like in printf() function */
182  ... /**< format arguments line in printf() function */
183  );
184 
185 /** prints a message, acting like the vprintf() command */
188  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
189  const char* formatstr, /**< format string like in printf() function */
190  va_list ap /**< variable argument list */
191  );
192 
193 /** prints a message into a file, acting like the fprintf() command */
194 #ifdef __GNUC__
195 __attribute__((format(printf, 3, 4)))
196 #endif
199  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
200  FILE* file, /**< file stream to print into, or NULL for stdout */
201  const char* formatstr, /**< format string like in printf() function */
202  ... /**< format arguments line in printf() function */
203  );
204 
205 /** prints a message into a file, acting like the vfprintf() command */
208  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
209  FILE* file, /**< file stream to print into, or NULL for stdout */
210  const char* formatstr, /**< format string like in printf() function */
211  va_list ap /**< variable argument list */
212  );
213 
214 /** prints a warning message, acting like the printf() command */
215 #ifdef __GNUC__
216 __attribute__((format(printf, 2, 3)))
217 #endif
220  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
221  const char* formatstr, /**< format string like in printf() function */
222  ... /**< format arguments line in printf() function */
223  );
224 
225 /** prints a warning message, acting like the vprintf() command */
228  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
229  const char* formatstr, /**< format string like in printf() function */
230  va_list ap /**< variable argument list */
231  );
232 
233 /** prints a warning message into a file, acting like the fprintf() command */
234 #ifdef __GNUC__
235 __attribute__((format(printf, 2, 3)))
236 #endif
239  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
240  const char* formatstr, /**< format string like in printf() function */
241  ... /**< format arguments line in printf() function */
242  );
243 
244 /** prints a warning message into a file, acting like the vfprintf() command */
247  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
248  const char* formatstr, /**< format string like in printf() function */
249  va_list ap /**< variable argument list */
250  );
251 
252 /** prints a dialog message that requests user interaction, acting like the printf() command */
253 #ifdef __GNUC__
254 __attribute__((format(printf, 2, 3)))
255 #endif
258  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
259  const char* formatstr, /**< format string like in printf() function */
260  ... /**< format arguments line in printf() function */
261  );
262 
263 /** prints a dialog message that requests user interaction, acting like the vprintf() command */
266  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
267  const char* formatstr, /**< format string like in printf() function */
268  va_list ap /**< variable argument list */
269  );
270 
271 /** prints a dialog message that requests user interaction into a file, acting like the fprintf() command */
272 #ifdef __GNUC__
273 __attribute__((format(printf, 3, 4)))
274 #endif
277  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
278  FILE* file, /**< file stream to print into, or NULL for stdout */
279  const char* formatstr, /**< format string like in printf() function */
280  ... /**< format arguments line in printf() function */
281  );
282 
283 /** prints a dialog message that requests user interaction into a file, acting like the vfprintf() command */
286  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
287  FILE* file, /**< file stream to print into, or NULL for stdout */
288  const char* formatstr, /**< format string like in printf() function */
289  va_list ap /**< variable argument list */
290  );
291 
292 /** prints a message depending on the verbosity level, acting like the printf() command */
293 #ifdef __GNUC__
294 __attribute__((format(printf, 4, 5)))
295 #endif
298  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
299  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
300  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
301  const char* formatstr, /**< format string like in printf() function */
302  ... /**< format arguments line in printf() function */
303  );
304 
305 /** prints a message depending on the verbosity level, acting like the vprintf() command */
308  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
309  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
310  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
311  const char* formatstr, /**< format string like in printf() function */
312  va_list ap /**< variable argument list */
313  );
314 
315 /** prints a message into a file depending on the verbosity level, acting like the fprintf() command */
316 #ifdef __GNUC__
317 __attribute__((format(printf, 5, 6)))
318 #endif
321  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
322  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
323  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
324  FILE* file, /**< file stream to print into, or NULL for stdout */
325  const char* formatstr, /**< format string like in printf() function */
326  ... /**< format arguments line in printf() function */
327  );
328 
329 /** prints a message into a file depending on the verbosity level, acting like the vfprintf() command */
332  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
333  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
334  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
335  FILE* file, /**< file stream to print into, or NULL for stdout */
336  const char* formatstr, /**< format string like in printf() function */
337  va_list ap /**< variable argument list */
338  );
339 
340 /** prints the header with source file location for an error message using the static message handler */
343  const char* sourcefile, /**< name of the source file that called the function */
344  int sourceline /**< line in the source file where the function was called */
345  );
346 
347 /** prints an error message, acting like the printf() command using the static message handler */
348 #ifdef __GNUC__
349 __attribute__((format(printf, 1, 2)))
350 #endif
353  const char* formatstr, /**< format string like in printf() function */
354  ... /**< format arguments line in printf() function */
355  );
356 
357 /** prints an error message, acting like the vprintf() command using the static message handler */
360  const char* formatstr, /**< format string like in printf() function */
361  va_list ap /**< variable argument list */
362  );
363 
364 /** Method to set the error printing method. Setting the error printing method to NULL will suspend all error methods.
365  *
366  * @note The error printing method is a static variable. This means that all occurring errors are handled via this method.
367  */
370  SCIP_DECL_ERRORPRINTING((*errorPrinting)),/**< error message print method of message handler, or NULL */
371  void* data /**< data pointer which will be passed to the error printing method, or NULL */
372  );
373 
374 /** Method to set the error printing method to default version prints everything the stderr.
375  *
376  * @note The error printing method is a static variable. This means that all occurring errors are handled via this method.
377  */
380  void
381  );
382 
383 
384 /** returns the user data of the message handler */
387  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
388  );
389 
390 /** returns the log file or NULL for stdout */
393  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
394  );
395 
396 /** returns TRUE if the message handler is set to be quiet */
399  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
400  );
401 
402 #ifdef NDEBUG
403 
404 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
405  * speed up the algorithms.
406  */
407 
408 #define SCIPmessagehdlrGetData(messagehdlr) ((messagehdlr) != NULL) ? messagehdlr->messagehdlrdata : NULL
409 #define SCIPmessagehdlrGetLogfile(messagehdlr) ((messagehdlr) == NULL ? NULL : (messagehdlr)->logfile)
410 #define SCIPmessagehdlrIsQuiet(messagehdlr) ((messagehdlr) == NULL || (messagehdlr)->quiet)
411 
412 #endif
413 
414 #ifdef __cplusplus
415 }
416 #endif
417 
418 #endif
SCIP_EXPORT void SCIPmessageVFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr, va_list ap)
Definition: message.c:624
struct SCIP_MessagehdlrData SCIP_MESSAGEHDLRDATA
Definition: type_message.h:51
SCIP_EXPORT void SCIPmessagePrintError(const char *formatstr,...)
Definition: message.c:782
SCIP_EXPORT void SCIPmessagePrintErrorHeader(const char *sourcefile, int sourceline)
Definition: message.c:768
#define SCIP_DECL_MESSAGEWARNING(x)
Definition: type_message.h:82
SCIP_EXPORT void SCIPmessageFPrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:442
SCIP_EXPORT void SCIPmessageVPrintDialog(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
Definition: message.c:515
#define SCIP_EXPORT
Definition: def.h:100
datastructures for problem statistics
SCIP_EXPORT void SCIPmessageFPrintDialog(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:525
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_EXPORT void SCIPmessageVFPrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
Definition: message.c:456
SCIP_EXPORT void SCIPmessageSetErrorPrinting(SCIP_DECL_ERRORPRINTING((*errorPrinting)), void *data)
Definition: message.c:842
enum SCIP_VerbLevel SCIP_VERBLEVEL
Definition: type_message.h:48
SCIP_EXPORT SCIP_RETCODE SCIPmessagehdlrRelease(SCIP_MESSAGEHDLR **messagehdlr)
Definition: message.c:339
SCIP_EXPORT void SCIPmessageSetErrorPrintingDefault(void)
Definition: message.c:855
SCIP_EXPORT void SCIPmessagehdlrSetQuiet(SCIP_MESSAGEHDLR *messagehdlr, SCIP_Bool quiet)
Definition: message.c:402
SCIP_EXPORT void SCIPmessageVPrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
Definition: message.c:432
SCIP_EXPORT void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:609
SCIP_EXPORT SCIP_RETCODE SCIPmessagehdlrSetData(SCIP_MESSAGEHDLR *messagehdlr, SCIP_MESSAGEHDLRDATA *messagehdlrdata)
Definition: message.c:368
SCIP_EXPORT void SCIPmessageVPrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, const char *formatstr, va_list ap)
Definition: message.c:685
SCIP_EXPORT void SCIPmessagehdlrSetLogfile(SCIP_MESSAGEHDLR *messagehdlr, const char *filename)
Definition: message.c:384
#define SCIP_Bool
Definition: def.h:70
#define SCIP_DECL_ERRORPRINTING(x)
Definition: type_message.h:71
SCIP_EXPORT void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:418
SCIP_EXPORT void SCIPmessageVFPrintDialog(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr, va_list ap)
Definition: message.c:540
SCIP_EXPORT SCIP_Bool SCIPmessagehdlrIsQuiet(SCIP_MESSAGEHDLR *messagehdlr)
Definition: message.c:901
#define SCIP_DECL_MESSAGEHDLRFREE(x)
Definition: type_message.h:113
SCIP_EXPORT SCIP_MESSAGEHDLRDATA * SCIPmessagehdlrGetData(SCIP_MESSAGEHDLR *messagehdlr)
Definition: message.c:878
SCIP_EXPORT void SCIPmessageFPrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: message.c:697
SCIP_EXPORT void SCIPmessagehdlrCapture(SCIP_MESSAGEHDLR *messagehdlr)
Definition: message.c:330
#define SCIP_DECL_MESSAGEDIALOG(x)
Definition: type_message.h:93
SCIP_EXPORT void SCIPmessagePrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:585
SCIP_EXPORT void SCIPmessageVFPrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr, va_list ap)
Definition: message.c:714
type definitions for message output methods
SCIP_EXPORT void SCIPmessagePrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, const char *formatstr,...)
Definition: message.c:669
SCIP_EXPORT FILE * SCIPmessagehdlrGetLogfile(SCIP_MESSAGEHDLR *messagehdlr)
Definition: message.c:890
common defines and data types used in all packages of SCIP
SCIP_EXPORT 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)
Definition: message.c:286
SCIP_EXPORT void SCIPmessagePrintDialog(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:501
#define SCIP_DECL_MESSAGEINFO(x)
Definition: type_message.h:104
SCIP_EXPORT void SCIPmessageVPrintError(const char *formatstr, va_list ap)
Definition: message.c:795
SCIP_EXPORT void SCIPmessageVPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
Definition: message.c:599