Belle II Software  release-08-01-10
Time.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 
9 #ifndef TRGTime_FLAG_
10 #define TRGTime_FLAG_
11 
12 #include <string>
13 
14 namespace Belle2 {
20  class TRGSignal;
21  class TRGClock;
22 
25  class TRGTime {
26 
27  public:
28 
30  TRGTime(const TRGTime&);
31 
34  TRGTime(double timing,
35  bool edge,
36  const TRGClock& clock,
37  const std::string& name = "signal");
38 
41  TRGTime(int clockPosition,
42  bool edge,
43  const TRGClock& clock,
44  const std::string& name = "signal");
45 
47  virtual ~TRGTime();
48 
49  public:// Selectors.
50 
52  const std::string& name(void) const;
53 
55  const std::string& name(const std::string& newName);
56 
58  bool edge(void) const;
59 
61  const TRGClock& clock(void) const;
62 
64  int time(void) const;
65 
68  void dump(const std::string& message = "",
69  const std::string& pre = "") const;
70 
71  public:// Operators
72 
74  const TRGClock& clock(const TRGClock&);
75 
77  TRGSignal operator&(const TRGTime&) const;
78 
80  TRGSignal operator&(const TRGSignal&) const;
81 
83  TRGSignal operator|(const TRGTime&) const;
84 
86  TRGSignal operator|(const TRGSignal&) const;
87 
89  bool operator==(const TRGTime&) const;
90 
92  bool operator!=(const TRGTime&) const;
93 
95  int time(int newTime);
96 
98  TRGTime& reverse(void);
99 
101  TRGTime& shift(int unit);
102 
103  public://
104 
106  static bool sortByTime(const TRGTime& a, const TRGTime& b);
107 
108  private:
109 
111  int _time;
112 
114  bool _edge;
115 
117  const TRGClock* _clock;
118 
120  std::string _name;
121  };
122 
123 //-----------------------------------------------------------------------------
124 
125  inline
126  const std::string&
127  TRGTime::name(void) const
128  {
129  return _name;
130  }
131 
132  inline
133  const std::string&
134  TRGTime::name(const std::string& a)
135  {
136  return _name = a;
137  }
138 
139  inline
140  TRGTime&
142  {
143  _edge = ! _edge;
144  return * this;
145  }
146 
147  inline
148  const TRGClock&
149  TRGTime::clock(void) const
150  {
151  return * _clock;
152  }
153 
154  inline
155  bool
156  TRGTime::edge(void) const
157  {
158  return _edge;
159  }
160 
161  inline
162  TRGTime&
164  {
165  _time += u;
166  return * this;
167  }
168 
169  inline
170  int
171  TRGTime::time(void) const
172  {
173  return _time;
174  }
175 
176  inline
177  int
179  {
180  return _time = a;
181  }
182 
183  inline
184  bool
185  TRGTime::operator==(const TRGTime& a) const
186  {
187  if (_time != a._time) return false;
188  if (_edge != a._edge) return false;
189  if (_clock != a._clock) return false;
190  // no name check
191  return true;
192  }
193 
194  inline
195  bool
196  TRGTime::operator!=(const TRGTime& a) const
197  {
198  return (! operator==(a));
199  }
200 
202 } // namespace Belle2
203 
204 #endif /* TRGTime_FLAG_ */
A class to represent a digitized signal. Unit is nano second.
Definition: Clock.h:38
A class to represent a digitized signal. Unit is nano second.
Definition: Signal.h:23
A class to represent a signal timing in the trigger system.
Definition: Time.h:25
const TRGClock * _clock
Clock.
Definition: Time.h:117
int _time
Time in clock unit.
Definition: Time.h:111
std::string _name
Name.
Definition: Time.h:120
bool _edge
Edge type. true : rising, false : falling.
Definition: Time.h:114
virtual ~TRGTime()
Destructor.
Definition: Time.cc:52
bool operator!=(const TRGTime &) const
returns false if two are the same.
Definition: Time.h:196
bool operator==(const TRGTime &) const
returns true if two are the same.
Definition: Time.h:185
const TRGClock & clock(void) const
returns clock.
Definition: Time.h:149
TRGTime & reverse(void)
reverse edge.
Definition: Time.h:141
const std::string & name(void) const
returns name.
Definition: Time.h:127
TRGTime(const TRGTime &)
Copy constructor.
Definition: Time.cc:22
TRGSignal operator|(const TRGTime &) const
oring two TRGTime. A result is TRGSignal.
Definition: Time.cc:72
TRGTime & shift(int unit)
delays by clock unit.
Definition: Time.h:163
int time(void) const
returns timing in clock position.
Definition: Time.h:171
bool edge(void) const
returns edge information.
Definition: Time.h:156
static bool sortByTime(const TRGTime &a, const TRGTime &b)
returns true if a is older than b.
Definition: Time.cc:107
TRGSignal operator&(const TRGTime &) const
adding two TRGTime. A result is TRGSignal.
Definition: Time.cc:57
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
Definition: Time.cc:87
Abstract base class for different kinds of events.