00001 // -*- C++ -*- 00002 /*************************************************************************** 00003 * 00004 * The IPPL Framework 00005 * 00006 * 00007 * Visit http://people.web.psi.ch/adelmann/ for more details 00008 * 00009 ***************************************************************************/ 00010 00011 #ifndef NAMED_OBJ_H 00012 #define NAMED_OBJ_H 00013 00014 /*************************************************************************** 00015 * 00016 * NamedObj is a simple base class for objects which desire to have a name; 00017 * it provides one method 'name()' which returns the name of the object. 00018 * 00019 ***************************************************************************/ 00020 00021 // include files 00022 #include "Utility/Pstring.h" 00023 00024 00025 class NamedObj { 00026 00027 public: 00028 NamedObj(const char *nm = 0) { 00029 if (nm != 0) 00030 MyName = nm; 00031 } 00032 ~NamedObj() { } 00033 00034 // return the current name 00035 const char *name() const { return MyName.c_str(); } 00036 00037 // change the name 00038 const char *setName(const char *nm = 0) { 00039 if (nm != 0) 00040 MyName = nm; 00041 else 00042 MyName = ""; 00043 return MyName.c_str(); 00044 } 00045 00046 private: 00047 string MyName; 00048 }; 00049 00050 #endif // NAMED_OBJ_H 00051 00052 /*************************************************************************** 00053 * $RCSfile: NamedObj.h,v $ $Author: adelmann $ 00054 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:33 $ 00055 * IPPL_VERSION_ID: $Id: NamedObj.h,v 1.1.1.1 2003/01/23 07:40:33 adelmann Exp $ 00056 ***************************************************************************/