sc_process_handle.hh revision 12838
112838Sgabeblack@google.com/*
212838Sgabeblack@google.com * Copyright 2018 Google, Inc.
312838Sgabeblack@google.com *
412838Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
512838Sgabeblack@google.com * modification, are permitted provided that the following conditions are
612838Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
712838Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
812838Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
912838Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1012838Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1112838Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1212838Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1312838Sgabeblack@google.com * this software without specific prior written permission.
1412838Sgabeblack@google.com *
1512838Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1612838Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1712838Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1812838Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1912838Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2012838Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2112838Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2212838Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2312838Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2412838Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2512838Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2612838Sgabeblack@google.com *
2712838Sgabeblack@google.com * Authors: Gabe Black
2812838Sgabeblack@google.com */
2912838Sgabeblack@google.com
3012838Sgabeblack@google.com#ifndef __SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__
3112838Sgabeblack@google.com#define __SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__
3212838Sgabeblack@google.com
3312838Sgabeblack@google.com#include <exception>
3412838Sgabeblack@google.com#include <vector>
3512838Sgabeblack@google.com
3612838Sgabeblack@google.comnamespace sc_core
3712838Sgabeblack@google.com{
3812838Sgabeblack@google.com
3912838Sgabeblack@google.comclass sc_event;
4012838Sgabeblack@google.comclass sc_object;
4112838Sgabeblack@google.com
4212838Sgabeblack@google.comenum sc_curr_proc_kind
4312838Sgabeblack@google.com{
4412838Sgabeblack@google.com    SC_NO_PROC_,
4512838Sgabeblack@google.com    SC_METHOD_PROC_,
4612838Sgabeblack@google.com    SC_THREAD_PROC_,
4712838Sgabeblack@google.com    SC_CTHREAD_PROC_
4812838Sgabeblack@google.com};
4912838Sgabeblack@google.com
5012838Sgabeblack@google.comenum sc_descendent_inclusion_info
5112838Sgabeblack@google.com{
5212838Sgabeblack@google.com    SC_NO_DESCENDANTS,
5312838Sgabeblack@google.com    SC_INCLUDE_DESCENDANTS
5412838Sgabeblack@google.com};
5512838Sgabeblack@google.com
5612838Sgabeblack@google.comclass sc_unwind_exception : public std::exception
5712838Sgabeblack@google.com{
5812838Sgabeblack@google.com  public:
5912838Sgabeblack@google.com    virtual const char *what() const throw();
6012838Sgabeblack@google.com    virtual bool is_reset() const;
6112838Sgabeblack@google.com
6212838Sgabeblack@google.com  protected:
6312838Sgabeblack@google.com    sc_unwind_exception();
6412838Sgabeblack@google.com    sc_unwind_exception(const sc_unwind_exception &);
6512838Sgabeblack@google.com    virtual ~sc_unwind_exception() throw();
6612838Sgabeblack@google.com};
6712838Sgabeblack@google.com
6812838Sgabeblack@google.comclass sc_process_handle
6912838Sgabeblack@google.com{
7012838Sgabeblack@google.com  public:
7112838Sgabeblack@google.com    sc_process_handle();
7212838Sgabeblack@google.com    sc_process_handle(const sc_process_handle &);
7312838Sgabeblack@google.com    explicit sc_process_handle(sc_object *);
7412838Sgabeblack@google.com    ~sc_process_handle();
7512838Sgabeblack@google.com
7612838Sgabeblack@google.com    bool valid() const;
7712838Sgabeblack@google.com
7812838Sgabeblack@google.com    sc_process_handle &operator = (const sc_process_handle &);
7912838Sgabeblack@google.com    bool operator == (const sc_process_handle &) const;
8012838Sgabeblack@google.com    bool operator != (const sc_process_handle &) const;
8112838Sgabeblack@google.com    bool operator < (const sc_process_handle &) const;
8212838Sgabeblack@google.com    bool swap(sc_process_handle &);
8312838Sgabeblack@google.com
8412838Sgabeblack@google.com    const char *name() const;
8512838Sgabeblack@google.com    sc_curr_proc_kind proc_kind() const;
8612838Sgabeblack@google.com    const std::vector<sc_object *> &get_child_objects() const;
8712838Sgabeblack@google.com    const std::vector<sc_event *> &get_child_events() const;
8812838Sgabeblack@google.com    sc_object *get_parent_object() const;
8912838Sgabeblack@google.com    sc_object *get_process_object() const;
9012838Sgabeblack@google.com    bool dynamic() const;
9112838Sgabeblack@google.com    bool terminated() const;
9212838Sgabeblack@google.com    const sc_event &terminated_event() const;
9312838Sgabeblack@google.com
9412838Sgabeblack@google.com    void suspend(sc_descendent_inclusion_info include_descendants=
9512838Sgabeblack@google.com                 SC_NO_DESCENDANTS);
9612838Sgabeblack@google.com    void resume(sc_descendent_inclusion_info include_descendants=
9712838Sgabeblack@google.com                SC_NO_DESCENDANTS);
9812838Sgabeblack@google.com    void disable(sc_descendent_inclusion_info include_descendants=
9912838Sgabeblack@google.com                 SC_NO_DESCENDANTS);
10012838Sgabeblack@google.com    void enable(sc_descendent_inclusion_info include_descendants=
10112838Sgabeblack@google.com                SC_NO_DESCENDANTS);
10212838Sgabeblack@google.com    void kill(sc_descendent_inclusion_info include_descendants=
10312838Sgabeblack@google.com              SC_NO_DESCENDANTS);
10412838Sgabeblack@google.com    void reset(sc_descendent_inclusion_info include_descendants=
10512838Sgabeblack@google.com               SC_NO_DESCENDANTS);
10612838Sgabeblack@google.com    bool is_unwinding();
10712838Sgabeblack@google.com    const sc_event &reset_event() const;
10812838Sgabeblack@google.com
10912838Sgabeblack@google.com    void sync_reset_on(sc_descendent_inclusion_info include_descendants=
11012838Sgabeblack@google.com                       SC_NO_DESCENDANTS);
11112838Sgabeblack@google.com    void sync_reset_off(sc_descendent_inclusion_info include_descendants=
11212838Sgabeblack@google.com                        SC_NO_DESCENDANTS);
11312838Sgabeblack@google.com
11412838Sgabeblack@google.com    void warn_unimpl(const char *func);
11512838Sgabeblack@google.com    template <typename T>
11612838Sgabeblack@google.com    void throw_it(const T &user_defined_exception,
11712838Sgabeblack@google.com                  sc_descendent_inclusion_info include_descendants=
11812838Sgabeblack@google.com                  SC_NO_DESCENDANTS)
11912838Sgabeblack@google.com    {
12012838Sgabeblack@google.com        warn_unimpl(__PRETTY_FUNCTION__);
12112838Sgabeblack@google.com    }
12212838Sgabeblack@google.com};
12312838Sgabeblack@google.com
12412838Sgabeblack@google.comsc_process_handle sc_get_current_process_handle();
12512838Sgabeblack@google.combool sc_is_unwinding();
12612838Sgabeblack@google.com
12712838Sgabeblack@google.com} // namespace sc_core
12812838Sgabeblack@google.com
12912838Sgabeblack@google.com#endif  //__SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__
130