SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
sc_version_simics_adapter.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2016 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_VERSION_SIMICS_ADAPTER_H
17#define SIMICS_SYSTEMC_IFACE_SC_VERSION_SIMICS_ADAPTER_H
18
19#include <simics/base/attr-value.h>
22
23#include <systemc-interfaces.h>
24
25#include <map>
26#include <string>
27#include <vector>
28
29namespace simics {
30namespace systemc {
31namespace iface {
32
34template<typename TBase, typename TInterface = ScVersionInterface>
35class ScVersionSimicsAdapter : public SimicsAdapter<sc_version_interface_t> {
36 public:
37 ScVersionSimicsAdapter() : SimicsAdapter<sc_version_interface_t>(
38 SC_VERSION_INTERFACE, init_iface()) {
39 }
40
41 protected:
42 static const char *kernel_version(conf_object_t *obj) {
43 return adapter<TBase, TInterface>(obj)->kernel_version();
44 }
45 static const char *library_version(conf_object_t *obj) {
46 return adapter<TBase, TInterface>(obj)->library_version();
47 }
48 static const char *library_kernel_version(conf_object_t *obj) {
49 return adapter<TBase, TInterface>(obj)->library_kernel_version();
50 }
51 static attr_value_t versions(conf_object_t *obj) {
52 const std::map<std::string, std::string> *v =
53 adapter<TBase, TInterface>(obj)->versions();
54 unsigned idx = 0;
55 std::map<std::string, std::string>::const_iterator i;
56 attr_value_t dict = SIM_alloc_attr_dict(v->size());
57 for (i = v->begin(); i != v->end(); ++i, ++idx) {
58 SIM_attr_dict_set_item(&dict, idx,
59 SIM_make_attr_string(i->first.c_str()),
60 SIM_make_attr_string(i->second.c_str()));
61 }
62 return dict;
63 }
64
65 private:
66 std::vector<std::string> description(conf_object_t *obj,
67 DescriptionType type) {
68 return descriptionBase<TBase, TInterface>(obj, type);
69 }
70 sc_version_interface_t init_iface() {
71 sc_version_interface_t iface = {};
72 iface.kernel_version = kernel_version;
73 iface.library_version = library_version;
74 iface.library_kernel_version = library_kernel_version;
75 iface.versions = versions;
76 return iface;
77 }
78};
79
80} // namespace iface
81} // namespace systemc
82} // namespace simics
83
84#endif
Definition: sc_version_simics_adapter.h:35
static attr_value_t versions(conf_object_t *obj)
Definition: sc_version_simics_adapter.h:51
static const char * kernel_version(conf_object_t *obj)
Definition: sc_version_simics_adapter.h:42
ScVersionSimicsAdapter()
Definition: sc_version_simics_adapter.h:37
static const char * library_version(conf_object_t *obj)
Definition: sc_version_simics_adapter.h:45
static const char * library_kernel_version(conf_object_t *obj)
Definition: sc_version_simics_adapter.h:48
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