event.hh revision 12955
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_CORE_EVENT_HH__ 31#define __SYSTEMC_CORE_EVENT_HH__ 32 33#include <string> 34#include <vector> 35 36#include "systemc/core/list.hh" 37#include "systemc/core/object.hh" 38#include "systemc/ext/core/sc_prim.hh" 39#include "systemc/ext/core/sc_time.hh" 40 41namespace sc_core 42{ 43 44class sc_event; 45 46} // namespace sc_core 47 48namespace sc_gem5 49{ 50 51typedef std::vector<sc_core::sc_event *> Events; 52 53class Event 54{ 55 public: 56 Event(sc_core::sc_event *_sc_event); 57 Event(sc_core::sc_event *_sc_event, const char *_basename); 58 59 ~Event(); 60 61 sc_core::sc_event *sc_event() { return _sc_event; } 62 63 const std::string &name() const; 64 const std::string &basename() const; 65 bool inHierarchy() const; 66 sc_core::sc_object *getParentObject() const; 67 68 void notify(); 69 void notify(const sc_core::sc_time &t); 70 void 71 notify(double d, sc_core::sc_time_unit &u) 72 { 73 notify(sc_core::sc_time(d, u)); 74 } 75 void cancel(); 76 77 bool triggered() const; 78 79 static Event * 80 getFromScEvent(sc_core::sc_event *e) 81 { 82 return e->_gem5_event; 83 } 84 85 static const Event * 86 getFromScEvent(const sc_core::sc_event *e) 87 { 88 return e->_gem5_event; 89 } 90 91 private: 92 sc_core::sc_event *_sc_event; 93 94 std::string _basename; 95 std::string _name; 96 bool _inHierarchy; 97 98 sc_core::sc_object *parent; 99 EventsIt parentIt; 100}; 101 102extern Events topLevelEvents; 103extern Events allEvents; 104 105EventsIt findEvent(const std::string &name); 106 107} // namespace sc_gem5 108 109#endif //__SYSTEMC_CORE_EVENT_HH__ 110