object.hh revision 12950
12381SN/A/* 28949Sandreas.hansson@arm.com * Copyright 2018 Google, Inc. 38949Sandreas.hansson@arm.com * 48949Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without 58949Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are 68949Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright 78949Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer; 88949Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright 98949Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the 108949Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution; 118949Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its 128949Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from 138949Sandreas.hansson@arm.com * this software without specific prior written permission. 142592SN/A * 157636Ssteve.reinhardt@amd.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 162381SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 172381SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 182381SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 192381SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 202381SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 212381SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 222381SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 232381SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 242381SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 252381SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 262381SN/A * 272381SN/A * Authors: Gabe Black 282381SN/A */ 292381SN/A 302381SN/A#ifndef __SYSTEMC_CORE_OBJECT_HH__ 312381SN/A#define __SYSTEMC_CORE_OBJECT_HH__ 322381SN/A 332381SN/A#include <string> 342381SN/A#include <vector> 352381SN/A 362381SN/A#include "systemc/ext/core/sc_attr.hh" 372381SN/A#include "systemc/ext/core/sc_object.hh" 382381SN/A 392381SN/Anamespace sc_gem5 402665Ssaidi@eecs.umich.edu{ 412665Ssaidi@eecs.umich.edu 422665Ssaidi@eecs.umich.educlass Object; 432665Ssaidi@eecs.umich.edu 449031Sandreas.hansson@arm.comtypedef std::vector<sc_core::sc_object *> Objects; 452381SN/Atypedef std::vector<sc_core::sc_event *> Events; 462381SN/Atypedef Objects::iterator ObjectsIt; 472381SN/A 482381SN/Aclass Object 492662Sstever@eecs.umich.edu{ 502381SN/A public: 512381SN/A Object(sc_core::sc_object *sc_obj); 522381SN/A Object(sc_core::sc_object *sc_obj, const char *); 532381SN/A Object(sc_core::sc_object *sc_obj, const Object &); 542381SN/A Object &operator = (const Object &); 558229Snate@binkert.org 563348Sbinkertn@umich.edu virtual ~Object(); 573348Sbinkertn@umich.edu 583348Sbinkertn@umich.edu /* 595735Snate@binkert.org * sc_object methods. 604024Sbinkertn@umich.edu */ 615735Snate@binkert.org const char *name() const; 623940Ssaidi@eecs.umich.edu const char *basename() const; 635314Sstever@gmail.com 646216Snate@binkert.org void print(std::ostream & =std::cout) const; 652392SN/A void dump(std::ostream & =std::cout) const; 664167Sbinkertn@umich.edu 672394SN/A const std::vector<sc_core::sc_object *> &get_child_objects() const; 688737Skoansin.tan@gmail.com const std::vector<sc_core::sc_event *> &get_child_events() const; 693349Sbinkertn@umich.edu sc_core::sc_object *get_parent_object() const; 702394SN/A 712812Srdreslin@umich.edu bool add_attribute(sc_core::sc_attr_base &); 722812Srdreslin@umich.edu sc_core::sc_attr_base *get_attribute(const std::string &); 734022Sstever@eecs.umich.edu sc_core::sc_attr_base *remove_attribute(const std::string &); 744022Sstever@eecs.umich.edu void remove_all_attributes(); 755735Snate@binkert.org int num_attributes() const; 765735Snate@binkert.org sc_core::sc_attr_cltn &attr_cltn(); 774022Sstever@eecs.umich.edu const sc_core::sc_attr_cltn &attr_cltn() const; 785735Snate@binkert.org 795735Snate@binkert.org sc_core::sc_simcontext *simcontext() const; 805735Snate@binkert.org 814022Sstever@eecs.umich.edu private: 824022Sstever@eecs.umich.edu sc_core::sc_object *sc_obj; 834022Sstever@eecs.umich.edu 844022Sstever@eecs.umich.edu std::string _basename; 854473Sstever@eecs.umich.edu std::string _name; 865319Sstever@gmail.com 874022Sstever@eecs.umich.edu Objects children; 884022Sstever@eecs.umich.edu Events events; 894022Sstever@eecs.umich.edu sc_core::sc_object *parent; 904022Sstever@eecs.umich.edu ObjectsIt parentIt; 914022Sstever@eecs.umich.edu 924022Sstever@eecs.umich.edu sc_core::sc_attr_cltn cltn; 934022Sstever@eecs.umich.edu}; 949018Sandreas.hansson@arm.com 959018Sandreas.hansson@arm.comextern Objects topLevelObjects; 969018Sandreas.hansson@arm.comextern Objects allObjects; 979018Sandreas.hansson@arm.com 989018Sandreas.hansson@arm.comsc_core::sc_object *findObject( 999018Sandreas.hansson@arm.com const char *name, const Objects &objects=topLevelObjects); 1009018Sandreas.hansson@arm.com 1019018Sandreas.hansson@arm.com} // namespace sc_gem5 1024022Sstever@eecs.umich.edu 1034022Sstever@eecs.umich.edu#endif //__SYSTEMC_CORE_OBJECT_HH__ 1044022Sstever@eecs.umich.edu