OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
NamedObj.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  *
7  * Visit http://people.web.psi.ch/adelmann/ for more details
8  *
9  ***************************************************************************/
10 
11 #ifndef NAMED_OBJ_H
12 #define NAMED_OBJ_H
13 
14 /***************************************************************************
15  *
16  * NamedObj is a simple base class for objects which desire to have a name;
17  * it provides one method 'name()' which returns the name of the object.
18  *
19  ***************************************************************************/
20 
21 // include files
22 #include <string>
23 
24 
25 class NamedObj {
26 
27 public:
28  NamedObj(const char *nm = 0) {
29  if (nm != 0)
30  MyName = nm;
31  }
32  virtual ~NamedObj() { }
33 
34  // return the current name
35  const char *name() const { return MyName.c_str(); }
36 
37  // change the name
38  const char *setName(const char *nm = 0) {
39  if (nm != 0)
40  MyName = nm;
41  else
42  MyName = "";
43  return MyName.c_str();
44  }
45 
46 private:
47  std::string MyName;
48 };
49 
50 #endif // NAMED_OBJ_H
51 
52 /***************************************************************************
53  * $RCSfile: NamedObj.h,v $ $Author: adelmann $
54  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:33 $
55  * IPPL_VERSION_ID: $Id: NamedObj.h,v 1.1.1.1 2003/01/23 07:40:33 adelmann Exp $
56  ***************************************************************************/
virtual ~NamedObj()
Definition: NamedObj.h:32
std::string MyName
Definition: NamedObj.h:47
const char * setName(const char *nm=0)
Definition: NamedObj.h:38
const char * name() const
Definition: NamedObj.h:35
NamedObj(const char *nm=0)
Definition: NamedObj.h:28