gem5  v22.0.0.2
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 
47 #include <sstream>
48 
49 #include "base/cprintf.hh"
50 #include "systemc/core/object.hh"
54 
55 namespace sc_core
56 {
57 
58 sc_vector_base::size_type sc_vector_base::size() const { return objs.size(); }
59 
62 {
63  elements.clear();
64  for (auto ptr: objs) {
65  sc_object *obj_ptr = objectCast(ptr);
66  if (obj_ptr)
67  elements.push_back(obj_ptr);
68  }
69  return elements;
70 }
71 
72 void
74 {
75  if (index >= size()) {
76  std::ostringstream ss;
77  gem5::ccprintf(ss, "%s[%d] >= size() = %d", name(), index, size());
79  sc_abort();
80  }
81 }
82 
83 void
85 {
87 }
88 
89 void
91 {
93 }
94 
95 void
96 sc_vector_base::reportEmpty(const char *kind_, bool empty_dest) const
97 {
98  std::ostringstream ss;
99 
100  ss << "target `" << name() << "' " << "(" << kind_ << ") ";
101 
102  if (!size())
103  ss << "not initialised yet";
104  else if (empty_dest)
105  ss << "empty range given";
106  else
107  ss << "empty destination range given";
108 
110 }
111 
112 } // namespace sc_core
messages.hh
sc_core::sc_vector_base::checkIndex
void checkIndex(size_type index) const
Definition: sc_vector.cc:90
sc_core::sc_vector_base::size
size_type size() const
Definition: sc_vector.cc:75
gem5::MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:47
sc_core
Definition: messages.cc:31
sc_gem5::popParentObj
void popParentObj()
Definition: object.cc:323
std::vector
STL vector class.
Definition: stl.hh:37
sc_core::sc_vector_base::size_type
size_t size_type
Definition: sc_vector.hh:166
sc_core::sc_vector_base::unforceParent
void unforceParent() const
Definition: sc_vector.cc:107
gem5::ccprintf
void ccprintf(cp::Print &print)
Definition: cprintf.hh:130
sc_core::sc_vector_base::elements
std::vector< sc_object * > elements
Definition: sc_vector.hh:179
sc_core::sc_vector_base::objectCast
virtual sc_object * objectCast(void *) const =0
SC_REPORT_ERROR
#define SC_REPORT_ERROR(msg_type, msg)
Definition: sc_report_handler.hh:127
sc_core::sc_vector_base::get_elements
const std::vector< sc_object * > & get_elements() const
Definition: sc_vector.cc:78
sc_core::sc_vector_base::reportEmpty
void reportEmpty(const char *kind_, bool empty_dest) const
Definition: sc_vector.cc:113
cprintf.hh
ss
std::stringstream ss
Definition: trace.test.cc:45
gem5::statistics::size_type
unsigned int size_type
Definition: types.hh:60
sc_gem5::pushParentObj
void pushParentObj(sc_core::sc_object *obj)
Definition: object.cc:322
SC_REPORT_WARNING
#define SC_REPORT_WARNING(msg_type, msg)
Definition: sc_report_handler.hh:123
sc_vector.hh
sc_report_handler.hh
sc_core::SC_ID_VECTOR_BIND_EMPTY_
const char SC_ID_VECTOR_BIND_EMPTY_[]
Definition: messages.cc:52
sc_core::sc_object::name
const char * name() const
Definition: sc_object.cc:44
object.hh
sc_core::sc_object::sc_object
sc_object()
Definition: sc_object.cc:133
sc_core::sc_abort
void sc_abort()
Definition: sc_report.cc:178
sc_core::SC_ID_OUT_OF_BOUNDS_
const char SC_ID_OUT_OF_BOUNDS_[]
Definition: messages.cc:40
sc_core::sc_vector_base::forceParent
void forceParent() const
Definition: sc_vector.cc:101
sc_core::sc_vector_base::objs
std::vector< void * > objs
Definition: sc_vector.hh:175
sc_core::sc_object::get_parent_object
sc_object * get_parent_object() const
Definition: sc_object.cc:80

Generated on Thu Jul 28 2022 13:32:43 for gem5 by doxygen 1.8.17