SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
instance_counter.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2014 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_INSTANCE_COUNTER_H
17#define SIMICS_SYSTEMC_INSTANCE_COUNTER_H
18
19#include <systemc>
20#include <map>
21
22namespace simics {
23namespace systemc {
24
31template <class T>
33 public:
35 ++m_instances[sc_core::sc_curr_simcontext];
36 }
39 virtual ~InstanceCounter() {
40 --m_instances[sc_core::sc_curr_simcontext];
41 }
42 static int instances() {
43 return m_instances[sc_core::sc_curr_simcontext];
44 }
45
46 private:
47 static std::map<sc_core::sc_simcontext *, int> m_instances;
48};
49
50template<class T> std::map<sc_core::sc_simcontext *, int>
51 InstanceCounter<T>::m_instances;
52
53} // namespace systemc
54} // namespace simics
55
56#endif
Keeps track of (counts) the number of instances for this type of class.
Definition: instance_counter.h:32
static int instances()
Definition: instance_counter.h:42
InstanceCounter()
Definition: instance_counter.h:34
InstanceCounter & operator=(const InstanceCounter &)=delete
InstanceCounter(const InstanceCounter &)=delete
virtual ~InstanceCounter()
Definition: instance_counter.h:39
Definition: pci_bus_interface.h:24