Scippy

SCIP

Solving Constraint Integer Programs

objmessagehdlr.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-2023 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file objmessagehdlr.h
26  * @brief C++ wrapper for message handlers
27  * @author Tobias Achterberg
28  */
29 
30 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
31 
32 #ifndef __SCIP_OBJMESSAGEHDLR_H__
33 #define __SCIP_OBJMESSAGEHDLR_H__
34 
35 #include "scip/scip.h"
36 
37 namespace scip
38 {
39 
40 /**
41  * @brief C++ wrapper for message handlers
42  *
43  * This class defines the interface for message handlers implemented in C++. Note that all functions are pure virtual
44  * (these functions have to be implemented).
45  *
46  * - \ref type_message.h "Corresponding C interface"
47  */
49 {
50 public:
51  /** should the output be buffered up to the next newline? */
53 
54  /** default constructor */
55  explicit ObjMessagehdlr(
56  SCIP_Bool bufferedoutput /**< should the output be buffered up to the next newline? */
57  )
58  : scip_bufferedoutput_(bufferedoutput)
59  {
60  }
61 
62  /** destructor */
63  virtual ~ObjMessagehdlr()
64  {
65  }
66 
67  /** assignment of polymorphic classes causes slicing and is therefore disabled. */
68  ObjMessagehdlr& operator=(const ObjMessagehdlr& o) = delete;
69 
70  /** assignment of polymorphic classes causes slicing and is therefore disabled. */
72 
73  /** error message print method of message handler
74  *
75  * @note This function can be activated by calling SCIPsetStaticErrorPrintingMessagehdlr().
76  *
77  * @see SCIP_DECL_ERRORPRINTING(x) in @ref type_message.h
78  */ /*lint -e715*/
79  virtual void scip_error(
80  SCIP_MESSAGEHDLR* messagehdlr, /**< the message handler itself */
81  FILE* file, /**< file stream to print into (NULL for stderr) */
82  const char* msg /**< string to output into the file (or NULL to flush) */
83  )
84  { /*lint --e{715}*/
85 
86  }
87 
88  /** warning message print method of message handler
89  *
90  * @see SCIP_DECL_MESSAGEWARNING(x) in @ref type_message.h
91  */ /*lint -e715*/
92  virtual SCIP_DECL_MESSAGEWARNING(scip_warning)
93  { /*lint --e{715}*/
94 
95  }
96 
97  /** dialog message print method of message handler
98  *
99  * @see SCIP_DECL_MESSAGEDIALOG(x) in @ref type_message.h
100  */ /*lint -e715*/
101  virtual SCIP_DECL_MESSAGEDIALOG(scip_dialog)
102  { /*lint --e{715}*/
103 
104  }
105 
106  /** info message print method of message handler
107  *
108  * @see SCIP_DECL_MESSAGEINFO(x) in @ref type_message.h
109  */ /*lint -e715*/
110  virtual SCIP_DECL_MESSAGEINFO(scip_info)
111  { /*lint --e{715}*/
112 
113  }
114 
115  /** destructor of message handler to free message handler data
116  *
117  * @see SCIP_DECL_MESSAGEHDLRFREE(x) in @ref type_message.h
118  */ /*lint -e715*/
119  virtual SCIP_DECL_MESSAGEHDLRFREE(scip_free)
120  { /*lint --e{715}*/
121  return SCIP_OKAY;
122  }
123 };
124 
125 } /* namespace scip */
126 
127 
128 
129 /** creates the message handler for the given message handler object */
130 SCIP_EXPORT
132  SCIP_MESSAGEHDLR** messagehdlr, /**< pointer to store the message handler */
133  scip::ObjMessagehdlr* objmessagehdlr, /**< message handler object */
134  SCIP_Bool deleteobject /**< should the message handler object be deleted when message handler is freed? */
135  );
136 
137 /** returns the message handler object for the given message handler */
138 SCIP_EXPORT
140  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
141  );
142 
143 /** set static error output function to the corresponding function of message handler */
144 SCIP_EXPORT
146  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
147  );
148 
149 #endif
virtual SCIP_DECL_MESSAGEDIALOG(scip_dialog)
ObjMessagehdlr(SCIP_Bool bufferedoutput)
ObjMessagehdlr & operator=(const ObjMessagehdlr &o)=delete
SCIP_RETCODE SCIPcreateObjMessagehdlr(SCIP_MESSAGEHDLR **messagehdlr, scip::ObjMessagehdlr *objmessagehdlr, SCIP_Bool deleteobject)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
virtual void scip_error(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *msg)
virtual SCIP_DECL_MESSAGEHDLRFREE(scip_free)
#define SCIP_Bool
Definition: def.h:93
C++ wrapper for message handlers.
virtual SCIP_DECL_MESSAGEINFO(scip_info)
void SCIPsetStaticErrorPrintingMessagehdlr(SCIP_MESSAGEHDLR *messagehdlr)
const SCIP_Bool scip_bufferedoutput_
virtual SCIP_DECL_MESSAGEWARNING(scip_warning)
scip::ObjMessagehdlr * SCIPgetObjMessagehdlr(SCIP_MESSAGEHDLR *messagehdlr)
SCIP callable library.