SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
simics_lock.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_SIMICS_LOCK_H
17#define SIMICS_SYSTEMC_SIMICS_LOCK_H
18
19#include <simics/base/object-locks.h>
21
22namespace simics {
23namespace systemc {
24
26template <typename T>
28 public:
29 SimicsLock(iface::SimulationInterface *simulation, T *pointer)
30 : lock_(0), pointer_(pointer), object_(simulation->simics_object()) {
31#ifndef SYSTEMC_SERIAL_TD
32 SIM_ACQUIRE_OBJECT(object_, &lock_);
33#endif
34 }
35 virtual ~SimicsLock() {
36#ifndef SYSTEMC_SERIAL_TD
37 SIM_RELEASE_OBJECT(object_, &lock_);
38#endif
39 }
40 SimicsLock(const SimicsLock &) = delete;
41 SimicsLock operator=(const SimicsLock &) = delete;
42 SimicsLock(SimicsLock&&) = default;
44
46 return *pointer_;
47 }
48 const T &operator* () const {
49 return *pointer_;
50 }
52 return pointer_;
53 }
54 const T *operator->() const {
55 return pointer_;
56 }
57 operator bool() const {
58 return pointer_ != NULL;
59 }
60
61 protected:
62 domain_lock_t *lock_;
64 conf_object_t *object_;
65};
66
67} // namespace systemc
68} // namespace simics
69
70#endif
Definition: simics_lock.h:27
T & operator*()
Definition: simics_lock.h:45
SimicsLock & operator=(SimicsLock &&)=default
SimicsLock(const SimicsLock &)=delete
SimicsLock(iface::SimulationInterface *simulation, T *pointer)
Definition: simics_lock.h:29
conf_object_t * object_
Definition: simics_lock.h:64
domain_lock_t * lock_
Definition: simics_lock.h:62
SimicsLock(SimicsLock &&)=default
SimicsLock operator=(const SimicsLock &)=delete
T * operator->()
Definition: simics_lock.h:51
virtual ~SimicsLock()
Definition: simics_lock.h:35
const T * operator->() const
Definition: simics_lock.h:54
T * pointer_
Definition: simics_lock.h:63
Interface to the SystemC simulation.
Definition: simulation_interface.h:27
Definition: pci_bus_interface.h:24