FRIBParallelanalysis  1.0
FrameworkforMPIParalleldataanalysisatFRIB
ErrnoException.h
1 /*
2  This software is Copyright by the Board of Trustees of Michigan
3  State University (c) Copyright 2005.
4 
5  You may use this software under the terms of the GNU public license
6  (GPL). The terms of this license are described at:
7 
8  http://www.gnu.org/licenses/gpl.txt
9 
10  Author:
11  Ron Fox
12  NSCL
13  Michigan State University
14  East Lansing, MI 48824-1321
15 */
16 
17 
18 
19 // CErrnoException.h:
20 //
21 // This file defines the CErrnoException class.
22 //
23 // Author:
24 // Ron Fox
25 // NSCL
26 // Michigan State University
27 // East Lansing, MI 48824-1321
28 // mailto:fox@nscl.msu.edu
29 //
30 // Copyright 1999 NSCL, All Rights Reserved.
31 //
33 
34 #ifndef ERRNOEXCEPTION_H //Required for current class
35 #define ERRNOEXCEPTION_H
36  //Required for base classes
37 #ifndef EXCEPTION_H
38 #include "Exception.h"
39 #endif
40 
41 #include <errno.h>
42 #include <string>
43 
44 
45 class CErrnoException : public CException
46 {
47  int m_nErrno; // // Snapshot of errno at construction time.
48 
49 public:
50 
51  //Constructor with arguments
52 
53  CErrnoException(const char* pszAction) :
54  m_nErrno(errno),
55  CException(pszAction) {}
56  CErrnoException(const std::string& rsAction) :
57  m_nErrno(errno),
58  CException(rsAction) {}
59  ~CErrnoException ( ) { } //Destructor
60 
61  // Copy Constructor:
62 
63  CErrnoException (const CErrnoException& aCErrnoException ) :
64  CException (aCErrnoException)
65  {
66  m_nErrno = aCErrnoException.m_nErrno;
67  }
68  //Operator= Assignment Operator
69 
70  CErrnoException& operator= (const CErrnoException& aCErrnoException)
71  {
72  if (this == &aCErrnoException) return *this;
73  CException::operator= (aCErrnoException);
74  m_nErrno = aCErrnoException.m_nErrno;
75  return *this;
76  }
77 
78  //Operator== Equality Operator
79 
80  int operator== (const CErrnoException& aCErrnoException) const
81  {
82  return ((CException::operator== (aCErrnoException)) &&
83  (m_nErrno == aCErrnoException.m_nErrno)
84  );
85  }
86  int operator!=(const CErrnoException& aCErrnoException) const {
87  return !(this->operator==(aCErrnoException));
88  }
89 
90 
91  // Selectors: Note typically these are not needed.
92 
93 public:
94  int getErrno() const
95  {
96  return m_nErrno;
97  }
98  // Mutating selectors: For derived classes only.
99 protected:
100  void setErrno(int am_nErrno)
101  {
102  m_nErrno = am_nErrno;
103  }
104 
105  // Functions of the class:
106 public:
107 
108  virtual const char* ReasonText () const ;
109  virtual int ReasonCode () const ;
110 
111 };
112 
113 #endif
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
Definition: ErrnoException.h:45
Definition: Exception.h:41