C++ Device API Reference Manual
Reference documentation for the Simics C++ Device API.
 
Loading...
Searching...
No Matches
utility.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2021 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_UTILITY_H
17#define SIMICS_UTILITY_H
18
19#include "conf-object.h"
20
21namespace simics {
22
26template <typename IFACE>
28 // See bug 21722, the performance benchmark shows dynamic_cast
29 // is better than cache it by a map
30 auto *iface = dynamic_cast<IFACE*>(from_obj<ConfObject>(obj));
31 if (!iface) {
32 throw std::runtime_error {
33 "The configuration object needs derive from the interface class"
34 };
35 }
36 return iface;
37}
38
45class nocopy {
46 protected:
47 nocopy() {}
49
50 private:
51 nocopy(const nocopy &);
52 const nocopy & operator=(const nocopy &);
53};
54
55} // namespace simics
56
57#endif
struct conf_object conf_object_t
Definition: bank-issue-callbacks-interface.h:23
Prevent copy of classes inheriting from this class by having private copy-constructor and assignment ...
Definition: utility.h:45
nocopy()
Definition: utility.h:47
~nocopy()
Definition: utility.h:48
Definition: attr-value.h:23
IFACE * get_interface(conf_object_t *obj)
Return the Simics C++ interface class from a configuration object.
Definition: utility.h:27