FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairTimeStamp.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 #ifndef FAIRTIMESTAMP_H
9 #define FAIRTIMESTAMP_H
10 
11 #include "FairMultiLinkedData_Interface.h" // for FairMultiLinkedData
12 
13 #include <Rtypes.h> // for Double_t, etc
14 #include <iosfwd> // for ostream
15 #include <iostream> // for ostream, cout
16 
17 namespace boost {
18 namespace serialization {
19 class access;
20 }
21 } // namespace boost
22 #include <boost/serialization/base_object.hpp>
23 
24 class TObject;
25 
32 {
33  public:
35  FairTimeStamp();
37  FairTimeStamp(Double_t time);
39  FairTimeStamp(Double_t time, Double_t timeerror);
40 
42  virtual ~FairTimeStamp(){};
44  Double_t GetTimeStamp() const { return fTimeStamp; }
45  Double_t GetTimeStampError() const { return fTimeStampError; }
47  void SetTimeStamp(Double_t t) { fTimeStamp = t; }
48  void SetTimeStampError(Double_t t) { fTimeStampError = t; }
49  virtual Int_t Compare(const TObject* obj) const
50  {
51  if (this == obj) {
52  return 0;
53  }
54  FairTimeStamp* tsobj = static_cast<FairTimeStamp*>(const_cast<TObject*>(obj));
55  Double_t ts = tsobj->GetTimeStamp();
56  Double_t tserror = tsobj->GetTimeStampError();
57  if (fTimeStamp < ts) {
58  return -1;
59  } else if (fTimeStamp == ts && fTimeStampError < tserror) {
60  return -1;
61  } else if (fTimeStamp == ts && fTimeStampError == tserror) {
62  return 0;
63  } else {
64  return 1;
65  }
66  }
67 
68  virtual std::ostream& PrintTimeInfo(std::ostream& out = std::cout) const;
69  virtual Bool_t IsSortable() const { return kTRUE; };
70 
71  virtual bool equal(FairTimeStamp* data)
72  {
73  return (fTimeStamp == data->GetTimeStamp() && fTimeStampError == data->GetTimeStampError());
74  }
75 
76  friend std::ostream& operator<<(std::ostream& out, const FairTimeStamp& link)
77  {
78  link.PrintTimeInfo(out);
79  return out;
80  }
81 
82  virtual bool operator<(const FairTimeStamp* rValue) const
83  {
84  if (GetTimeStamp() < rValue->GetTimeStamp())
85  return true;
86  else
87  return false;
88  }
89 
90  template<class Archive>
91  void serialize(Archive& ar, const unsigned int)
92  {
93  // ar & boost::serialization::base_object<FairMultiLinkedData>(*this);
94  ar& fTimeStamp;
95  ar& fTimeStampError;
96  }
97 
98  protected:
100 
101  Double_t fTimeStamp;
102  Double_t fTimeStampError;
105 };
106 
107 // ----- Default constructor -------------------------------------------
110  , fTimeStamp(-1)
111  , fTimeStampError(-1)
112 {}
113 
114 // ----- Standard constructor ------------------------------------------
115 inline FairTimeStamp::FairTimeStamp(Double_t time)
117  , fTimeStamp(time)
118  , fTimeStampError(-1)
119 {}
120 
121 inline FairTimeStamp::FairTimeStamp(Double_t time, Double_t timeerror)
123  , fTimeStamp(time)
124  , fTimeStampError(timeerror)
125 {}
126 
127 #endif
virtual Int_t Compare(const TObject *obj) const
Definition: FairTimeStamp.h:49
Double_t fTimeStamp
Double_t GetTimeStampError() const
Definition: FairTimeStamp.h:45
Double_t GetTimeStamp() const
Definition: FairTimeStamp.h:44
void SetTimeStamp(Double_t t)
Definition: FairTimeStamp.h:47
virtual bool operator<(const FairTimeStamp *rValue) const
Definition: FairTimeStamp.h:82
ClassDef(FairTimeStamp, 4)
Double_t fTimeStampError
friend std::ostream & operator<<(std::ostream &out, const FairTimeStamp &link)
Definition: FairTimeStamp.h:76
friend class boost::serialization::access
Definition: FairTimeStamp.h:99
void SetTimeStampError(Double_t t)
Definition: FairTimeStamp.h:48
virtual bool equal(FairTimeStamp *data)
Definition: FairTimeStamp.h:71
virtual Bool_t IsSortable() const
Definition: FairTimeStamp.h:69
void serialize(Archive &ar, const unsigned int)
Definition: FairTimeStamp.h:91
virtual ~FairTimeStamp()
Definition: FairTimeStamp.h:42
virtual std::ostream & PrintTimeInfo(std::ostream &out=std::cout) const