gem5 v24.0.0.0
Loading...
Searching...
No Matches
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"
54
55namespace sc_core
56{
57
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
72void
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
83void
88
89void
94
95void
96sc_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
109 SC_REPORT_WARNING(SC_ID_VECTOR_BIND_EMPTY_, ss.str().c_str());
110}
111
112} // namespace sc_core
sc_object * get_parent_object() const
Definition sc_object.cc:80
const char * name() const
Definition sc_object.cc:44
virtual sc_object * objectCast(void *) const =0
size_type size() const
Definition sc_vector.cc:58
void forceParent() const
Definition sc_vector.cc:84
void unforceParent() const
Definition sc_vector.cc:90
void reportEmpty(const char *kind_, bool empty_dest) const
Definition sc_vector.cc:96
std::vector< void * > objs
Definition sc_vector.hh:176
void checkIndex(size_type index) const
Definition sc_vector.cc:73
const std::vector< sc_object * > & get_elements() const
Definition sc_vector.cc:61
std::vector< sc_object * > elements
Definition sc_vector.hh:180
STL vector class.
Definition stl.hh:37
void ccprintf(cp::Print &print)
Definition cprintf.hh:130
void sc_abort()
Definition sc_report.cc:178
const char SC_ID_OUT_OF_BOUNDS_[]
Definition messages.cc:40
void popParentObj()
Definition object.cc:323
void pushParentObj(sc_core::sc_object *obj)
Definition object.cc:322
#define SC_REPORT_WARNING(msg_type, msg)
#define SC_REPORT_ERROR(msg_type, msg)
std::stringstream ss
Definition trace.test.cc:45

Generated on Tue Jun 18 2024 16:24:07 for gem5 by doxygen 1.11.0