object.hh revision 12984:02f20eeeb8ce
15625Sgblack@eecs.umich.edu/*
25625Sgblack@eecs.umich.edu * Copyright 2018 Google, Inc.
35625Sgblack@eecs.umich.edu *
45625Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
57087Snate@binkert.org * modification, are permitted provided that the following conditions are
67087Snate@binkert.org * met: redistributions of source code must retain the above copyright
77087Snate@binkert.org * notice, this list of conditions and the following disclaimer;
87087Snate@binkert.org * redistributions in binary form must reproduce the above copyright
97087Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
107087Snate@binkert.org * documentation and/or other materials provided with the distribution;
117087Snate@binkert.org * neither the name of the copyright holders nor the names of its
127087Snate@binkert.org * contributors may be used to endorse or promote products derived from
135625Sgblack@eecs.umich.edu * this software without specific prior written permission.
147087Snate@binkert.org *
157087Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
167087Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
177087Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
187087Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
197087Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
207087Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
217087Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
225625Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
237087Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
245625Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
255625Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
265625Sgblack@eecs.umich.edu *
275625Sgblack@eecs.umich.edu * Authors: Gabe Black
285625Sgblack@eecs.umich.edu */
295625Sgblack@eecs.umich.edu
305625Sgblack@eecs.umich.edu#ifndef __SYSTEMC_CORE_OBJECT_HH__
315625Sgblack@eecs.umich.edu#define __SYSTEMC_CORE_OBJECT_HH__
325625Sgblack@eecs.umich.edu
335625Sgblack@eecs.umich.edu#include <string>
345625Sgblack@eecs.umich.edu#include <vector>
355625Sgblack@eecs.umich.edu
365625Sgblack@eecs.umich.edu#include "systemc/ext/core/sc_attr.hh"
375625Sgblack@eecs.umich.edu#include "systemc/ext/core/sc_object.hh"
385625Sgblack@eecs.umich.edu
395625Sgblack@eecs.umich.edunamespace sc_gem5
405625Sgblack@eecs.umich.edu{
415625Sgblack@eecs.umich.edu
425625Sgblack@eecs.umich.educlass Object;
435625Sgblack@eecs.umich.edu
445625Sgblack@eecs.umich.edutypedef std::vector<sc_core::sc_object *> Objects;
455625Sgblack@eecs.umich.edutypedef std::vector<sc_core::sc_event *> Events;
465625Sgblack@eecs.umich.edutypedef Objects::iterator ObjectsIt;
475625Sgblack@eecs.umich.edutypedef Events::iterator EventsIt;
485625Sgblack@eecs.umich.edu
495625Sgblack@eecs.umich.educlass Object
505625Sgblack@eecs.umich.edu{
515625Sgblack@eecs.umich.edu  public:
528229Snate@binkert.org    Object(sc_core::sc_object *_sc_obj);
535625Sgblack@eecs.umich.edu    Object(sc_core::sc_object *_sc_obj, const char *);
548706Sandreas.hansson@arm.com    Object(sc_core::sc_object *_sc_obj, const Object &);
555625Sgblack@eecs.umich.edu    Object &operator = (const Object &);
565625Sgblack@eecs.umich.edu
575625Sgblack@eecs.umich.edu    virtual ~Object();
585625Sgblack@eecs.umich.edu
595625Sgblack@eecs.umich.edu    /*
605625Sgblack@eecs.umich.edu     * sc_object methods.
615625Sgblack@eecs.umich.edu     */
625625Sgblack@eecs.umich.edu    const char *name() const;
635625Sgblack@eecs.umich.edu    const char *basename() const;
645625Sgblack@eecs.umich.edu
655625Sgblack@eecs.umich.edu    void print(std::ostream & =std::cout) const;
665625Sgblack@eecs.umich.edu    void dump(std::ostream & =std::cout) const;
675625Sgblack@eecs.umich.edu
685625Sgblack@eecs.umich.edu    const std::vector<sc_core::sc_object *> &get_child_objects() const;
695625Sgblack@eecs.umich.edu    const std::vector<sc_core::sc_event *> &get_child_events() const;
705625Sgblack@eecs.umich.edu    sc_core::sc_object *get_parent_object() const;
715625Sgblack@eecs.umich.edu
725625Sgblack@eecs.umich.edu    bool add_attribute(sc_core::sc_attr_base &);
735625Sgblack@eecs.umich.edu    sc_core::sc_attr_base *get_attribute(const std::string &);
745625Sgblack@eecs.umich.edu    sc_core::sc_attr_base *remove_attribute(const std::string &);
755625Sgblack@eecs.umich.edu    void remove_all_attributes();
765625Sgblack@eecs.umich.edu    int num_attributes() const;
775625Sgblack@eecs.umich.edu    sc_core::sc_attr_cltn &attr_cltn();
785625Sgblack@eecs.umich.edu    const sc_core::sc_attr_cltn &attr_cltn() const;
795625Sgblack@eecs.umich.edu
805625Sgblack@eecs.umich.edu    sc_core::sc_simcontext *simcontext() const;
815625Sgblack@eecs.umich.edu
825625Sgblack@eecs.umich.edu    static Object *
835625Sgblack@eecs.umich.edu    getFromScObject(sc_core::sc_object *sc_obj)
845625Sgblack@eecs.umich.edu    {
855625Sgblack@eecs.umich.edu        return sc_obj->_gem5_object;
865625Sgblack@eecs.umich.edu    }
875625Sgblack@eecs.umich.edu
885625Sgblack@eecs.umich.edu    sc_core::sc_object *sc_obj() { return _sc_obj; }
895625Sgblack@eecs.umich.edu
905625Sgblack@eecs.umich.edu    EventsIt addChildEvent(sc_core::sc_event *e);
915625Sgblack@eecs.umich.edu    void delChildEvent(EventsIt it);
925625Sgblack@eecs.umich.edu
935625Sgblack@eecs.umich.edu  private:
945625Sgblack@eecs.umich.edu    sc_core::sc_object *_sc_obj;
955625Sgblack@eecs.umich.edu
968706Sandreas.hansson@arm.com    std::string _basename;
975625Sgblack@eecs.umich.edu    std::string _name;
985625Sgblack@eecs.umich.edu
995625Sgblack@eecs.umich.edu    Objects children;
1005625Sgblack@eecs.umich.edu    Events events;
1015625Sgblack@eecs.umich.edu    sc_core::sc_object *parent;
1025625Sgblack@eecs.umich.edu
1035625Sgblack@eecs.umich.edu    sc_core::sc_attr_cltn cltn;
1045625Sgblack@eecs.umich.edu};
1055625Sgblack@eecs.umich.edu
1065625Sgblack@eecs.umich.eduextern Objects topLevelObjects;
1075625Sgblack@eecs.umich.eduextern Objects allObjects;
1085625Sgblack@eecs.umich.edu
1095625Sgblack@eecs.umich.edusc_core::sc_object *findObject(
1105625Sgblack@eecs.umich.edu        const char *name, const Objects &objects=topLevelObjects);
1115625Sgblack@eecs.umich.edu
1125625Sgblack@eecs.umich.edu} // namespace sc_gem5
1135625Sgblack@eecs.umich.edu
1145625Sgblack@eecs.umich.edu#endif  //__SYSTEMC_CORE_OBJECT_HH__
1155625Sgblack@eecs.umich.edu