The Sparta Modeling Framework
Loading...
Searching...
No Matches
ArchDataContainer.hpp
Go to the documentation of this file.
1// <ArchDataContainer> -*- C++ -*-
2
8#pragma once
9
10#include <vector>
11
14
15namespace sparta
16{
17 class ArchData;
18
26 {
27 public:
28
33 friend class ArchData;
34
49 std::vector<ArchData*> getAssociatedArchDatas() {
50 return local_archdatas_;
51 }
52
56 const std::vector<ArchData*> getAssociatedArchDatas() const {
57 return local_archdatas_;
58 }
59
63 virtual std::string getLocation() const = 0;
64
68 ArchDataContainer() = default;
69
74
79
83 virtual ~ArchDataContainer() {}
84
85 private:
86
106 void associateArchData_(ArchData* ad) {
107 if(!ad){
108 throw SpartaException("associateArchData: ArchData pointer must not be nullptr. "
109 "Error at node: ")
110 << getLocation();
111 }
112 // Commented currently because ArchData cannot guarantee this
113 //if(ad->getOwnerNode() != this){
114 // throw SpartaException("associateArchData: ArchData owner node must be set as "
115 // "the TreeNode with which it is being associated. Error at node: ")
116 // << getLocation();
117 //}
118 if(std::find(local_archdatas_.begin(), local_archdatas_.end(), ad)
119 != local_archdatas_.end())
120 {
121 return; // Already in the list
122 }
123
124 local_archdatas_.push_back(ad);
125 }
126
134 void disassociateArchData_(ArchData* ad) {
135 auto itr = std::find(local_archdatas_.begin(), local_archdatas_.end(), ad);
136 if(itr != local_archdatas_.end()){
137 local_archdatas_.erase(itr);
138 }
139 }
140
145 std::vector<ArchData*> local_archdatas_;
146 };
147
148} // namespace sparta
149
Set of macros for Sparta assertions. Caught by the framework.
Exception class for all of Sparta.
Container class for any number of ArchData pointers owned externally.
friend class ArchData
ArchData must be able to invoke associateArchData_ and disassociateArchData_ methods during construct...
ArchDataContainer(ArchDataContainer &)=delete
Copy construction disabled.
const std::vector< ArchData * > getAssociatedArchDatas() const
Const variant of getAssociatedArchDatas.
std::vector< ArchData * > getAssociatedArchDatas()
Retrieves all ArchDatas associated with this TreeNode so that children can use it to allocate their d...
virtual std::string getLocation() const =0
virtual ~ArchDataContainer()
Virtual destructor.
ArchDataContainer(ArchDataContainer &&)=default
Move constructor.
ArchDataContainer()=default
Default constructor.
Contains a set of contiguous line of architectural data which can be referred to by any architected o...
Definition ArchData.hpp:39
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Macros for handling exponential backoff.