FRIBParallelanalysis  1.0
FrameworkforMPIParalleldataanalysisatFRIB
CDuplicateSingleton.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 #ifndef CDUPLICATESINGLETON_H
18 #define CDUPLICATESINGLETON_H
19 
20 #ifndef EXCEPTION_H
21 #include "Exception.h"
22 #endif
23 
24 #include <string>
25 
27 {
28  std::string m_sName;
29  std::string m_sReasonText;
30  public:
31 
32  CDuplicateSingleton(const char* pDoing, const char* pName) :
33  CException(pDoing),
34  m_sName(pName)
35  { UpdateReasonText(); }
36 
37  CDuplicateSingleton(const char* pDoing, const std::string& rName) :
38  CException(pDoing),
39  m_sName(rName)
40  { UpdateReasonText(); }
41 
42  CDuplicateSingleton(const std::string& rDoing, const char* pName) :
43  CException(rDoing),
44  m_sName(pName)
45  { UpdateReasonText(); }
46 
47  CDuplicateSingleton(const std::string& rDoing, const std::string& rName) :
48  CException(rDoing),
49  m_sName(rName)
50  { UpdateReasonText(); }
51 
52  virtual ~CDuplicateSingleton() { } // Destructor
53 
54  // Copy constructor
56  (const CDuplicateSingleton& aCDuplicateSingleton ) :
57  CException (aCDuplicateSingleton)
58  {
59  m_sName = aCDuplicateSingleton.m_sName;
60  UpdateReasonText();
61  }
62 
63  //Operator= Assignment Operator
64 
65  CDuplicateSingleton operator=
66  (const CDuplicateSingleton& aCDuplicateSingleton)
67  {
68  if (this != &aCDuplicateSingleton) {
69  CException::operator= (aCDuplicateSingleton);
70  m_sName = aCDuplicateSingleton.m_sName;
71  UpdateReasonText();
72  }
73  return *this;
74  }
75 
76  //Operator== Equality Operator
77 
78  int operator== (const CDuplicateSingleton& aCDuplicateSingleton)
79  {
80  return (
81  (CException::operator== (aCDuplicateSingleton)) &&
82  (m_sName == aCDuplicateSingleton.m_sName)
83  );
84  }
85 
86  public:
87  std::string getName() const
88  {
89  return m_sName;
90  }
91 
92  public:
93  void setName (std::string am_sName)
94  {
95  m_sName = am_sName;
96  }
97 
98  public:
99 
100  virtual const char* ReasonText() const;
101 
102  protected:
103  void UpdateReasonText();
104 };
105 
106 #endif
Definition: CDuplicateSingleton.h:26
Definition: Exception.h:41