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-2018 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 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 
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 - also consider using SCIPdebugMsg/SCIPsetDebugMsg */
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 - also consider using SCIPdebugMsg/SCIPsetDebugMsg */
77 #define SCIPdebugMessage while( FALSE ) /*lint -e{530}*/ printf
78 
79 /** executes printf command only if SCIP_DEBUG flag is set */
80 #define SCIPdebugPrintf while( FALSE ) /*lint -e{530}*/ 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 ) /*lint -e{530}*/ printf
105 
106 /** executes printf command only if SCIP_STATISTIC flag is set */
107 #define SCIPstatisticPrintf while( FALSE ) /*lint -e{530}*/ 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  * Use SCIPsetMessagehdlr() to make SCIP aware of the created message handler.
115  * @note The message handler does not handle error messages. For that see SCIPmessageSetErrorPrinting()
116  * @note Creating a message handler automatically captures it.
117  */
118 extern
120  SCIP_MESSAGEHDLR** messagehdlr, /**< pointer to store the message handler */
121  SCIP_Bool bufferedoutput, /**< should the output be buffered up to the next newline? */
122  const char* filename, /**< name of log file, or NULL for no log */
123  SCIP_Bool quiet, /**< should screen messages be suppressed? */
124  SCIP_DECL_MESSAGEWARNING((*messagewarning)),/**< warning message print method of message handler */
125  SCIP_DECL_MESSAGEDIALOG((*messagedialog)),/**< dialog message print method of message handler */
126  SCIP_DECL_MESSAGEINFO ((*messageinfo)), /**< info message print method of message handler */
127  SCIP_DECL_MESSAGEHDLRFREE((*messagehdlrfree)), /**< destructor of message handler to free message handler data */
128  SCIP_MESSAGEHDLRDATA* messagehdlrdata /**< message handler data */
129  );
130 
131 /** captures message handler */
132 extern
134  SCIP_MESSAGEHDLR* messagehdlr /**< message handler, or NULL */
135  );
136 
137 /** releases message handler */
138 extern
140  SCIP_MESSAGEHDLR** messagehdlr /**< pointer to the message handler */
141  );
142 
143 /** sets the user data of the message handler */
144 extern
146  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler; must not be NULL */
147  SCIP_MESSAGEHDLRDATA* messagehdlrdata /**< new message handler data to attach to the handler */
148  );
149 
150 /** sets the log file name for the message handler */
151 extern
153  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
154  const char* filename /**< log file name where to copy messages into, or NULL */
155  );
156 
157 /** sets the messages handler to be quiet */
158 extern
160  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
161  SCIP_Bool quiet /**< should screen messages be suppressed? */
162  );
163 
164 /** prints a message, acting like the printf() command */
165 extern
167  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
168  const char* formatstr, /**< format string like in printf() function */
169  ... /**< format arguments line in printf() function */
170  );
171 
172 /** prints a message, acting like the vprintf() command */
173 extern
175  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
176  const char* formatstr, /**< format string like in printf() function */
177  va_list ap /**< variable argument list */
178  );
179 
180 /** prints a message into a file, acting like the fprintf() command */
181 extern
183  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
184  FILE* file, /**< file stream to print into, or NULL for stdout */
185  const char* formatstr, /**< format string like in printf() function */
186  ... /**< format arguments line in printf() function */
187  );
188 
189 /** prints a message into a file, acting like the vfprintf() command */
190 extern
192  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
193  FILE* file, /**< file stream to print into, or NULL for stdout */
194  const char* formatstr, /**< format string like in printf() function */
195  va_list ap /**< variable argument list */
196  );
197 
198 /** prints a warning message, acting like the printf() command */
199 extern
201  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
202  const char* formatstr, /**< format string like in printf() function */
203  ... /**< format arguments line in printf() function */
204  );
205 
206 /** prints a warning message, acting like the vprintf() command */
207 extern
209  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
210  const char* formatstr, /**< format string like in printf() function */
211  va_list ap /**< variable argument list */
212  );
213 
214 /** prints a warning message into a file, acting like the fprintf() command */
215 extern
217  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
218  const char* formatstr, /**< format string like in printf() function */
219  ... /**< format arguments line in printf() function */
220  );
221 
222 /** prints a warning message into a file, acting like the vfprintf() command */
223 extern
225  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
226  const char* formatstr, /**< format string like in printf() function */
227  va_list ap /**< variable argument list */
228  );
229 
230 /** prints a dialog message that requests user interaction, acting like the printf() command */
231 extern
233  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
234  const char* formatstr, /**< format string like in printf() function */
235  ... /**< format arguments line in printf() function */
236  );
237 
238 /** prints a dialog message that requests user interaction, acting like the vprintf() command */
239 extern
241  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
242  const char* formatstr, /**< format string like in printf() function */
243  va_list ap /**< variable argument list */
244  );
245 
246 /** prints a dialog message that requests user interaction into a file, acting like the fprintf() command */
247 extern
249  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
250  FILE* file, /**< file stream to print into, or NULL for stdout */
251  const char* formatstr, /**< format string like in printf() function */
252  ... /**< format arguments line in printf() function */
253  );
254 
255 /** prints a dialog message that requests user interaction into a file, acting like the vfprintf() command */
256 extern
258  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
259  FILE* file, /**< file stream to print into, or NULL for stdout */
260  const char* formatstr, /**< format string like in printf() function */
261  va_list ap /**< variable argument list */
262  );
263 
264 /** prints a message depending on the verbosity level, acting like the printf() command */
265 extern
267  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
268  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
269  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
270  const char* formatstr, /**< format string like in printf() function */
271  ... /**< format arguments line in printf() function */
272  );
273 
274 /** prints a message depending on the verbosity level, acting like the vprintf() command */
275 extern
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  va_list ap /**< variable argument list */
282  );
283 
284 /** prints a message into a file depending on the verbosity level, acting like the fprintf() command */
285 extern
287  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
288  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
289  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
290  FILE* file, /**< file stream to print into, or NULL for stdout */
291  const char* formatstr, /**< format string like in printf() function */
292  ... /**< format arguments line in printf() function */
293  );
294 
295 /** prints a message into a file depending on the verbosity level, acting like the vfprintf() command */
296 extern
298  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
299  SCIP_VERBLEVEL verblevel, /**< current verbosity level */
300  SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
301  FILE* file, /**< file stream to print into, or NULL for stdout */
302  const char* formatstr, /**< format string like in printf() function */
303  va_list ap /**< variable argument list */
304  );
305 
306 /** prints the header with source file location for an error message using the static message handler */
307 extern
309  const char* sourcefile, /**< name of the source file that called the function */
310  int sourceline /**< line in the source file where the function was called */
311  );
312 
313 /** prints an error message, acting like the printf() command using the static message handler */
314 extern
316  const char* formatstr, /**< format string like in printf() function */
317  ... /**< format arguments line in printf() function */
318  );
319 
320 /** prints an error message, acting like the vprintf() command using the static message handler */
321 extern
323  const char* formatstr, /**< format string like in printf() function */
324  va_list ap /**< variable argument list */
325  );
326 
327 /** Method to set the error printing method. Setting the error printing method to NULL will suspend all error methods.
328  *
329  * @note The error printing method is a static variable. This means that all occurring errors are handled via this method.
330  */
331 extern
333  SCIP_DECL_ERRORPRINTING((*errorPrinting)),/**< error message print method of message handler, or NULL */
334  void* data /**< data pointer which will be passed to the error printing method, or NULL */
335  );
336 
337 /** Method to set the error printing method to default version prints everything the stderr.
338  *
339  * @note The error printing method is a static variable. This means that all occurring errors are handled via this method.
340  */
341 extern
343  void
344  );
345 
346 
347 /** returns the user data of the message handler */
348 extern
350  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
351  );
352 
353 /** returns the log file or NULL for stdout */
354 extern
356  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
357  );
358 
359 /** returns TRUE if the message handler is set to be quiet */
360 extern
362  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
363  );
364 
365 #ifdef NDEBUG
366 
367 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
368  * speed up the algorithms.
369  */
370 
371 #define SCIPmessagehdlrGetData(messagehdlr) ((messagehdlr) != NULL) ? messagehdlr->messagehdlrdata : NULL
372 #define SCIPmessagehdlrGetLogfile(messagehdlr) ((messagehdlr) == NULL ? NULL : (messagehdlr)->logfile)
373 #define SCIPmessagehdlrIsQuiet(messagehdlr) ((messagehdlr) == NULL || (messagehdlr)->quiet)
374 
375 #endif
376 
377 #ifdef __cplusplus
378 }
379 #endif
380 
381 #endif
void SCIPmessageVPrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
Definition: message.c:431
struct SCIP_MessagehdlrData SCIP_MESSAGEHDLRDATA
Definition: type_message.h:51
SCIP_Bool SCIPmessagehdlrIsQuiet(SCIP_MESSAGEHDLR *messagehdlr)
Definition: message.c:900
void SCIPmessagePrintDialog(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:500
void SCIPmessageFPrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:441
#define SCIP_DECL_MESSAGEWARNING(x)
Definition: type_message.h:82
void SCIPmessageVFPrintDialog(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr, va_list ap)
Definition: message.c:539
void SCIPmessagePrintErrorHeader(const char *sourcefile, int sourceline)
Definition: message.c:767
datastructures for problem statistics
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:608
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)
Definition: message.c:383
void SCIPmessageVFPrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
Definition: message.c:455
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:417
FILE * SCIPmessagehdlrGetLogfile(SCIP_MESSAGEHDLR *messagehdlr)
Definition: message.c:889
SCIP_RETCODE SCIPmessagehdlrSetData(SCIP_MESSAGEHDLR *messagehdlr, SCIP_MESSAGEHDLRDATA *messagehdlrdata)
Definition: message.c:367
void SCIPmessageFPrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: message.c:696
SCIP_RETCODE SCIPmessagehdlrRelease(SCIP_MESSAGEHDLR **messagehdlr)
Definition: message.c:338
void SCIPmessageVPrintDialog(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
Definition: message.c:514
void SCIPmessageFPrintDialog(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:524
void SCIPmessageVFPrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr, va_list ap)
Definition: message.c:713
void SCIPmessageSetErrorPrinting(SCIP_DECL_ERRORPRINTING((*errorPrinting)), void *data)
Definition: message.c:841
#define SCIP_Bool
Definition: def.h:61
void SCIPmessageVPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr, va_list ap)
Definition: message.c:598
#define SCIP_DECL_ERRORPRINTING(x)
Definition: type_message.h:71
#define SCIP_DECL_MESSAGEHDLRFREE(x)
Definition: type_message.h:113
void SCIPmessageVPrintError(const char *formatstr, va_list ap)
Definition: message.c:794
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:285
void SCIPmessagehdlrCapture(SCIP_MESSAGEHDLR *messagehdlr)
Definition: message.c:329
void SCIPmessagePrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:584
#define SCIP_DECL_MESSAGEDIALOG(x)
Definition: type_message.h:93
void SCIPmessageVPrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, const char *formatstr, va_list ap)
Definition: message.c:684
void SCIPmessagePrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, const char *formatstr,...)
Definition: message.c:668
void SCIPmessagehdlrSetQuiet(SCIP_MESSAGEHDLR *messagehdlr, SCIP_Bool quiet)
Definition: message.c:401
void SCIPmessagePrintError(const char *formatstr,...)
Definition: message.c:781
SCIP_MESSAGEHDLRDATA * SCIPmessagehdlrGetData(SCIP_MESSAGEHDLR *messagehdlr)
Definition: message.c:877
void SCIPmessageVFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr, va_list ap)
Definition: message.c:623
type definitions for message output methods
void SCIPmessageSetErrorPrintingDefault(void)
Definition: message.c:854
common defines and data types used in all packages of SCIP
#define SCIP_DECL_MESSAGEINFO(x)
Definition: type_message.h:104