EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimIdentifier.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SimIdentifier.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
12 
13 #include <cstddef>
14 #include <vector>
15 
16 namespace ActsExamples {
17 
27  public:
28  using Value = uint64_t;
29  using Difference = int64_t;
30 
34  explicit SimIdentifier(Value value) : m_value(value) {}
39  SimIdentifier(Value value, std::vector<std::size_t> indices)
40  : m_value(value), m_indices(std::move(indices)) {}
41 
42  // Explicitely defaulted constructors and assignment operators
43  SimIdentifier() = default;
44  SimIdentifier(const SimIdentifier&) = default;
45  SimIdentifier(SimIdentifier&&) = default;
46  SimIdentifier& operator=(const SimIdentifier&) = default;
48 
52  operator Value() const { return m_value; }
53 
55  Value value() const { return m_value; }
57  const std::vector<std::size_t>& indices() const { return m_indices; }
58 
60  void addIndex(std::size_t index) { m_indices.push_back(index); }
61 
62  private:
66  std::vector<std::size_t> m_indices;
67 
68  friend constexpr bool operator<(const SimIdentifier& lhs,
69  const SimIdentifier& rhs) {
70  return lhs.m_value < rhs.m_value;
71  }
72  friend bool operator==(const SimIdentifier& lhs, const SimIdentifier& rhs) {
73  return lhs.m_value == rhs.m_value;
74  }
75 };
76 
77 } // end of namespace ActsExamples
78