sc_attr.hh revision 12948:cd54609046c4
12972SN/A/* 26328SN/A * Copyright 2018 Google, Inc. 36328SN/A * 45254SN/A * Redistribution and use in source and binary forms, with or without 52972SN/A * modification, are permitted provided that the following conditions are 65254SN/A * met: redistributions of source code must retain the above copyright 75254SN/A * notice, this list of conditions and the following disclaimer; 85254SN/A * redistributions in binary form must reproduce the above copyright 95254SN/A * notice, this list of conditions and the following disclaimer in the 105254SN/A * documentation and/or other materials provided with the distribution; 115254SN/A * neither the name of the copyright holders nor the names of its 125254SN/A * contributors may be used to endorse or promote products derived from 135254SN/A * this software without specific prior written permission. 145254SN/A * 155254SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 162972SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 175254SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 185254SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 195254SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 205254SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 215254SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 225254SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 235254SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 245254SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 255254SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 265254SN/A * 275254SN/A * Authors: Gabe Black 285222SN/A */ 296328SN/A 302972SN/A#ifndef __SYSTEMC_EXT_CORE_SC_ATTR_HH__ 312972SN/A#define __SYSTEMC_EXT_CORE_SC_ATTR_HH__ 326329Sgblack@eecs.umich.edu 336329Sgblack@eecs.umich.edu#include <string> 342972SN/A#include <vector> 3513610Sgiacomo.gabrielli@arm.com 3612109SRekai.GonzalezAlberquilla@arm.comnamespace sc_core 378961Sgblack@eecs.umich.edu{ 3812334Sgabeblack@google.com 396329Sgblack@eecs.umich.educlass sc_attr_base 406328SN/A{ 416329Sgblack@eecs.umich.edu public: 426328SN/A sc_attr_base(const std::string &_name); 436328SN/A sc_attr_base(const sc_attr_base &other); 446328SN/A virtual ~sc_attr_base(); 456328SN/A 466329Sgblack@eecs.umich.edu const std::string &name() const; 476329Sgblack@eecs.umich.edu 489046SAli.Saidi@ARM.com private: 496328SN/A // Disabled 506329Sgblack@eecs.umich.edu sc_attr_base(); 516329Sgblack@eecs.umich.edu sc_attr_base &operator = (const sc_attr_base &); 526329Sgblack@eecs.umich.edu 536329Sgblack@eecs.umich.edu const std::string _name; 546329Sgblack@eecs.umich.edu}; 556328SN/A 566329Sgblack@eecs.umich.edutemplate <class T> 576329Sgblack@eecs.umich.educlass sc_attribute : public sc_attr_base 586329Sgblack@eecs.umich.edu{ 5913610Sgiacomo.gabrielli@arm.com public: 6013610Sgiacomo.gabrielli@arm.com sc_attribute(const std::string &_name) : sc_attr_base(_name) {} 6113610Sgiacomo.gabrielli@arm.com sc_attribute(const std::string &_name, const T &t) : 6213610Sgiacomo.gabrielli@arm.com sc_attr_base(_name), value(t) 639920Syasuko.eckert@amd.com {} 646328SN/A sc_attribute(const sc_attribute<T> &other) : 656329Sgblack@eecs.umich.edu sc_attr_base(other.name()), value(other.value) 668694Sguodeyuan@tsinghua.org.cn {} 676328SN/A virtual ~sc_attribute() {} 686329Sgblack@eecs.umich.edu T value; 696383Sgblack@eecs.umich.edu 706383Sgblack@eecs.umich.edu private: 716383Sgblack@eecs.umich.edu // Disabled 726383Sgblack@eecs.umich.edu sc_attribute() {} 736383Sgblack@eecs.umich.edu sc_attribute<T> &operator = (const sc_attribute<T> &) { return *this; } 746329Sgblack@eecs.umich.edu}; 756329Sgblack@eecs.umich.edu 766329Sgblack@eecs.umich.educlass sc_attr_cltn 776329Sgblack@eecs.umich.edu{ 786329Sgblack@eecs.umich.edu public: 796329Sgblack@eecs.umich.edu typedef sc_attr_base *elem_type; 806329Sgblack@eecs.umich.edu typedef std::vector<elem_type>::iterator iterator; 816329Sgblack@eecs.umich.edu typedef std::vector<elem_type>::const_iterator const_iterator; 826329Sgblack@eecs.umich.edu 836329Sgblack@eecs.umich.edu iterator begin(); 846329Sgblack@eecs.umich.edu const_iterator begin() const; 856329Sgblack@eecs.umich.edu iterator end(); 866329Sgblack@eecs.umich.edu const_iterator end() const; 876329Sgblack@eecs.umich.edu 886329Sgblack@eecs.umich.edu private: 896329Sgblack@eecs.umich.edu // Disabled 906329Sgblack@eecs.umich.edu sc_attr_cltn &operator = (const sc_attr_cltn &); 916329Sgblack@eecs.umich.edu 926383Sgblack@eecs.umich.edu // "Impelemtation defined" members required by the regression tests. 936383Sgblack@eecs.umich.edu public: 946383Sgblack@eecs.umich.edu sc_attr_cltn(); 956383Sgblack@eecs.umich.edu 966383Sgblack@eecs.umich.edu // It's non-standard for this not to be disabled. 976383Sgblack@eecs.umich.edu sc_attr_cltn(const sc_attr_cltn &); 986383Sgblack@eecs.umich.edu 996383Sgblack@eecs.umich.edu ~sc_attr_cltn(); 1006383Sgblack@eecs.umich.edu 1016383Sgblack@eecs.umich.edu bool push_back(sc_attr_base *); 1026383Sgblack@eecs.umich.edu 1036383Sgblack@eecs.umich.edu sc_attr_base *operator [] (const std::string &name); 1046383Sgblack@eecs.umich.edu const sc_attr_base *operator [] (const std::string &name) const; 1056383Sgblack@eecs.umich.edu 1066383Sgblack@eecs.umich.edu sc_attr_base *remove(const std::string &name); 1076329Sgblack@eecs.umich.edu 1086329Sgblack@eecs.umich.edu void remove_all(); 1096329Sgblack@eecs.umich.edu int size() const; 1106329Sgblack@eecs.umich.edu 1116329Sgblack@eecs.umich.edu private: 1126329Sgblack@eecs.umich.edu std::vector<sc_attr_base *> cltn; 1136329Sgblack@eecs.umich.edu}; 1146329Sgblack@eecs.umich.edu 1156329Sgblack@eecs.umich.edu} // namespace sc_core 1166329Sgblack@eecs.umich.edu 1176329Sgblack@eecs.umich.edu#endif //__SYSTEMC_EXT_CORE_SC_ATTR_HH__ 1186329Sgblack@eecs.umich.edu