Belle II Software  release-05-01-25
Named.h
1 /**************************************************************************
2 * BASF2 (Belle Analysis Framework 2) *
3 * Copyright(C) 2015 - Belle II Collaboration *
4 * *
5 * Author: The Belle II Collaboration *
6 * Contributors: Oliver Frost *
7 * *
8 * This software is provided "as is" without any warranty. *
9 **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/utilities/Scalar.h>
13 
14 #include <string>
15 
16 namespace Belle2 {
21  namespace TrackFindingCDC {
22 
24  template<class T>
25  class Named : public ScalarToClass<T> {
26 
27  private:
29  using Super = ScalarToClass<T>;
30 
31  public:
33  using Super::Super;
34 
36  Named(const std::string& name, T t)
37  : Super(std::move(t))
38  , m_name(name)
39  {
40  }
41 
43  bool operator<(const Named<T>& other) const
44  {
45  const T& t(*this);
46  const T& otherT(other);
47  return getName() < other.getName() or (not(other.getName() < getName()) and t < otherT);
48  }
49 
51  std::string getName() const
52  {
53  return m_name;
54  }
55 
57  void setName(const std::string& name)
58  {
59  m_name = name;
60  }
61 
62  private:
64  std::string m_name = "";
65  };
66  }
68 }
Belle2::TrackFindingCDC::Named
A mixin class to attach a name to an object.
Definition: Named.h:33
Belle2::TrackFindingCDC::Named::operator<
bool operator<(const Named< T > &other) const
Comparison operator establishing an ordering considering the name and the object.
Definition: Named.h:51
Belle2::TrackFindingCDC::Named::Named
Named(const std::string &name, T t)
Constructor taking the name and the desired value.
Definition: Named.h:44
Belle2::TrackFindingCDC::Named::setName
void setName(const std::string &name)
Setter for the name of the object.
Definition: Named.h:65
Belle2::TrackFindingCDC::Named::m_name
std::string m_name
Memory for the name.
Definition: Named.h:72
Belle2::TrackFindingCDC::Named::Super
ScalarToClass< T > Super
Type of the base class.
Definition: Named.h:37
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::Named::getName
std::string getName() const
Getter for the name.
Definition: Named.h:59