thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
Named.h
1// -*- C++ -*-
2//
3// Named.h is a part of ThePEG - Toolkit for HEP Event Generation
4// Copyright (C) 1999-2019 Leif Lonnblad
5//
6// ThePEG is licenced under version 3 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
16namespace ThePEG {
17
24class Named {
25
26public:
27
31 Named(const string & newName = string())
32 : theName(newName) {}
33
37 Named(const Named & ) = default;
38
42 const string & name() const { return theName; }
43
47 bool operator == (const Named & other) const {
48 return theName == other.name();
49 }
50
54 bool operator < (const Named & other) const {
55 return theName < other.name();
56 }
57
58protected:
59
63 const Named & operator = (const Named & other) {
64 if (this != &other)
65 theName = other.name();
66 return *this;
67 }
68
72 const string & name(const string & newName) {
73 return theName = newName;
74 }
75
76private:
77
81 string theName;
82
83};
84
85}
86
87#endif /* ThePEG_Named_H */
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
Lexicographical comparison.
Definition: Named.h:54
bool operator==(const Named &other) const
Test for equality.
Definition: Named.h:47
const string & name() const
Return name.
Definition: Named.h:42
const Named & operator=(const Named &other)
Assignment.
Definition: Named.h:63
Named(const Named &)=default
Explicit default copy-constructor (too avoid compiler warnings)
Named(const string &newName=string())
Constructor with name.
Definition: Named.h:31
string theName
The string containing the name.
Definition: Named.h:81
const string & name(const string &newName)
Set new name.
Definition: Named.h:72
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28