sc_event.hh (12915:aff42de64e41) sc_event.hh (12924:f74f34bd41ce)
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#ifndef __SYSTEMC_EXT_CORE_SC_EVENT_HH__
31#define __SYSTEMC_EXT_CORE_SC_EVENT_HH__
32
33#include <vector>
34
35#include "sc_time.hh"
36
37namespace sc_core
38{
39
40class sc_event;
41class sc_event_and_expr;
42class sc_event_or_expr;
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#ifndef __SYSTEMC_EXT_CORE_SC_EVENT_HH__
31#define __SYSTEMC_EXT_CORE_SC_EVENT_HH__
32
33#include <vector>
34
35#include "sc_time.hh"
36
37namespace sc_core
38{
39
40class sc_event;
41class sc_event_and_expr;
42class sc_event_or_expr;
43class sc_interface;
43class sc_object;
44class sc_port_base;
45
46class sc_event_finder
47{
48 protected:
49 void warn_unimpl(const char *func) const;
44class sc_object;
45class sc_port_base;
46
47class sc_event_finder
48{
49 protected:
50 void warn_unimpl(const char *func) const;
51
52 public:
53 // Should be "implementation defined" but used in the tests.
54 virtual const sc_event &find_event(sc_interface *if_p=NULL) const = 0;
50};
51
52template <class IF>
53class sc_event_finder_t : public sc_event_finder
54{
55 public:
56 sc_event_finder_t(const sc_port_base &,
57 const sc_event & (IF::*event_method)() const)
58 {
59 warn_unimpl(__PRETTY_FUNCTION__);
60 }
55};
56
57template <class IF>
58class sc_event_finder_t : public sc_event_finder
59{
60 public:
61 sc_event_finder_t(const sc_port_base &,
62 const sc_event & (IF::*event_method)() const)
63 {
64 warn_unimpl(__PRETTY_FUNCTION__);
65 }
66
67 const sc_event &
68 find_event(sc_interface *if_p=NULL) const override
69 {
70 warn_unimpl(__PRETTY_FUNCTION__);
71 return *(const sc_event *)nullptr;
72 }
61};
62
63class sc_event_and_list
64{
65 public:
66 sc_event_and_list();
67 sc_event_and_list(const sc_event_and_list &);
68 sc_event_and_list(const sc_event &);
69 sc_event_and_list &operator = (const sc_event_and_list &);
70
71 int size() const;
72 void swap(sc_event_and_list &);
73
74 sc_event_and_list &operator &= (const sc_event &);
75 sc_event_and_list &operator &= (const sc_event_and_list &);
76
77 sc_event_and_expr operator & (const sc_event &) const;
78 sc_event_and_expr operator & (const sc_event_and_list &);
79};
80
81class sc_event_or_list
82{
83 public:
84 sc_event_or_list();
85 sc_event_or_list(const sc_event_or_list &);
86 sc_event_or_list(const sc_event &);
87 sc_event_or_list& operator = (const sc_event_or_list &);
88 ~sc_event_or_list();
89
90 int size() const;
91 void swap(sc_event_or_list &);
92
93 sc_event_or_list &operator |= (const sc_event &);
94 sc_event_or_list &operator |= (const sc_event_or_list &);
95
96 sc_event_or_expr operator | (const sc_event &) const;
97 sc_event_or_expr operator | (const sc_event_or_list &) const;
98};
99
100class sc_event_and_expr
101{
102 public:
103 operator const sc_event_and_list &() const;
104};
105
106sc_event_and_expr operator & (sc_event_and_expr, sc_event const &);
107sc_event_and_expr operator & (sc_event_and_expr, sc_event_and_list const &);
108
109class sc_event_or_expr
110{
111 public:
112 operator const sc_event_or_list &() const;
113};
114
115sc_event_or_expr operator | (sc_event_or_expr, sc_event const &);
116sc_event_or_expr operator | (sc_event_or_expr, sc_event_or_list const &);
117
118class sc_event
119{
120 public:
121 sc_event();
122 explicit sc_event(const char *);
123 ~sc_event();
124
125 const char *name() const;
126 const char *basename() const;
127 bool in_hierarchy() const;
128 sc_object *get_parent_object() const;
129
130 void notify();
131 void notify(const sc_time &);
132 void notify(double, sc_time_unit);
133 void cancel();
134
135 // Nonstandard
136 // Returns whether this event is currently triggered.
137 bool triggered() const;
138
139 // Deprecated
140 void notify_delayed();
141 void notify_delayed(const sc_time &);
142
143 sc_event_and_expr operator & (const sc_event &) const;
144 sc_event_and_expr operator & (const sc_event_and_list &) const;
145 sc_event_or_expr operator | (const sc_event &) const;
146 sc_event_or_expr operator | (const sc_event_or_list &) const;
147
148 private:
149 // Disabled
150 sc_event(const sc_event &) {}
151 sc_event &operator = (const sc_event &) { return *this; }
152};
153
154const std::vector<sc_event *> &sc_get_top_level_events();
155sc_event *sc_find_event(const char *);
156
157} // namespace sc_core
158
159#endif //__SYSTEMC_EXT_CORE_SC_INTERFACE_HH__
73};
74
75class sc_event_and_list
76{
77 public:
78 sc_event_and_list();
79 sc_event_and_list(const sc_event_and_list &);
80 sc_event_and_list(const sc_event &);
81 sc_event_and_list &operator = (const sc_event_and_list &);
82
83 int size() const;
84 void swap(sc_event_and_list &);
85
86 sc_event_and_list &operator &= (const sc_event &);
87 sc_event_and_list &operator &= (const sc_event_and_list &);
88
89 sc_event_and_expr operator & (const sc_event &) const;
90 sc_event_and_expr operator & (const sc_event_and_list &);
91};
92
93class sc_event_or_list
94{
95 public:
96 sc_event_or_list();
97 sc_event_or_list(const sc_event_or_list &);
98 sc_event_or_list(const sc_event &);
99 sc_event_or_list& operator = (const sc_event_or_list &);
100 ~sc_event_or_list();
101
102 int size() const;
103 void swap(sc_event_or_list &);
104
105 sc_event_or_list &operator |= (const sc_event &);
106 sc_event_or_list &operator |= (const sc_event_or_list &);
107
108 sc_event_or_expr operator | (const sc_event &) const;
109 sc_event_or_expr operator | (const sc_event_or_list &) const;
110};
111
112class sc_event_and_expr
113{
114 public:
115 operator const sc_event_and_list &() const;
116};
117
118sc_event_and_expr operator & (sc_event_and_expr, sc_event const &);
119sc_event_and_expr operator & (sc_event_and_expr, sc_event_and_list const &);
120
121class sc_event_or_expr
122{
123 public:
124 operator const sc_event_or_list &() const;
125};
126
127sc_event_or_expr operator | (sc_event_or_expr, sc_event const &);
128sc_event_or_expr operator | (sc_event_or_expr, sc_event_or_list const &);
129
130class sc_event
131{
132 public:
133 sc_event();
134 explicit sc_event(const char *);
135 ~sc_event();
136
137 const char *name() const;
138 const char *basename() const;
139 bool in_hierarchy() const;
140 sc_object *get_parent_object() const;
141
142 void notify();
143 void notify(const sc_time &);
144 void notify(double, sc_time_unit);
145 void cancel();
146
147 // Nonstandard
148 // Returns whether this event is currently triggered.
149 bool triggered() const;
150
151 // Deprecated
152 void notify_delayed();
153 void notify_delayed(const sc_time &);
154
155 sc_event_and_expr operator & (const sc_event &) const;
156 sc_event_and_expr operator & (const sc_event_and_list &) const;
157 sc_event_or_expr operator | (const sc_event &) const;
158 sc_event_or_expr operator | (const sc_event_or_list &) const;
159
160 private:
161 // Disabled
162 sc_event(const sc_event &) {}
163 sc_event &operator = (const sc_event &) { return *this; }
164};
165
166const std::vector<sc_event *> &sc_get_top_level_events();
167sc_event *sc_find_event(const char *);
168
169} // namespace sc_core
170
171#endif //__SYSTEMC_EXT_CORE_SC_INTERFACE_HH__