gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
sc_vector.cc
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements. See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied. See the License for the specific language governing
16  permissions and limitations under the License.
17 
18  *****************************************************************************/
19 
20 /*
21  * Copyright 2018 Google, Inc.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions are
25  * met: redistributions of source code must retain the above copyright
26  * notice, this list of conditions and the following disclaimer;
27  * redistributions in binary form must reproduce the above copyright
28  * notice, this list of conditions and the following disclaimer in the
29  * documentation and/or other materials provided with the distribution;
30  * neither the name of the copyright holders nor the names of its
31  * contributors may be used to endorse or promote products derived from
32  * this software without specific prior written permission.
33  *
34  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45  *
46  * Authors: Gabe Black
47  */
48 
49 #include <sstream>
50 
51 #include "base/cprintf.hh"
52 #include "systemc/core/object.hh"
56 
57 namespace sc_core
58 {
59 
61 
64 {
65  elements.clear();
66  for (auto ptr: objs) {
67  sc_object *obj_ptr = objectCast(ptr);
68  if (obj_ptr)
69  elements.push_back(obj_ptr);
70  }
71  return elements;
72 }
73 
74 void
76 {
77  if (index >= size()) {
78  std::ostringstream ss;
79  ccprintf(ss, "%s[%d] >= size() = %d", name(), index, size());
81  sc_abort();
82  }
83 }
84 
85 void
87 {
89 }
90 
91 void
93 {
95 }
96 
97 void
98 sc_vector_base::reportEmpty(const char *kind_, bool empty_dest) const
99 {
100  std::ostringstream ss;
101 
102  ss << "target `" << name() << "' " << "(" << kind_ << ") ";
103 
104  if (!size())
105  ss << "not initialised yet";
106  else if (empty_dest)
107  ss << "empty range given";
108  else
109  ss << "empty destination range given";
110 
111  SC_REPORT_WARNING(SC_ID_VECTOR_BIND_EMPTY_, ss.str().c_str());
112 }
113 
114 } // namespace sc_core
void popParentObj()
Definition: object.cc:325
void ccprintf(cp::Print &print)
Definition: cprintf.hh:131
Bitfield< 30, 0 > index
void checkIndex(size_type index) const
Definition: sc_vector.cc:75
void unforceParent() const
Definition: sc_vector.cc:92
virtual sc_object * objectCast(void *) const =0
std::vector< sc_object * > elements
Definition: sc_vector.hh:181
const char * name() const
Definition: sc_object.cc:46
const char SC_ID_VECTOR_BIND_EMPTY_[]
Definition: messages.cc:54
#define SC_REPORT_WARNING(msg_type, msg)
STL vector class.
Definition: stl.hh:40
const char SC_ID_OUT_OF_BOUNDS_[]
Definition: messages.cc:42
sc_object * get_parent_object() const
Definition: sc_object.cc:82
const std::vector< sc_object * > & get_elements() const
Definition: sc_vector.cc:63
void pushParentObj(sc_core::sc_object *obj)
Definition: object.cc:324
Bitfield< 21 > ss
void forceParent() const
Definition: sc_vector.cc:86
size_type size() const
Definition: sc_vector.cc:60
#define SC_REPORT_ERROR(msg_type, msg)
void reportEmpty(const char *kind_, bool empty_dest) const
Definition: sc_vector.cc:98
void sc_abort()
Definition: sc_report.cc:180
std::vector< void * > objs
Definition: sc_vector.hh:177

Generated on Fri Feb 28 2020 16:27:06 for gem5 by doxygen 1.8.13