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-2020 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 */
177  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
178  const char* formatstr, /**< format string like in printf() function */
179  ... /**< format arguments line in printf() function */
180  );
181 
182 /** prints a message, acting like the vprintf() command */
185  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
186  const char* formatstr, /**< format string like in printf() function */
187  va_list ap /**< variable argument list */
188  );
189 
190 /** prints a message into a file, acting like the fprintf() command */
193  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
194  FILE* file, /**< file stream to print into, or NULL for stdout */
195  const char* formatstr, /**< format string like in printf() function */
196  ... /**< format arguments line in printf() function */
197  );
198 
199 /** prints a message into a file, acting like the vfprintf() command */
202  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
203  FILE* file, /**< file stream to print into, or NULL for stdout */
204  const char* formatstr, /**< format string like in printf() function */
205  va_list ap /**< variable argument list */
206  );
207 
208 /** prints a warning message, acting like the printf() command */
211  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
212  const char* formatstr, /**< format string like in printf() function */
213  ... /**< format arguments line in printf() function */
214  );
215 
216 /** prints a warning message, acting like the vprintf() command */
219  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
220  const char* formatstr, /**< format string like in printf() function */
221  va_list ap /**< variable argument list */
222  );
223 
224 /** prints a warning message into a file, acting like the fprintf() command */
227  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
228  const char* formatstr, /**< format string like in printf() function */
229  ... /**< format arguments line in printf() function */
230  );
231 
232 /** prints a warning message into a file, acting like the vfprintf() command */
235  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
236  const char* formatstr, /**< format string like in printf() function */
237  va_list ap /**< variable argument list */
238  );
239 
240 /** prints a dialog message that requests user interaction, acting like the printf() command */
243  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
244  const char* formatstr, /**< format string like in printf() function */
245  ... /**< format arguments line in printf() function */
246  );
247 
248 /** prints a dialog message that requests user interaction, acting like the vprintf() command */
251  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
252  const char* formatstr, /**< format string like in printf() function */
253  va_list ap /**< variable argument list */
254  );
255 
256 /** prints a dialog message that requests user interaction into a file, acting like the fprintf() command */
259  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
260  FILE* file, /**< file stream to print into, or NULL for stdout */
261  const char* formatstr, /**< format string like in printf() function */
262  ... /**< format arguments line in printf() function */
263  );
264 
265 /** prints a dialog message that requests user interaction into a file, acting like the vfprintf() command */
268  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
269  FILE* file, /**< file stream to print into, or NULL for stdout */
270  const char* formatstr, /**< format string like in printf() function */
271  va_list ap /**< variable argument list */
272  );
273 
274 /** prints a message depending on the verbosity level, acting like the printf() command */
277  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
278  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
279  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
280  const char* formatstr, /**< format string like in printf() function */
281  ... /**< format arguments line in printf() function */
282  );
283 
284 /** prints a message depending on the verbosity level, acting like the vprintf() command */
287  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
288  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
289  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
290  const char* formatstr, /**< format string like in printf() function */
291  va_list ap /**< variable argument list */
292  );
293 
294 /** prints a message into a file depending on the verbosity level, acting like the fprintf() command */
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  ... /**< format arguments line in printf() function */
303  );
304 
305 /** prints a message into a file depending on the verbosity level, acting like the vfprintf() command */
308  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
309  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
310  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
311  FILE* file, /**< file stream to print into, or NULL for stdout */
312  const char* formatstr, /**< format string like in printf() function */
313  va_list ap /**< variable argument list */
314  );
315 
316 /** prints the header with source file location for an error message using the static message handler */
319  const char* sourcefile, /**< name of the source file that called the function */
320  int sourceline /**< line in the source file where the function was called */
321  );
322 
323 /** prints an error message, acting like the printf() command using the static message handler */
326  const char* formatstr, /**< format string like in printf() function */
327  ... /**< format arguments line in printf() function */
328  );
329 
330 /** prints an error message, acting like the vprintf() command using the static message handler */
333  const char* formatstr, /**< format string like in printf() function */
334  va_list ap /**< variable argument list */
335  );
336 
337 /** Method to set the error printing method. Setting the error printing method to NULL will suspend all error methods.
338  *
339  * @note The error printing method is a static variable. This means that all occurring errors are handled via this method.
340  */
343  SCIP_DECL_ERRORPRINTING((*errorPrinting)),/**< error message print method of message handler, or NULL */
344  void* data /**< data pointer which will be passed to the error printing method, or NULL */
345  );
346 
347 /** Method to set the error printing method to default version prints everything the stderr.
348  *
349  * @note The error printing method is a static variable. This means that all occurring errors are handled via this method.
350  */
353  void
354  );
355 
356 
357 /** returns the user data of the message handler */
360  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
361  );
362 
363 /** returns the log file or NULL for stdout */
366  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
367  );
368 
369 /** returns TRUE if the message handler is set to be quiet */
372  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
373  );
374 
375 #ifdef NDEBUG
376 
377 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
378  * speed up the algorithms.
379  */
380 
381 #define SCIPmessagehdlrGetData(messagehdlr) ((messagehdlr) != NULL) ? messagehdlr->messagehdlrdata : NULL
382 #define SCIPmessagehdlrGetLogfile(messagehdlr) ((messagehdlr) == NULL ? NULL : (messagehdlr)->logfile)
383 #define SCIPmessagehdlrIsQuiet(messagehdlr) ((messagehdlr) == NULL || (messagehdlr)->quiet)
384 
385 #endif
386 
387 #ifdef __cplusplus
388 }
389 #endif
390 
391 #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