FRIBParallelanalysis  1.0
FrameworkforMPIParalleldataanalysisatFRIB
RangeError.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 // CRangeError.h:
18 //
19 // This file defines the CRangeError class.
20 //
21 // Author:
22 // Ron Fox
23 // NSCL
24 // Michigan State University
25 // East Lansing, MI 48824-1321
26 // mailto:fox@nscl.msu.edu
27 //
28 // Copyright 1999 NSCL, All Rights Reserved.
29 //
31 
32 /********************** WARNING - this file is obsolete, include
33  CrangeError.h from now on
34 */
35 
36 
37 #ifndef CRANGEERROR_H //Required for current class
38 #define CRANGEERROR_H
39  //Required for base classes
40 #ifndef EXCEPTION_H
41 #include "Exception.h"
42 #endif
43 
44 #include <string>
45 
46 class CRangeError : public CException
47 {
48  int m_nLow; // Lowest allowed value for range (inclusive).
49  int m_nHigh; // Highest allowed value for range.
50  int m_nRequested; // Actual requested value which is outside
51  // of the range.
52  std::string m_ReasonText; // Reason text will be built up here.
53 public:
54  // The type below is intended to allow the client to categorize the
55  // exception:
56 
57  enum {
58  knTooLow, // CRangeError::knTooLow - below m_nLow
59  knTooHigh // CRangeError::knTooHigh - above m_nHigh
60  };
61  //Constructors with arguments
62 
63  CRangeError ( int nLow, int nHigh, int nRequested,
64  const char* pDoing) :
65  CException(pDoing),
66  m_nLow (nLow),
67  m_nHigh (nHigh),
68  m_nRequested (nRequested)
69  { UpdateReason(); }
70  CRangeError(int nLow, int nHigh, int nRequested,
71  const std::string& rDoing) :
72  CException(rDoing),
73  m_nLow(nLow),
74  m_nHigh(nHigh),
75  m_nRequested(nRequested)
76  { UpdateReason(); }
77  virtual ~ CRangeError ( ) { } //Destructor
78 
79  //Copy constructor
80 
81  CRangeError (const CRangeError& aCRangeError ) :
82  CException (aCRangeError)
83  {
84  m_nLow = aCRangeError.m_nLow;
85  m_nHigh = aCRangeError.m_nHigh;
86  m_nRequested = aCRangeError.m_nRequested;
87  UpdateReason();
88  }
89 
90  //Operator= Assignment Operator
91 
92  CRangeError operator= (const CRangeError& aCRangeError)
93  {
94  if (this != &aCRangeError) {
95  CException::operator= (aCRangeError);
96  m_nLow = aCRangeError.m_nLow;
97  m_nHigh = aCRangeError.m_nHigh;
98  m_nRequested = aCRangeError.m_nRequested;
99  UpdateReason();
100  }
101 
102  return *this;
103  }
104 
105  //Operator== Equality Operator
106 
107  int operator== (const CRangeError& aCRangeError) const
108  {
109  return (
110  (CException::operator== (aCRangeError)) &&
111  (m_nLow == aCRangeError.m_nLow) &&
112  (m_nHigh == aCRangeError.m_nHigh) &&
113  (m_nRequested == aCRangeError.m_nRequested)
114  );
115  }
116  int operator!= (const CRangeError& aCRangeError) const
117  {
118  return !(this->operator==(aCRangeError));
119  }
120 
121  // Selectors - Don't use these unless you're a derived class
122  // or you need some special exception type specific
123  // data. Generic handling should be based on the interface
124  // for CException.
125 public:
126 
127  int getLow() const
128  {
129  return m_nLow;
130  }
131  int getHigh() const
132  {
133  return m_nHigh;
134  }
135  int getRequested() const
136  {
137  return m_nRequested;
138  }
139  // Mutators - These can only be used by derived classes:
140 
141 protected:
142  void setLow (int am_nLow)
143  {
144  m_nLow = am_nLow;
145  UpdateReason();
146  }
147  void setHigh (int am_nHigh)
148  {
149  m_nHigh = am_nHigh;
150  UpdateReason();
151  }
152  void setRequested (int am_nRequested)
153  {
154  m_nRequested = am_nRequested;
155  UpdateReason();
156  }
157  //
158  // Interfaces implemented from the CException class.
159  //
160 public:
161  virtual const char* ReasonText () const ;
162  virtual int ReasonCode () const ;
163 
164  // Protected utilities:
165  //
166 protected:
167  void UpdateReason();
168 };
169 
170 #endif
Definition: Exception.h:41
Definition: RangeError.h:46