SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
sc_object_simics_adapter.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2015 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_IFACE_SC_OBJECT_SIMICS_ADAPTER_H
17#define SIMICS_SYSTEMC_IFACE_SC_OBJECT_SIMICS_ADAPTER_H
18
21
22#include <systemc-interfaces.h>
23
24#include <string>
25#include <vector>
26
27namespace simics {
28namespace systemc {
29namespace iface {
30
32template<typename TBase, typename TInterface = ScObjectInterface>
33class ScObjectSimicsAdapter : public SimicsAdapter<sc_object_interface_t> {
34 public:
36 : SimicsAdapter<sc_object_interface_t>(
37 SC_OBJECT_INTERFACE, init_iface()) {
38 }
39
40 protected:
41 static attr_value_t sc_print(conf_object_t *obj) {
42 std::vector<std::string> lines =
43 adapter<TBase, TInterface>(obj)->sc_print();
44
45 return vectorToAttr(lines);
46 }
47 static attr_value_t sc_dump(conf_object_t *obj) {
48 std::vector<std::string> lines
49 = adapter<TBase, TInterface>(obj)->sc_dump();
50
51 return vectorToAttr(lines);
52 }
53 static attr_value_t sc_kind(conf_object_t *obj) {
54 return adapter<TBase, TInterface>(obj)->sc_kind();
55 }
56 static const char *sc_name(conf_object_t *obj) {
57 return adapter<TBase, TInterface>(obj)->sc_name();
58 }
59
60 private:
61 static attr_value_t vectorToAttr(const std::vector<std::string> &lines) {
62 attr_value_t list = SIM_alloc_attr_list(lines.size());
63 for (unsigned i = 0; i < lines.size(); ++i)
64 SIM_attr_list_set_item(&list, i,
65 SIM_make_attr_string(lines[i].c_str()));
66
67 return list;
68 }
69 std::vector<std::string> description(conf_object_t *obj,
70 DescriptionType type) {
71 return descriptionBase<TBase, TInterface>(obj, type);
72 }
73 sc_object_interface_t init_iface() {
74 sc_object_interface_t iface = {};
75 iface.sc_print = sc_print;
76 iface.sc_dump = sc_dump;
77 iface.sc_kind = sc_kind;
78 iface.sc_name = sc_name;
79 return iface;
80 }
81};
82
83} // namespace iface
84} // namespace systemc
85} // namespace simics
86
87#endif
Definition: sc_object_simics_adapter.h:33
static const char * sc_name(conf_object_t *obj)
Definition: sc_object_simics_adapter.h:56
ScObjectSimicsAdapter()
Definition: sc_object_simics_adapter.h:35
static attr_value_t sc_print(conf_object_t *obj)
Definition: sc_object_simics_adapter.h:41
static attr_value_t sc_kind(conf_object_t *obj)
Definition: sc_object_simics_adapter.h:53
static attr_value_t sc_dump(conf_object_t *obj)
Definition: sc_object_simics_adapter.h:47
Base class for mapping Simics interface to a C++ interface.
Definition: simics_adapter.h:47
DescriptionType
Definition: description_interface.h:25
Definition: pci_bus_interface.h:24