Simpact Cyan
Population based event driven simulation using mNRM
errorbase.h
Go to the documentation of this file.
1 /*
2 
3  This file is a part of ErrUt, a small collection of error handling
4  utilities.
5 
6  Copyright (c) 2008-2012 Jori Liesenborgs
7 
8  Contact: jori.liesenborgs@gmail.com
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26  IN THE SOFTWARE.
27 
28 */
29 
34 #ifndef ERRUT_ERRORBASE_H
35 
36 #define ERRUT_ERRORBASE_H
37 
38 #include <string>
39 
40 namespace errut
41 {
42 
43 #define ERRUT_IMPORTEXPORT
44 
49 class ERRUT_IMPORTEXPORT ErrorBase
50 {
51 public:
53  ErrorBase() { m_objectName = std::string("Unnamed object"); }
54 
56  ErrorBase(const std::string &objName) { m_objectName = objName; }
57 
58  virtual ~ErrorBase() { }
59 
61  std::string getObjectName() const { return m_objectName; }
62 
64  std::string getErrorString() const { return m_errorString; }
65 protected:
67  void setErrorString(const std::string &str) const { m_errorString = str; }
68 private:
69  mutable std::string m_errorString;
70  std::string m_objectName;
71 };
72 
73 } // end namespace
74 
75 #endif // ERRUT_ERRORBASE_H
76 
Base class which allows an error message to be set.
Definition: errorbase.h:49
ErrorBase(const std::string &objName)
Creates an instance with the object name set to objName.
Definition: errorbase.h:56
ErrorBase()
Creates an instance without an explicit object name.
Definition: errorbase.h:53
std::string getObjectName() const
Returns the stored object name.
Definition: errorbase.h:61
void setErrorString(const std::string &str) const
Derived classes can use this member function to store an error message.
Definition: errorbase.h:67
std::string getErrorString() const
Returns the currently stored error message.
Definition: errorbase.h:64