Scippy

SoPlex

Sequential object-oriented simPlex

exceptions.h
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the class library */
4/* SoPlex --- the Sequential object-oriented simPlex. */
5/* */
6/* Copyright (c) 1996-2025 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 SoPlex; see the file LICENSE. If not email to soplex@zib.de. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file exceptions.h
26 * @brief Exception classes for SoPlex.
27 */
28#ifndef _EXCEPTIONS_H_
29#define _EXCEPTIONS_H_
30
31#include <string.h>
32
33namespace soplex
34{
35/**@brief Exception base class.
36 * @ingroup Elementary
37 *
38 * This class implements a base class for our SoPlex exceptions
39 * We provide a what() function which returns the exception message.
40 */
42{
43private:
44 //----------------------------------------
45 /**@name Private data */
46 ///@{
47 /// Exception message.
48 std::string msg;
49 ///@}
50public:
51 //----------------------------------------
52 /**@name Construction / destruction */
53 ///@{
54 /// constructor
55 /** The constructor receives an optional string as an exception message.
56 */
57 SPxException(const std::string& m = "") : msg(m) {}
58 SPxException(const SPxException&) = default;
60 /// destructor
61 virtual ~SPxException() = default;
62 ///@}
63
64 //----------------------------------------
65 /**@name Access / modification */
66 ///@{
67 /// returns exception message
68 virtual const std::string& what() const
69 {
70 return msg;
71 }
72 ///@}
73};
74
75/**@brief Exception class for out of memory exceptions.
76 * @ingroup Elementary
77 *
78 * This class is derived from the SoPlex exception base class.
79 * It does not provide any new functionality.
80 */
82{
83public:
84 //----------------------------------------
85 /**@name Construction / destruction */
86 ///@{
87 /// constructor
88 /** The constructor receives an optional string as an exception message.
89 */
90 SPxMemoryException(const std::string& m = "") : SPxException(m) {}
91 ///@}
92};
93
94/**@brief Exception class for status exceptions during the computations
95 * @ingroup Elementary
96 *
97 * This class is derived from the SoPlex exception base class.
98 * It does not provide any new functionality.
99 */
101{
102public:
103 //----------------------------------------
104 /**@name Construction / destruction */
105 ///@{
106 /// constructor
107 /** The constructor receives an optional string as an exception message.
108 */
109 SPxStatusException(const std::string& m = "") : SPxException(m) {}
110 ///@}
111};
112
113/**@brief Exception class for things that should NEVER happen.
114 * @ingroup Elementary
115 *
116 * This class is derived from the SoPlex exception base class.
117 * It does not provide any new functionality. Most often it is used to replace
118 * assert(false) terms in earlier code.
119 */
121{
122public:
123 //----------------------------------------
124 /**@name Construction / destruction */
125 ///@{
126 /// constructor
127 /** The constructor receives an optional string as an exception message.
128 */
129 SPxInternalCodeException(const std::string& m = "") : SPxException(m) {}
130 ///@}
131};
132
133
134/**@brief Exception class for incorrect usage of interface methods.
135 * @ingroup Elementary
136 */
138{
139public:
140 //----------------------------------------
141 /**@name Construction / destruction */
142 ///@{
143 /// constructor
144 /** The constructor receives an optional string as an exception message.
145 */
146 SPxInterfaceException(const std::string& m = "") : SPxException(m) {}
147 ///@}
148};
149
150} //namespace soplex
151
152#endif // _EXCEPTIONS_H_
Exception base class.
Definition: exceptions.h:42
std::string msg
Exception message.
Definition: exceptions.h:48
virtual ~SPxException()=default
destructor
SPxException(const std::string &m="")
constructor
Definition: exceptions.h:57
SPxException(SPxException &&)=default
virtual const std::string & what() const
returns exception message
Definition: exceptions.h:68
SPxException(const SPxException &)=default
Exception class for incorrect usage of interface methods.
Definition: exceptions.h:138
SPxInterfaceException(const std::string &m="")
constructor
Definition: exceptions.h:146
Exception class for things that should NEVER happen.
Definition: exceptions.h:121
SPxInternalCodeException(const std::string &m="")
constructor
Definition: exceptions.h:129
Exception class for out of memory exceptions.
Definition: exceptions.h:82
SPxMemoryException(const std::string &m="")
constructor
Definition: exceptions.h:90
Exception class for status exceptions during the computations.
Definition: exceptions.h:101
SPxStatusException(const std::string &m="")
constructor
Definition: exceptions.h:109
Everything should be within this namespace.