SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
attributes.h
Go to the documentation of this file.
1/*
2 © 2014 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_AWARENESS_ATTRIBUTES_H
15#define SIMICS_SYSTEMC_AWARENESS_ATTRIBUTES_H
16
18
19#include <memory>
20#include <vector>
21
22namespace simics {
23namespace systemc {
24namespace awareness {
25
27 public:
28 template<typename T>
29 static T *defineAttribute() {
30 std::shared_ptr<T> ptr = std::make_shared<T> (key_);
31 attributes_.push_back(ptr);
32 ++key_;
33 return ptr.get();
34 }
35 void init();
36 template<typename T>
37 T *attribute(int key) {
38 return static_cast<T*>(instance_attributes_[key]);
39 }
40
41 Attributes() = default;
42 virtual ~Attributes();
43 Attributes(const Attributes &other) = delete;
44 Attributes& operator=(const Attributes &other) = delete;
45
46 private:
47 static int key_;
48 static std::vector<std::shared_ptr<Attribute> > attributes_;
49 std::vector<Attribute*> instance_attributes_;
50};
51
52} // namespace awareness
53} // namespace systemc
54} // namespace simics
55
56#endif
Definition: attributes.h:26
T * attribute(int key)
Definition: attributes.h:37
Attributes & operator=(const Attributes &other)=delete
static T * defineAttribute()
Definition: attributes.h:29
Attributes(const Attributes &other)=delete
Definition: adapter.h:79