tt_event.hpp
Go to the documentation of this file.
1 /**********************************************************************
2  * tt_event.hpp -- Time-Tagged Event data type *
3  * *
4  * Author: Hosein Attarzadeh (shan2@kth.se) *
5  * *
6  * Purpose: Define a time-tagged event used in the timed MoCs *
7  * *
8  * Usage: This file is included automatically *
9  * *
10  * License: BSD3 *
11  *******************************************************************/
12 
13 #ifndef TT_EVENT_HPP
14 #define TT_EVENT_HPP
15 
20 #include "abst_ext.hpp"
21 
22 namespace ForSyDe
23 {
24 
25 using namespace sc_core;
26 
28 
31 template <typename VT, typename TT=sc_time>
32 struct tt_event
33 {
35  tt_event(const VT& value, const TT& time) : value(value), time(time) {}
36 
39  {
40  value = VT();
41  time = TT();
42  }
43 
45  tt_event (const tt_event& ev)
46  {
47  value = get_value(ev);
48  time = get_time(ev);
49  }
50 
52 
54  bool operator== (const tt_event& ev) const
55  {
56  return (value == get_value(ev)) && (time == get_time(ev));
57  }
58 
60  friend std::ostream& operator<< (std::ostream& os, const tt_event &ev)
61  {
62  os << "(" << ev.value << "," << ev.time << ")";
63  return os;
64  }
65 
66  inline friend VT get_value(const tt_event& ev) {return ev.value;}
67 
68  inline friend TT get_time(const tt_event& ev) {return ev.time;}
69 
70  inline friend void set_value(tt_event& ev, const VT& v) {ev.value = v;}
71 
72  inline friend void set_time(tt_event& ev, const TT& t) {ev.time = t;}
73 
74 private:
75  VT value;
76  TT time;
77 };
78 
80 template<typename T>
82 
83 }
84 #endif
tt_event(const VT &value, const TT &time)
The constructor with time and value.
Definition: tt_event.hpp:35
Time-tagged data types.
Definition: tt_event.hpp:32
The namespace for ForSyDe.
Definition: abssemantics.hpp:30
Implements the Absent-extended values.
tt_event()
The default constructor.
Definition: tt_event.hpp:38
tt_event(const tt_event &ev)
The copy constructor.
Definition: tt_event.hpp:45