ThePEG  1.8.0
Named.h
1 // -*- C++ -*-
2 //
3 // Named.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef ThePEG_Named_H
10 #define ThePEG_Named_H
11 // This is the declaration of the Named class.
12 
13 
14 #include <string>
15 
16 namespace ThePEG {
17 
24 class Named {
25 
26 public:
27 
31  Named(const string & newName = string())
32  : theName(newName) {}
33 
37  const string & name() const { return theName; }
38 
42  bool operator == (const Named & other) const
43  {
44  return theName == other.name();
45  }
46 
50  bool operator < (const Named & other) const
51  {
52  return theName < other.name();
53  }
54 
55 protected:
56 
60  const Named & operator = (const Named & other)
61  {
62  if (this != &other)
63  theName = other.name();
64  return *this;
65  }
66 
70  const string & name(const string & newName)
71  {
72  return theName = newName;
73  }
74 
75 private:
76 
80  string theName;
81 
82 };
83 
84 }
85 
86 #endif /* ThePEG_Named_H */
string theName
The string containing the name.
Definition: Named.h:80
bool operator<(const Named &other) const
Lexicographical comparison.
Definition: Named.h:50
const string & name(const string &newName)
Set new name.
Definition: Named.h:70
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
The Named class is a simple concrete base class to used by classes of objects with a name...
Definition: Named.h:24
bool operator==(const Named &other) const
Test for equality.
Definition: Named.h:42
const string & name() const
Return name.
Definition: Named.h:37
Named(const string &newName=string())
Constructor with name.
Definition: Named.h:31
const Named & operator=(const Named &other)
Assignment.
Definition: Named.h:60