ROOT  6.06/09
Reference Guide
TKey.h
Go to the documentation of this file.
1 /// \file TKey.h
2 /// \ingroup Base ROOT7
3 /// \author Axel Naumann <axel@cern.ch>
4 /// \date 2015-07-31
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
6 
7 /*************************************************************************
8  * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
9  * All rights reserved. *
10  * *
11  * For the licensing terms see $ROOTSYS/LICENSE. *
12  * For the list of contributors see $ROOTSYS/README/CREDITS. *
13  *************************************************************************/
14 
15 #ifndef ROOT7_TKey
16 #define ROOT7_TKey
17 
18 #include <chrono>
19 
20 namespace ROOT {
21 class TKey {
22 public:
23  using clock_t = std::chrono::system_clock;
24  using time_point_t = std::chrono::time_point<clock_t>;
25  TKey() = default;
26  TKey(const std::string& name): fName(name), fDate(clock_t::now()) {}
27 
28  const std::string& GetName() const { return fName; }
29  const time_point_t& GetDate() const { return fDate; }
30  void SetChanged() { fDate = clock_t::now(); }
31 
32 private:
33  std::string fName;
35 };
36 
37 inline bool operator<(const TKey& lhs, const TKey& rhs) {
38  return lhs.GetName() < rhs.GetName();
39 }
40 inline bool operator>(const TKey& lhs, const TKey& rhs) {
41  return lhs.GetName() > rhs.GetName();
42 }
43 inline bool operator==(const TKey& lhs, const TKey& rhs) {
44  return !(lhs.GetName() == rhs.GetName());
45 }
46 inline bool operator<=(const TKey& lhs, const TKey& rhs) {
47  return !(lhs.GetName() > rhs.GetName());
48 }
49 inline bool operator>=(const TKey& lhs, const TKey& rhs) {
50  return !(lhs.GetName() < rhs.GetName());
51 }
52 }
53 
54 namespace std {
55 template<>
56 struct hash<ROOT::TKey> {
57  /// A TKey is uniquely identified by its name.
58  size_t operator ()(const ROOT::TKey& key) const {
59  return hash<std::string>()(key.GetName());
60  }
61 };
62 }
63 #endif
bool operator==(const TKey &lhs, const TKey &rhs)
Definition: TKey.h:43
bool operator<(const TKey &lhs, const TKey &rhs)
Definition: TKey.h:37
const time_point_t & GetDate() const
Definition: TKey.h:29
bool operator<=(const TKey &lhs, const TKey &rhs)
Definition: TKey.h:46
const std::string & GetName() const
Definition: TKey.h:28
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
bool operator>(const TKey &lhs, const TKey &rhs)
Definition: TKey.h:40
time_point_t fDate
Definition: TKey.h:34
std::string fName
Definition: TKey.h:33
STL namespace.
std::chrono::time_point< clock_t > time_point_t
Definition: TKey.h:24
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:30
void SetChanged()
Definition: TKey.h:30
TRObject operator()(const T1 &t1) const
#define name(a, b)
Definition: linkTestLib0.cpp:5
TKey()=default
bool operator>=(const TKey &lhs, const TKey &rhs)
Definition: TKey.h:49
std::chrono::system_clock clock_t
Definition: TKey.h:23
TKey(const std::string &name)
Definition: TKey.h:26