sc_process_handle.hh revision 12838:f03602fb0c75
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_PROCESS_HANDLE_HH__ 31#define __SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__ 32 33#include <exception> 34#include <vector> 35 36namespace sc_core 37{ 38 39class sc_event; 40class sc_object; 41 42enum sc_curr_proc_kind 43{ 44 SC_NO_PROC_, 45 SC_METHOD_PROC_, 46 SC_THREAD_PROC_, 47 SC_CTHREAD_PROC_ 48}; 49 50enum sc_descendent_inclusion_info 51{ 52 SC_NO_DESCENDANTS, 53 SC_INCLUDE_DESCENDANTS 54}; 55 56class sc_unwind_exception : public std::exception 57{ 58 public: 59 virtual const char *what() const throw(); 60 virtual bool is_reset() const; 61 62 protected: 63 sc_unwind_exception(); 64 sc_unwind_exception(const sc_unwind_exception &); 65 virtual ~sc_unwind_exception() throw(); 66}; 67 68class sc_process_handle 69{ 70 public: 71 sc_process_handle(); 72 sc_process_handle(const sc_process_handle &); 73 explicit sc_process_handle(sc_object *); 74 ~sc_process_handle(); 75 76 bool valid() const; 77 78 sc_process_handle &operator = (const sc_process_handle &); 79 bool operator == (const sc_process_handle &) const; 80 bool operator != (const sc_process_handle &) const; 81 bool operator < (const sc_process_handle &) const; 82 bool swap(sc_process_handle &); 83 84 const char *name() const; 85 sc_curr_proc_kind proc_kind() const; 86 const std::vector<sc_object *> &get_child_objects() const; 87 const std::vector<sc_event *> &get_child_events() const; 88 sc_object *get_parent_object() const; 89 sc_object *get_process_object() const; 90 bool dynamic() const; 91 bool terminated() const; 92 const sc_event &terminated_event() const; 93 94 void suspend(sc_descendent_inclusion_info include_descendants= 95 SC_NO_DESCENDANTS); 96 void resume(sc_descendent_inclusion_info include_descendants= 97 SC_NO_DESCENDANTS); 98 void disable(sc_descendent_inclusion_info include_descendants= 99 SC_NO_DESCENDANTS); 100 void enable(sc_descendent_inclusion_info include_descendants= 101 SC_NO_DESCENDANTS); 102 void kill(sc_descendent_inclusion_info include_descendants= 103 SC_NO_DESCENDANTS); 104 void reset(sc_descendent_inclusion_info include_descendants= 105 SC_NO_DESCENDANTS); 106 bool is_unwinding(); 107 const sc_event &reset_event() const; 108 109 void sync_reset_on(sc_descendent_inclusion_info include_descendants= 110 SC_NO_DESCENDANTS); 111 void sync_reset_off(sc_descendent_inclusion_info include_descendants= 112 SC_NO_DESCENDANTS); 113 114 void warn_unimpl(const char *func); 115 template <typename T> 116 void throw_it(const T &user_defined_exception, 117 sc_descendent_inclusion_info include_descendants= 118 SC_NO_DESCENDANTS) 119 { 120 warn_unimpl(__PRETTY_FUNCTION__); 121 } 122}; 123 124sc_process_handle sc_get_current_process_handle(); 125bool sc_is_unwinding(); 126 127} // namespace sc_core 128 129#endif //__SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__ 130