Belle II Software development
Named.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <tracking/trackFindingCDC/utilities/Scalar.h>
11
12#include <string>
13
14namespace Belle2 {
19 namespace TrackFindingCDC {
20
22 template<class T>
23 class Named : public ScalarToClass<T> {
24
25 private:
27 using Super = ScalarToClass<T>;
28
29 public:
31 using Super::Super;
32
34 Named(const std::string& name, T t)
35 : Super(std::move(t))
36 , m_name(name)
37 {
38 }
39
41 bool operator<(const Named<T>& other) const
42 {
43 // cppcheck-suppress constVariable
44 const T& t(*this);
45 // cppcheck-suppress constVariable
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}
A mixin class to attach a name to an object.
Definition: Named.h:23
ScalarToClass< T > Super
Type of the base class.
Definition: Named.h:27
std::string getName() const
Getter for the name.
Definition: Named.h:51
void setName(const std::string &name)
Setter for the name of the object.
Definition: Named.h:57
std::string m_name
Memory for the name.
Definition: Named.h:64
bool operator<(const Named< T > &other) const
Comparison operator establishing an ordering considering the name and the object.
Definition: Named.h:41
Named(const std::string &name, T t)
Constructor taking the name and the desired value.
Definition: Named.h:34
Abstract base class for different kinds of events.
STL namespace.