object.hh revision 13179:7445c43d036b
12SN/A/* 21762SN/A * Copyright 2018 Google, Inc. 32SN/A * 42SN/A * Redistribution and use in source and binary forms, with or without 52SN/A * modification, are permitted provided that the following conditions are 62SN/A * met: redistributions of source code must retain the above copyright 72SN/A * notice, this list of conditions and the following disclaimer; 82SN/A * redistributions in binary form must reproduce the above copyright 92SN/A * notice, this list of conditions and the following disclaimer in the 102SN/A * documentation and/or other materials provided with the distribution; 112SN/A * neither the name of the copyright holders nor the names of its 122SN/A * contributors may be used to endorse or promote products derived from 132SN/A * this software without specific prior written permission. 142SN/A * 152SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 162SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 172SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 182SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 192SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 202SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 212SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 222SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 232SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 242SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 252SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 262SN/A * 272665SN/A * Authors: Gabe Black 282665SN/A */ 292665SN/A 302665SN/A#ifndef __SYSTEMC_CORE_OBJECT_HH__ 312665SN/A#define __SYSTEMC_CORE_OBJECT_HH__ 322SN/A 332SN/A#include <string> 341722SN/A#include <vector> 355480Snate@binkert.org 362SN/A#include "systemc/ext/core/sc_attr.hh" 372SN/A#include "systemc/ext/core/sc_object.hh" 38146SN/A 392SN/Anamespace sc_gem5 402SN/A{ 412158SN/A 42146SN/Aclass Object; 431805SN/A 44146SN/Atypedef std::vector<sc_core::sc_object *> Objects; 451717SN/Atypedef std::vector<sc_core::sc_event *> Events; 462680SN/Atypedef Objects::iterator ObjectsIt; 475480Snate@binkert.orgtypedef Events::iterator EventsIt; 482521SN/A 4956SN/Aclass Object 505478SN/A{ 513348SN/A public: 523348SN/A Object(sc_core::sc_object *_sc_obj); 532521SN/A Object(sc_core::sc_object *_sc_obj, const char *); 545480Snate@binkert.org Object(sc_core::sc_object *_sc_obj, const Object &); 551805SN/A Object &operator = (const Object &); 562SN/A 572SN/A virtual ~Object(); 582107SN/A 592SN/A /* 605480Snate@binkert.org * sc_object methods. 615478SN/A */ 624762SN/A const char *name() const; 632SN/A const char *basename() const; 64545SN/A 652521SN/A void print(std::ostream & =std::cout) const; 662521SN/A void dump(std::ostream & =std::cout) const; 672521SN/A 682521SN/A const std::vector<sc_core::sc_object *> &get_child_objects() const; 692SN/A const std::vector<sc_core::sc_event *> &get_child_events() const; 702SN/A sc_core::sc_object *get_parent_object() const; 712SN/A 72926SN/A bool add_attribute(sc_core::sc_attr_base &); 73926SN/A sc_core::sc_attr_base *get_attribute(const std::string &); 74926SN/A sc_core::sc_attr_base *remove_attribute(const std::string &); 75926SN/A void remove_all_attributes(); 76926SN/A int num_attributes() const; 77926SN/A sc_core::sc_attr_cltn &attr_cltn(); 78926SN/A const sc_core::sc_attr_cltn &attr_cltn() const; 794395SN/A 801805SN/A sc_core::sc_simcontext *simcontext() const; 812SN/A 822SN/A static Object * 831634SN/A getFromScObject(sc_core::sc_object *sc_obj) 845480Snate@binkert.org { 851634SN/A return sc_obj->_gem5_object; 862549SN/A } 875714Shsul@eecs.umich.edu 881634SN/A sc_core::sc_object *sc_obj() { return _sc_obj; } 891634SN/A 901634SN/A EventsIt addChildEvent(sc_core::sc_event *e); 911634SN/A void delChildEvent(sc_core::sc_event *e); 921634SN/A 932521SN/A std::string pickUniqueName(std::string name); 941634SN/A 951634SN/A private: 962512SN/A sc_core::sc_object *_sc_obj; 975480Snate@binkert.org 982SN/A std::string _basename; 992SN/A std::string _name; 1002512SN/A 1012512SN/A Objects children; 1022512SN/A Events events; 1032512SN/A sc_core::sc_object *parent; 104540SN/A 1052641SN/A sc_core::sc_attr_cltn cltn; 1062522SN/A}; 1072641SN/A 1082512SN/Astd::string pickUniqueName(::sc_core::sc_object *parent, std::string name); 1092630SN/A 1104986SN/Aextern Objects topLevelObjects; 1112521SN/Aextern Objects allObjects; 1122641SN/A 113873SN/Asc_core::sc_object *findObject( 114873SN/A const char *name, const Objects &objects=topLevelObjects); 115873SN/A 116873SN/A} // namespace sc_gem5 117873SN/A 1182630SN/A#endif //__SYSTEMC_CORE_OBJECT_HH__ 119873SN/A