Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:32

0001 // -*- C++ -*-
0002 //
0003 // Named.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad
0005 //
0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef ThePEG_Named_H
0010 #define ThePEG_Named_H
0011 // This is the declaration of the Named class.
0012 
0013 
0014 #include <string>
0015 
0016 namespace ThePEG {
0017 
0018 /**
0019  * The <code>Named</code> class is a simple concrete base class to
0020  * used by classes of objects with a name. It just defines a string
0021  * member variable with corresponding (protected) set and get
0022  * functions.
0023  */
0024 class Named {
0025 
0026 public:
0027 
0028   /**
0029    * Constructor with name.
0030    */
0031   Named(const string & newName = string()) 
0032     : theName(newName) {}
0033 
0034   /**
0035    *  Explicit default copy-constructor (too avoid compiler warnings)
0036    */
0037   Named(const Named & ) = default;
0038   
0039   /**
0040    * Return name.
0041    */
0042   const string & name() const { return theName; }
0043 
0044   /**
0045    * Test for equality.
0046    */
0047   bool operator == (const Named & other) const { 
0048     return theName == other.name(); 
0049   }
0050 
0051   /**
0052    * Lexicographical comparison.
0053    */
0054   bool operator < (const Named & other) const { 
0055     return theName < other.name(); 
0056   }
0057 
0058 protected:
0059 
0060   /**
0061    * Assignment.
0062    */
0063   const Named & operator = (const Named & other) {
0064     if (this != &other)
0065       theName = other.name(); 
0066     return *this; 
0067   }
0068 
0069   /**
0070    * Set new name.
0071    */
0072   const string & name(const string & newName) { 
0073     return theName = newName; 
0074   } 
0075 
0076 private:
0077 
0078   /**
0079    * The string containing the name.
0080    */
0081   string theName;
0082 
0083 };
0084 
0085 }
0086 
0087 #endif /* ThePEG_Named_H */