SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
sc_attribute.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2019 Intel Corporation
5
6 This software and the related documents are Intel copyrighted materials, and
7 your use of them is governed by the express license under which they were
8 provided to you ("License"). Unless the License provides otherwise, you may
9 not use, modify, copy, publish, distribute, disclose or transmit this software
10 or the related documents without Intel's prior written permission.
11
12 This software and the related documents are provided as is, with no express or
13 implied warranties, other than those that are expressly stated in the License.
14*/
15
16#ifndef SIMICS_SYSTEMC_AWARENESS_SC_ATTRIBUTE_H
17#define SIMICS_SYSTEMC_AWARENESS_SC_ATTRIBUTE_H
18
20
21#include <systemc>
22
23#include <string>
24
25namespace simics {
26namespace systemc {
27namespace awareness {
28
30 public:
32 virtual void init(sc_core::sc_object *object,
33 sc_core::sc_attr_base *attr) = 0;
34 virtual int key() const = 0;
35 virtual sc_core::sc_attr_base *attr() = 0;
36 virtual sc_core::sc_attr_base *attr() const = 0;
37};
38
39template<class A>
41 public:
42 explicit ScAttribute(int key) : Attribute(key), attr_(NULL) {}
43 virtual void init(sc_core::sc_object *object, sc_core::sc_attr_base *attr) {
44 object_name_ = object->name();
45 attr_name_ = attr->name();
46 attr_ = attr;
47 }
48 virtual int key() const {
49 return Attribute::key();
50 }
51 virtual Attribute *create() {
52 sc_core::sc_object *obj = sc_core::sc_find_object(object_name_.c_str());
53 if (obj)
54 attr_ = obj->get_attribute(attr_name_);
55 else
56 attr_ = NULL;
57
58 return new ScAttribute<A>(*this);
59 }
60 virtual sc_core::sc_attr_base *attr() {
61 return attr_;
62 }
63 virtual sc_core::sc_attr_base *attr() const {
64 return attr_;
65 }
66 virtual set_error_t set(attr_value_t *val) {
67 A access;
68 if (access.set(attr(), val))
69 return Sim_Set_Ok;
70
71 return Sim_Set_Illegal_Type;
72 }
73 virtual attr_value_t get() const {
74 A access;
75 return access.get(attr());
76 }
77
78 private:
79 std::string object_name_;
80 std::string attr_name_;
81 sc_core::sc_attr_base *attr_;
82};
83
84} // namespace awareness
85} // namespace systemc
86} // namespace simics
87
88#endif
Definition: attribute.h:26
int key() const
Definition: attribute.h:31
virtual sc_core::sc_attr_base * attr() const =0
virtual sc_core::sc_attr_base * attr()=0
virtual ~ScAttributeInterface()
Definition: sc_attribute.h:31
virtual void init(sc_core::sc_object *object, sc_core::sc_attr_base *attr)=0
Definition: sc_attribute.h:40
virtual sc_core::sc_attr_base * attr()
Definition: sc_attribute.h:60
virtual Attribute * create()
Definition: sc_attribute.h:51
virtual attr_value_t get() const
Definition: sc_attribute.h:73
virtual void init(sc_core::sc_object *object, sc_core::sc_attr_base *attr)
Definition: sc_attribute.h:43
virtual set_error_t set(attr_value_t *val)
Definition: sc_attribute.h:66
virtual int key() const
Definition: sc_attribute.h:48
ScAttribute(int key)
Definition: sc_attribute.h:42
virtual sc_core::sc_attr_base * attr() const
Definition: sc_attribute.h:63
Definition: pci_bus_interface.h:24