1    	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2    	/*                                                                           */
3    	/*                  This file is part of the class library                   */
4    	/*       SoPlex --- the Sequential object-oriented simPlex.                  */
5    	/*                                                                           */
6    	/*  Copyright (c) 1996-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 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   	
33   	namespace 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   	 */
41   	class SPxException
42   	{
43   	private:
44   	   //----------------------------------------
45   	   /**@name Private data */
46   	   ///@{
47   	   /// Exception message.
48   	   std::string msg;
49   	   ///@}
50   	public:
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   	   /// destructor
59   	   virtual ~SPxException() {}
60   	   ///@}
61   	
62   	   //----------------------------------------
63   	   /**@name Access / modification */
64   	   ///@{
65   	   /// returns exception message
66   	   virtual const std::string what() const
67   	   {
68   	      return msg;
69   	   }
70   	   ///@}
71   	};
72   	
73   	/**@brief   Exception class for out of memory exceptions.
74   	 * @ingroup Elementary
75   	 *
76   	 * This class is derived from the SoPlex exception base class.
77   	 * It does not provide any new functionality.
78   	 */
79   	class SPxMemoryException : public SPxException
80   	{
81   	public:
82   	   //----------------------------------------
83   	   /**@name Construction / destruction */
84   	   ///@{
85   	   /// constructor
86   	   /** The constructor receives an optional string as an exception message.
87   	    */
88   	   SPxMemoryException(const std::string& m = "") : SPxException(m) {}
89   	   ///@}
90   	};
91   	
92   	/**@brief   Exception class for status exceptions during the computations
93   	 * @ingroup Elementary
94   	 *
95   	 * This class is derived from the SoPlex exception base class.
96   	 * It does not provide any new functionality.
97   	 */
98   	class SPxStatusException : public SPxException
99   	{
100  	public:
101  	   //----------------------------------------
102  	   /**@name Construction / destruction */
103  	   ///@{
104  	   /// constructor
105  	   /** The constructor receives an optional string as an exception message.
106  	    */
107  	   SPxStatusException(const std::string& m = "") : SPxException(m) {}
108  	   ///@}
109  	};
110  	
111  	/**@brief   Exception class for things that should NEVER happen.
112  	 * @ingroup Elementary
113  	 *
114  	 * This class is derived from the SoPlex exception base class.
115  	 * It does not provide any new functionality. Most often it is used to replace
116  	 * assert(false) terms in earlier code.
117  	 */
118  	class SPxInternalCodeException : public SPxException
119  	{
120  	public:
121  	   //----------------------------------------
122  	   /**@name Construction / destruction */
123  	   ///@{
124  	   /// constructor
125  	   /** The constructor receives an optional string as an exception message.
126  	    */
127  	   SPxInternalCodeException(const std::string& m = "") : SPxException(m) {}
128  	   ///@}
129  	};
130  	
131  	
132  	/**@brief   Exception class for incorrect usage of interface methods.
133  	 * @ingroup Elementary
134  	 */
135  	class SPxInterfaceException : public SPxException
136  	{
137  	public:
138  	   //----------------------------------------
139  	   /**@name Construction / destruction */
140  	   ///@{
141  	   /// constructor
142  	   /** The constructor receives an optional string as an exception message.
143  	    */
144  	   SPxInterfaceException(const std::string& m = "") : SPxException(m) {}
145  	   ///@}
146  	};
147  	
148  	} //namespace soplex
149  	
150  	#endif // _EXCEPTIONS_H_
151