object.hh revision 12950
12686Sksewell@umich.edu/* 25254Sksewell@umich.edu * Copyright 2018 Google, Inc. 35254Sksewell@umich.edu * 42686Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without 55254Sksewell@umich.edu * modification, are permitted provided that the following conditions are 65254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright 75254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer; 85254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright 95254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the 105254Sksewell@umich.edu * documentation and/or other materials provided with the distribution; 115254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its 125254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 135254Sksewell@umich.edu * this software without specific prior written permission. 145254Sksewell@umich.edu * 152686Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 165254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 175254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 185254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 195254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 205254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 215254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 225254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 235254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 245254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 255254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 265254Sksewell@umich.edu * 272706Sksewell@umich.edu * Authors: Gabe Black 285254Sksewell@umich.edu */ 292686Sksewell@umich.edu 302686Sksewell@umich.edu#ifndef __SYSTEMC_CORE_OBJECT_HH__ 314661Sksewell@umich.edu#define __SYSTEMC_CORE_OBJECT_HH__ 322686Sksewell@umich.edu 334661Sksewell@umich.edu#include <string> 344661Sksewell@umich.edu#include <vector> 354661Sksewell@umich.edu 364661Sksewell@umich.edu#include "systemc/ext/core/sc_attr.hh" 374661Sksewell@umich.edu#include "systemc/ext/core/sc_object.hh" 382980Sgblack@eecs.umich.edu 392686Sksewell@umich.edunamespace sc_gem5 405222Sksewell@umich.edu{ 415222Sksewell@umich.edu 425222Sksewell@umich.educlass Object; 435222Sksewell@umich.edu 445222Sksewell@umich.edutypedef std::vector<sc_core::sc_object *> Objects; 455222Sksewell@umich.edutypedef std::vector<sc_core::sc_event *> Events; 462686Sksewell@umich.edutypedef Objects::iterator ObjectsIt; 474661Sksewell@umich.edu 482686Sksewell@umich.educlass Object 495222Sksewell@umich.edu{ 505222Sksewell@umich.edu public: 512686Sksewell@umich.edu Object(sc_core::sc_object *sc_obj); 525222Sksewell@umich.edu Object(sc_core::sc_object *sc_obj, const char *); 535222Sksewell@umich.edu Object(sc_core::sc_object *sc_obj, const Object &); 545222Sksewell@umich.edu Object &operator = (const Object &); 555222Sksewell@umich.edu 565222Sksewell@umich.edu virtual ~Object(); 575222Sksewell@umich.edu 585222Sksewell@umich.edu /* 595222Sksewell@umich.edu * sc_object methods. 605222Sksewell@umich.edu */ 615222Sksewell@umich.edu const char *name() const; 625222Sksewell@umich.edu const char *basename() const; 635222Sksewell@umich.edu 645222Sksewell@umich.edu void print(std::ostream & =std::cout) const; 655222Sksewell@umich.edu void dump(std::ostream & =std::cout) const; 665222Sksewell@umich.edu 675222Sksewell@umich.edu const std::vector<sc_core::sc_object *> &get_child_objects() const; 685222Sksewell@umich.edu const std::vector<sc_core::sc_event *> &get_child_events() const; 695222Sksewell@umich.edu sc_core::sc_object *get_parent_object() const; 705222Sksewell@umich.edu 715222Sksewell@umich.edu bool add_attribute(sc_core::sc_attr_base &); 725222Sksewell@umich.edu sc_core::sc_attr_base *get_attribute(const std::string &); 735222Sksewell@umich.edu sc_core::sc_attr_base *remove_attribute(const std::string &); 745222Sksewell@umich.edu void remove_all_attributes(); 755222Sksewell@umich.edu int num_attributes() const; 762686Sksewell@umich.edu sc_core::sc_attr_cltn &attr_cltn(); 772686Sksewell@umich.edu const sc_core::sc_attr_cltn &attr_cltn() const; 782686Sksewell@umich.edu 792686Sksewell@umich.edu sc_core::sc_simcontext *simcontext() const; 802686Sksewell@umich.edu 812686Sksewell@umich.edu private: 822686Sksewell@umich.edu sc_core::sc_object *sc_obj; 832686Sksewell@umich.edu 842686Sksewell@umich.edu std::string _basename; 852686Sksewell@umich.edu std::string _name; 862686Sksewell@umich.edu 872686Sksewell@umich.edu Objects children; 882686Sksewell@umich.edu Events events; 892686Sksewell@umich.edu sc_core::sc_object *parent; 902686Sksewell@umich.edu ObjectsIt parentIt; 912686Sksewell@umich.edu 922686Sksewell@umich.edu sc_core::sc_attr_cltn cltn; 932686Sksewell@umich.edu}; 942686Sksewell@umich.edu 952686Sksewell@umich.eduextern Objects topLevelObjects; 962686Sksewell@umich.eduextern Objects allObjects; 972686Sksewell@umich.edu 982686Sksewell@umich.edusc_core::sc_object *findObject( 992686Sksewell@umich.edu const char *name, const Objects &objects=topLevelObjects); 1002686Sksewell@umich.edu 1012686Sksewell@umich.edu} // namespace sc_gem5 1022686Sksewell@umich.edu 1032686Sksewell@umich.edu#endif //__SYSTEMC_CORE_OBJECT_HH__ 1042686Sksewell@umich.edu