| 1 | /* -*- c++ -*- |
|---|
| 2 | * |
|---|
| 3 | * SOCLIB_LGPL_HEADER_BEGIN |
|---|
| 4 | * |
|---|
| 5 | * This file is part of SoCLib, GNU LGPLv2.1. |
|---|
| 6 | * |
|---|
| 7 | * SoCLib is free software; you can redistribute it and/or modify it |
|---|
| 8 | * under the terms of the GNU Lesser General Public License as published |
|---|
| 9 | * by the Free Software Foundation; version 2.1 of the License. |
|---|
| 10 | * |
|---|
| 11 | * SoCLib is distributed in the hope that it will be useful, but |
|---|
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 14 | * Lesser General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU Lesser General Public |
|---|
| 17 | * License along with SoCLib; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|---|
| 19 | * 02110-1301 USA |
|---|
| 20 | * |
|---|
| 21 | * SOCLIB_LGPL_HEADER_END |
|---|
| 22 | * |
|---|
| 23 | * Copyright (c) UPMC, Lip6, Asim |
|---|
| 24 | * Nicolas Pouillon <nipo@ssji.net>, 2007 |
|---|
| 25 | * |
|---|
| 26 | * Maintainers: nipo |
|---|
| 27 | */ |
|---|
| 28 | #ifndef SOCLIB_COMMON_BASE_MODULE_H_ |
|---|
| 29 | #define SOCLIB_COMMON_BASE_MODULE_H_ |
|---|
| 30 | |
|---|
| 31 | #include <systemc> |
|---|
| 32 | #include <string> |
|---|
| 33 | |
|---|
| 34 | namespace soclib { |
|---|
| 35 | |
|---|
| 36 | class BaseModule |
|---|
| 37 | : public sc_core::sc_module |
|---|
| 38 | { |
|---|
| 39 | private: |
|---|
| 40 | std::string m_name; |
|---|
| 41 | |
|---|
| 42 | public: |
|---|
| 43 | BaseModule(const sc_core::sc_module_name &name) |
|---|
| 44 | : sc_core::sc_module(name), m_name((const char *)name) |
|---|
| 45 | { |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | inline const std::string name() const |
|---|
| 49 | { |
|---|
| 50 | return m_name; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | virtual void stateDump() const |
|---|
| 54 | { |
|---|
| 55 | std::cerr << "Warning: state saving not handled in "<<m_name<<std::endl; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | virtual void stateRestore() |
|---|
| 59 | { |
|---|
| 60 | std::cerr << "Warning: state restoring not handled in "<<m_name<<std::endl; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | virtual ~BaseModule() |
|---|
| 64 | { |
|---|
| 65 | } |
|---|
| 66 | }; |
|---|
| 67 | |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | #define SOCLIB_WARNING(x) \ |
|---|
| 71 | do { \ |
|---|
| 72 | static bool warned##__LINE__ = false; \ |
|---|
| 73 | if ( !warned##__LINE__ ) { \ |
|---|
| 74 | std::cerr << "Warning at " << __FILE__ << ':' << __LINE__ \ |
|---|
| 75 | << std::endl << x << std::endl; \ |
|---|
| 76 | warned##__LINE__ = true; \ |
|---|
| 77 | } \ |
|---|
| 78 | } while(0) |
|---|
| 79 | |
|---|
| 80 | #endif /* SOCLIB_COMMON_BASE_MODULE_H_ */ |
|---|
| 81 | |
|---|
| 82 | // Local Variables: |
|---|
| 83 | // tab-width: 4 |
|---|
| 84 | // c-basic-offset: 4 |
|---|
| 85 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
|---|
| 86 | // indent-tabs-mode: nil |
|---|
| 87 | // End: |
|---|
| 88 | |
|---|
| 89 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
|---|
| 90 | |
|---|