object.hh revision 12955
112027Sjungma@eit.uni-kl.de/* 212027Sjungma@eit.uni-kl.de * Copyright 2018 Google, Inc. 312027Sjungma@eit.uni-kl.de * 412027Sjungma@eit.uni-kl.de * Redistribution and use in source and binary forms, with or without 512027Sjungma@eit.uni-kl.de * modification, are permitted provided that the following conditions are 612027Sjungma@eit.uni-kl.de * met: redistributions of source code must retain the above copyright 712027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer; 812027Sjungma@eit.uni-kl.de * redistributions in binary form must reproduce the above copyright 912027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer in the 1012027Sjungma@eit.uni-kl.de * documentation and/or other materials provided with the distribution; 1112027Sjungma@eit.uni-kl.de * neither the name of the copyright holders nor the names of its 1212027Sjungma@eit.uni-kl.de * contributors may be used to endorse or promote products derived from 1312027Sjungma@eit.uni-kl.de * this software without specific prior written permission. 1412027Sjungma@eit.uni-kl.de * 1512027Sjungma@eit.uni-kl.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612027Sjungma@eit.uni-kl.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712027Sjungma@eit.uni-kl.de * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812027Sjungma@eit.uni-kl.de * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912027Sjungma@eit.uni-kl.de * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012027Sjungma@eit.uni-kl.de * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112027Sjungma@eit.uni-kl.de * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212027Sjungma@eit.uni-kl.de * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312027Sjungma@eit.uni-kl.de * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412027Sjungma@eit.uni-kl.de * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512027Sjungma@eit.uni-kl.de * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612027Sjungma@eit.uni-kl.de * 2712027Sjungma@eit.uni-kl.de * Authors: Gabe Black 2812027Sjungma@eit.uni-kl.de */ 2912027Sjungma@eit.uni-kl.de 3012027Sjungma@eit.uni-kl.de#ifndef __SYSTEMC_CORE_OBJECT_HH__ 3112027Sjungma@eit.uni-kl.de#define __SYSTEMC_CORE_OBJECT_HH__ 3212027Sjungma@eit.uni-kl.de 3312027Sjungma@eit.uni-kl.de#include <string> 3412027Sjungma@eit.uni-kl.de#include <vector> 3512027Sjungma@eit.uni-kl.de 3612027Sjungma@eit.uni-kl.de#include "systemc/ext/core/sc_attr.hh" 3712027Sjungma@eit.uni-kl.de#include "systemc/ext/core/sc_object.hh" 3812027Sjungma@eit.uni-kl.de 3912027Sjungma@eit.uni-kl.denamespace sc_gem5 4012027Sjungma@eit.uni-kl.de{ 4112027Sjungma@eit.uni-kl.de 4212027Sjungma@eit.uni-kl.declass Object; 4312027Sjungma@eit.uni-kl.de 4412027Sjungma@eit.uni-kl.detypedef std::vector<sc_core::sc_object *> Objects; 4512027Sjungma@eit.uni-kl.detypedef std::vector<sc_core::sc_event *> Events; 4612027Sjungma@eit.uni-kl.detypedef Objects::iterator ObjectsIt; 4712027Sjungma@eit.uni-kl.detypedef Events::iterator EventsIt; 4812027Sjungma@eit.uni-kl.de 4912027Sjungma@eit.uni-kl.declass Object 5012027Sjungma@eit.uni-kl.de{ 5112027Sjungma@eit.uni-kl.de public: 5212027Sjungma@eit.uni-kl.de Object(sc_core::sc_object *_sc_obj); 5312027Sjungma@eit.uni-kl.de Object(sc_core::sc_object *_sc_obj, const char *); 5412027Sjungma@eit.uni-kl.de Object(sc_core::sc_object *_sc_obj, const Object &); 5512027Sjungma@eit.uni-kl.de Object &operator = (const Object &); 5612027Sjungma@eit.uni-kl.de 5712027Sjungma@eit.uni-kl.de virtual ~Object(); 5812027Sjungma@eit.uni-kl.de 5912027Sjungma@eit.uni-kl.de /* 6012027Sjungma@eit.uni-kl.de * sc_object methods. 6112027Sjungma@eit.uni-kl.de */ 6212027Sjungma@eit.uni-kl.de const char *name() const; 6312027Sjungma@eit.uni-kl.de const char *basename() const; 6412027Sjungma@eit.uni-kl.de 6512027Sjungma@eit.uni-kl.de void print(std::ostream & =std::cout) const; 6612027Sjungma@eit.uni-kl.de void dump(std::ostream & =std::cout) const; 6712027Sjungma@eit.uni-kl.de 6812027Sjungma@eit.uni-kl.de const std::vector<sc_core::sc_object *> &get_child_objects() const; 6912027Sjungma@eit.uni-kl.de const std::vector<sc_core::sc_event *> &get_child_events() const; 7012027Sjungma@eit.uni-kl.de sc_core::sc_object *get_parent_object() const; 7112027Sjungma@eit.uni-kl.de 7212027Sjungma@eit.uni-kl.de bool add_attribute(sc_core::sc_attr_base &); 7312027Sjungma@eit.uni-kl.de sc_core::sc_attr_base *get_attribute(const std::string &); 7412027Sjungma@eit.uni-kl.de sc_core::sc_attr_base *remove_attribute(const std::string &); 7512027Sjungma@eit.uni-kl.de void remove_all_attributes(); 7612027Sjungma@eit.uni-kl.de int num_attributes() const; 7712027Sjungma@eit.uni-kl.de sc_core::sc_attr_cltn &attr_cltn(); 7812027Sjungma@eit.uni-kl.de const sc_core::sc_attr_cltn &attr_cltn() const; 7912027Sjungma@eit.uni-kl.de 8012027Sjungma@eit.uni-kl.de sc_core::sc_simcontext *simcontext() const; 8112027Sjungma@eit.uni-kl.de 8212027Sjungma@eit.uni-kl.de static Object * 8312027Sjungma@eit.uni-kl.de getFromScObject(sc_core::sc_object *sc_obj) 8412027Sjungma@eit.uni-kl.de { 8512027Sjungma@eit.uni-kl.de return sc_obj->_gem5_object; 8612027Sjungma@eit.uni-kl.de } 8712027Sjungma@eit.uni-kl.de 8812027Sjungma@eit.uni-kl.de sc_core::sc_object *sc_obj() { return _sc_obj; } 8912027Sjungma@eit.uni-kl.de 9012027Sjungma@eit.uni-kl.de EventsIt addChildEvent(sc_core::sc_event *e); 9112027Sjungma@eit.uni-kl.de void delChildEvent(EventsIt it); 9212027Sjungma@eit.uni-kl.de 9312027Sjungma@eit.uni-kl.de private: 9412027Sjungma@eit.uni-kl.de sc_core::sc_object *_sc_obj; 9512027Sjungma@eit.uni-kl.de 9612027Sjungma@eit.uni-kl.de std::string _basename; 9712027Sjungma@eit.uni-kl.de std::string _name; 9812027Sjungma@eit.uni-kl.de 9912027Sjungma@eit.uni-kl.de Objects children; 10012027Sjungma@eit.uni-kl.de Events events; 10112027Sjungma@eit.uni-kl.de sc_core::sc_object *parent; 10212027Sjungma@eit.uni-kl.de ObjectsIt parentIt; 10312027Sjungma@eit.uni-kl.de 10412027Sjungma@eit.uni-kl.de sc_core::sc_attr_cltn cltn; 10512027Sjungma@eit.uni-kl.de}; 10612027Sjungma@eit.uni-kl.de 10712027Sjungma@eit.uni-kl.deextern Objects topLevelObjects; 10812027Sjungma@eit.uni-kl.deextern Objects allObjects; 10912027Sjungma@eit.uni-kl.de 11012027Sjungma@eit.uni-kl.desc_core::sc_object *findObject( 11112027Sjungma@eit.uni-kl.de const char *name, const Objects &objects=topLevelObjects); 11212027Sjungma@eit.uni-kl.de 11312027Sjungma@eit.uni-kl.de} // namespace sc_gem5 11412027Sjungma@eit.uni-kl.de 11512027Sjungma@eit.uni-kl.de#endif //__SYSTEMC_CORE_OBJECT_HH__ 11612027Sjungma@eit.uni-kl.de