Scippy

UG

Ubiquity Generator framework

scipParaObjMessageHdlr.cpp
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and software framework */
4/* UG --- Ubquity Generator Framework */
5/* */
6/* Copyright Written by Yuji Shinano <shinano@zib.de>, */
7/* Copyright (C) 2021-2024 by Zuse Institute Berlin, */
8/* licensed under LGPL version 3 or later. */
9/* Commercial licenses are available through <licenses@zib.de> */
10/* */
11/* This code is free software; you can redistribute it and/or */
12/* modify it under the terms of the GNU Lesser General Public License */
13/* as published by the Free Software Foundation; either version 3 */
14/* of the License, or (at your option) any later version. */
15/* */
16/* This program is distributed in the hope that it will be useful, */
17/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
19/* GNU Lesser General Public License for more details. */
20/* */
21/* You should have received a copy of the GNU Lesser General Public License */
22/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
23/* */
24/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25
26/**@file scipParaObjMessageHdlr.cpp
27 * @brief SCIP message handler for ParaSCIP and FiberSCIP.
28 * @author Yuji Shinano
29 *
30 *
31 *
32 */
33
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35
36#include <cassert>
37#include <iostream>
38
40
41using namespace ParaSCIP;
42
43
44/** constructor */
45ScipParaObjMessageHdlr::ScipParaObjMessageHdlr(
46 UG::ParaComm *inComm,
47 FILE* inFile,
48 SCIP_Bool inQuiet,
49 SCIP_Bool inBufferedoutput /* should the output be buffered up to the next newline? */
50 ) : ObjMessagehdlr(inBufferedoutput)
51{
52 comm = inComm; // for debugging
53 logfile = inFile;
54 quiet = inQuiet;
55}
56
58 )
59{
60}
61
62
64 FILE* file, /**< file stream to print message into */
65 const char* msg /**< message to print */
66 )
67{
68 if( file == NULL )
69 file = stdout;
70 if( !quiet || (file != stdout && file != stderr) )
71 {
72 fputs(msg, file);
73 fflush(file);
74 }
75 if( logfile != NULL && (file == stdout || file == stderr) )
76 {
77 fputs(msg, logfile);
78 fflush(logfile);
79 }
80}
81
82/** error message print method of message handler
83*
84* This method is invoked, if SCIP wants to display an error message to the screen or a file
85*/
87 SCIP_MESSAGEHDLR* messagehdlr, /**< the message handler itself */
88 FILE* file, /**< file stream to print into */
89 const char* msg /**< string to output into the file */
90 )
91{
92 logMessage(file, msg);
93}
94
95/** warning message print method of message handler
96 *
97 * This method is invoked, if SCIP wants to display a warning message to the screen or a file
98 */
100 SCIP_MESSAGEHDLR* messagehdlr, /**< the message handler itself */
101 FILE* file, /**< file stream to print into */
102 const char* msg /**< string to output into the file */
103 )
104{
105 // logMessage(mymessagehdlrdata, file, msg);
106 logMessage(file, msg);
107}
108
109/** dialog message print method of message handler
110 *
111 * This method is invoked, if SCIP wants to display a dialog message to the screen or a file
112 */
114 SCIP_MESSAGEHDLR* messagehdlr, /**< the message handler itself */
115 FILE* file, /**< file stream to print into */
116 const char* msg /**< string to output into the file */
117 )
118{
119 logMessage(file, msg);
120}
121
122/** info message print method of message handler
123 *
124 * This method is invoked, if SCIP wants to display an information message to the screen or a file
125 */
127 SCIP_MESSAGEHDLR* messagehdlr, /**< the message handler itself */
128 FILE* file, /**< file stream to print into */
129 const char* msg /**< string to output into the file */
130 )
131{
132 logMessage(file, msg);
133}
134
135extern "C" {
136/** error message function as used by SCIP */
137SCIP_DECL_ERRORPRINTING(scip_errorfunction)
138{
139 assert( data != 0 );
140 ScipParaObjMessageHdlr* objmessagehdlr = (ScipParaObjMessageHdlr*) data;
141
142 objmessagehdlr->scip_error(0, objmessagehdlr->getlogfile(), msg);
143}
144}
virtual void scip_warning(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *msg)
void logMessage(FILE *file, const char *msg)
virtual void scip_error(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *msg)
virtual void scip_info(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *msg)
virtual void scip_dialog(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *msg)
Base class of communicator object.
Definition: paraComm.h:102
SCIP_DECL_ERRORPRINTING(scip_errorfunction)
SCIP message handler for ParaSCIP and FiberSCIP.