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/*
2 © 2016 Intel Corporation
3
4 This software and the related documents are Intel copyrighted materials, and
5 your use of them is governed by the express license under which they were
6 provided to you ("License"). Unless the License provides otherwise, you may
7 not use, modify, copy, publish, distribute, disclose or transmit this software
8 or the related documents without Intel's prior written permission.
9
10 This software and the related documents are provided as is, with no express or
11 implied warranties, other than those that are expressly stated in the License.
12*/
13
14#ifndef SIMICS_SYSTEMC_IFACE_SC_VERSION_SIMICS_ADAPTER_H
15#define SIMICS_SYSTEMC_IFACE_SC_VERSION_SIMICS_ADAPTER_H
16
17#include <simics/base/attr-value.h>
20
21#include <systemc-interfaces.h>
22
23#include <map>
24#include <string>
25#include <vector>
26
27namespace simics {
28namespace systemc {
29namespace iface {
30
32template<typename TBase, typename TInterface = ScVersionInterface>
33class ScVersionSimicsAdapter : public SimicsAdapter<sc_version_interface_t> {
34 public:
35 ScVersionSimicsAdapter() : SimicsAdapter<sc_version_interface_t>(
36 SC_VERSION_INTERFACE, init_iface()) {
37 }
38
39 protected:
40 static const char *kernel_version(conf_object_t *obj) {
41 return adapter<TBase, TInterface>(obj)->kernel_version();
42 }
43 static const char *library_version(conf_object_t *obj) {
44 return adapter<TBase, TInterface>(obj)->library_version();
45 }
46 static const char *library_kernel_version(conf_object_t *obj) {
47 return adapter<TBase, TInterface>(obj)->library_kernel_version();
48 }
49 static attr_value_t versions(conf_object_t *obj) {
50 const std::map<std::string, std::string> *v =
51 adapter<TBase, TInterface>(obj)->versions();
52 unsigned idx = 0;
53 attr_value_t dict = SIM_alloc_attr_dict(v->size());
54 for (const auto &entry : *v) {
55 SIM_attr_dict_set_item(&dict, idx,
56 SIM_make_attr_string(entry.first.c_str()),
57 SIM_make_attr_string(entry.second.c_str()));
58 ++idx;
59 }
60 return dict;
61 }
62
63 private:
64 std::vector<std::string> description(conf_object_t *obj,
65 DescriptionType type) override {
66 return descriptionBase<TBase, TInterface>(obj, type);
67 }
68 sc_version_interface_t init_iface() {
69 sc_version_interface_t iface = {};
70 iface.kernel_version = kernel_version;
71 iface.library_version = library_version;
72 iface.library_kernel_version = library_kernel_version;
73 iface.versions = versions;
74 return iface;
75 }
76};
77
78} // namespace iface
79} // namespace systemc
80} // namespace simics
81
82#endif
Definition: sc_version_simics_adapter.h:33
static attr_value_t versions(conf_object_t *obj)
Definition: sc_version_simics_adapter.h:49
static const char * kernel_version(conf_object_t *obj)
Definition: sc_version_simics_adapter.h:40
ScVersionSimicsAdapter()
Definition: sc_version_simics_adapter.h:35
static const char * library_version(conf_object_t *obj)
Definition: sc_version_simics_adapter.h:43
static const char * library_kernel_version(conf_object_t *obj)
Definition: sc_version_simics_adapter.h:46
Base class for mapping Simics interface to a C++ interface.
Definition: simics_adapter.h:45
DescriptionType
Definition: description_interface.h:23
Definition: adapter.h:79