Belle II Software  release-05-02-19
Time.h
1 //-----------------------------------------------------------------------------
2 // $Id$
3 //-----------------------------------------------------------------------------
4 // Filename : TRGTime.h
5 // Section : TRG
6 // Owner : Yoshihito Iwasaki
7 // Email : yoshihito.iwasaki@kek.jp
8 //-----------------------------------------------------------------------------
9 // Description : A class to represent a signal timing in the trigger system.
10 //-----------------------------------------------------------------------------
11 // $Log$
12 //-----------------------------------------------------------------------------
13 
14 #ifndef TRGTime_FLAG_
15 #define TRGTime_FLAG_
16 
17 #include <string>
18 
19 namespace Belle2 {
25  class TRGSignal;
26  class TRGClock;
27 
30  class TRGTime {
31 
32  public:
33 
35  TRGTime(const TRGTime&);
36 
39  TRGTime(double timing,
40  bool edge,
41  const TRGClock& clock,
42  const std::string& name = "signal");
43 
46  TRGTime(int clockPosition,
47  bool edge,
48  const TRGClock& clock,
49  const std::string& name = "signal");
50 
52  virtual ~TRGTime();
53 
54  public:// Selectors.
55 
57  const std::string& name(void) const;
58 
60  const std::string& name(const std::string& newName);
61 
63  bool edge(void) const;
64 
66  const TRGClock& clock(void) const;
67 
69  int time(void) const;
70 
73  void dump(const std::string& message = "",
74  const std::string& pre = "") const;
75 
76  public:// Operators
77 
79  const TRGClock& clock(const TRGClock&);
80 
82  TRGSignal operator&(const TRGTime&) const;
83 
85  TRGSignal operator&(const TRGSignal&) const;
86 
88  TRGSignal operator|(const TRGTime&) const;
89 
91  TRGSignal operator|(const TRGSignal&) const;
92 
94  bool operator==(const TRGTime&) const;
95 
97  bool operator!=(const TRGTime&) const;
98 
100  int time(int newTime);
101 
103  TRGTime& reverse(void);
104 
106  TRGTime& shift(int unit);
107 
108  public://
109 
111  static bool sortByTime(const TRGTime& a, const TRGTime& b);
112 
113  private:
114 
116  int _time;
117 
119  bool _edge;
120 
122  const TRGClock* _clock;
123 
125  std::string _name;
126  };
127 
128 //-----------------------------------------------------------------------------
129 
130  inline
131  const std::string&
132  TRGTime::name(void) const
133  {
134  return _name;
135  }
136 
137  inline
138  const std::string&
139  TRGTime::name(const std::string& a)
140  {
141  return _name = a;
142  }
143 
144  inline
145  TRGTime&
147  {
148  _edge = ! _edge;
149  return * this;
150  }
151 
152  inline
153  const TRGClock&
154  TRGTime::clock(void) const
155  {
156  return * _clock;
157  }
158 
159  inline
160  bool
161  TRGTime::edge(void) const
162  {
163  return _edge;
164  }
165 
166  inline
167  TRGTime&
169  {
170  _time += u;
171  return * this;
172  }
173 
174  inline
175  int
176  TRGTime::time(void) const
177  {
178  return _time;
179  }
180 
181  inline
182  int
184  {
185  return _time = a;
186  }
187 
188  inline
189  bool
190  TRGTime::operator==(const TRGTime& a) const
191  {
192  if (_time != a._time) return false;
193  if (_edge != a._edge) return false;
194  if (_clock != a._clock) return false;
195  // no name check
196  return true;
197  }
198 
199  inline
200  bool
201  TRGTime::operator!=(const TRGTime& a) const
202  {
203  return (! operator==(a));
204  }
205 
207 } // namespace Belle2
208 
209 #endif /* TRGTime_FLAG_ */
Belle2::TRGSignal
A class to represent a digitized signal. Unit is nano second.
Definition: Signal.h:28
Belle2::TRGTime::_edge
bool _edge
Edge type. true : rising, false : falling.
Definition: Time.h:119
Belle2::TRGTime::shift
TRGTime & shift(int unit)
delays by clock unit.
Definition: Time.h:168
Belle2::TRGTime::operator!=
bool operator!=(const TRGTime &) const
returns false if two are the same.
Definition: Time.h:201
Belle2::TRGTime::operator|
TRGSignal operator|(const TRGTime &) const
oring two TRGTime. A result is TRGSignal.
Definition: Time.cc:77
Belle2::TRGTime::operator==
bool operator==(const TRGTime &) const
returns true if two are the same.
Definition: Time.h:190
Belle2::TRGTime::edge
bool edge(void) const
returns edge information.
Definition: Time.h:161
Belle2::TRGTime::name
const std::string & name(void) const
returns name.
Definition: Time.h:132
Belle2::TRGTime::_name
std::string _name
Name.
Definition: Time.h:125
Belle2::TRGTime::dump
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
Definition: Time.cc:92
Belle2::TRGTime::clock
const TRGClock & clock(void) const
returns clock.
Definition: Time.h:154
Belle2::TRGTime::sortByTime
static bool sortByTime(const TRGTime &a, const TRGTime &b)
returns true if a is older than b.
Definition: Time.cc:112
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TRGTime::_clock
const TRGClock * _clock
Clock.
Definition: Time.h:122
Belle2::TRGTime::operator&
TRGSignal operator&(const TRGTime &) const
adding two TRGTime. A result is TRGSignal.
Definition: Time.cc:62
Belle2::TRGTime::time
int time(void) const
returns timing in clock position.
Definition: Time.h:176
Belle2::TRGTime::~TRGTime
virtual ~TRGTime()
Destructor.
Definition: Time.cc:57
Belle2::TRGTime::TRGTime
TRGTime(const TRGTime &)
Copy constructor.
Definition: Time.cc:27
Belle2::TRGTime
A class to represent a signal timing in the trigger system.
Definition: Time.h:30
Belle2::TRGClock
A class to represent a digitized signal. Unit is nano second.
Definition: Clock.h:43
Belle2::TRGTime::_time
int _time
Time in clock unit.
Definition: Time.h:116
Belle2::TRGTime::reverse
TRGTime & reverse(void)
reverse edge.
Definition: Time.h:146