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-2015 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file exceptions.h
17  * @brief Exception classes for SoPlex.
18  */
19 #ifndef _EXCEPTIONS_H_
20 #define _EXCEPTIONS_H_
21 
22 #include <string.h>
23 
24 namespace soplex
25 {
26  /**@brief Exception base class.
27  * @ingroup Elementary
28  *
29  * This class implements a base class for our SoPlex exceptions
30  * We provide a what() function which returns the exception message.
31  */
33  {
34  private:
35  //----------------------------------------
36  /**@name Private data */
37  //@{
38  /// Exception message.
39  std::string msg;
40  //@}
41  public:
42  //----------------------------------------
43  /**@name Construction / destruction */
44  //@{
45  /// constructor
46  /** The constructor receives an optional string as an exception message.
47  */
48  SPxException(const std::string& m = "") : msg(m) {}
49  /// destructor
50  virtual ~SPxException() {}
51  //@}
52 
53  //----------------------------------------
54  /**@name Access / modification */
55  //@{
56  /// returns exception message
57  virtual const std::string what() const
58  {
59  return msg;
60  }
61  //@}
62  };
63 
64  /**@brief Exception class for out of memory exceptions.
65  * @ingroup Elementary
66  *
67  * This class is derived from the SoPlex exception base class.
68  * It does not provide any new functionality.
69  */
71  {
72  public:
73  //----------------------------------------
74  /**@name Construction / destruction */
75  //@{
76  /// constructor
77  /** The constructor receives an optional string as an exception message.
78  */
79  SPxMemoryException(const std::string& m = "") : SPxException(m) {}
80  //@}
81  };
82 
83  /**@brief Exception class for status exceptions during the computations
84  * @ingroup Elementary
85  *
86  * This class is derived from the SoPlex exception base class.
87  * It does not provide any new functionality.
88  */
90  {
91  public:
92  //----------------------------------------
93  /**@name Construction / destruction */
94  //@{
95  /// constructor
96  /** The constructor receives an optional string as an exception message.
97  */
98  SPxStatusException(const std::string& m = "") : SPxException(m) {}
99  //@}
100  };
101 
102  /**@brief Exception class for things that should NEVER happen.
103  * @ingroup Elementary
104  *
105  * This class is derived from the SoPlex exception base class.
106  * It does not provide any new functionality. Most often it is used to replace
107  * assert(false) terms in earlier code.
108  */
110  {
111  public:
112  //----------------------------------------
113  /**@name Construction / destruction */
114  //@{
115  /// constructor
116  /** The constructor receives an optional string as an exception message.
117  */
118  SPxInternalCodeException(const std::string& m = "") : SPxException(m) {}
119  //@}
120  };
121 
122 
123  /**@brief Exception class for incorrect usage of interface methods.
124  * @ingroup Elementary
125  */
127  {
128  public:
129  //----------------------------------------
130  /**@name Construction / destruction */
131  //@{
132  /// constructor
133  /** The constructor receives an optional string as an exception message.
134  */
135  SPxInterfaceException(const std::string& m = "") : SPxException(m) {}
136  //@}
137  };
138 
139 } //namespace soplex
140 
141 #endif // _EXCEPTIONS_H_