23 #ifndef COM_DAFER45_TBTK_INDEX_DESCRIPTOR 24 #define COM_DAFER45_TBTK_INDEX_DESCRIPTOR 27 #include "TBTK/IndexException.h" 42 enum class Format {None, Ranges, Custom, Dynamic};
152 bool returnNegativeForMissingIndex =
false 183 unsigned int dimensions;
207 NoneFormat noneFormat;
208 RangeFormat rangeFormat;
209 CustomFormat customFormat;
210 DynamicFormat dynamicFormat;
214 Descriptor descriptor;
218 return !(rhs == lhs);
227 format == Format::Ranges,
228 "IndexDescriptor::setDimensions()",
229 "The IndexDescriptor is not of the format Format::Ranges.",
233 std::vector<int> ranges;
234 for(
unsigned int n = 0; n < descriptor.rangeFormat.dimensions; n++)
235 ranges.push_back(descriptor.rangeFormat.ranges[n]);
242 format == Format::Custom,
243 "IndexDescriptor::getIndexTree()",
244 "The IndexDescriptor is not of the format Format::Custom.",
248 return *descriptor.customFormat.indexTree;
253 format == Format::Dynamic,
254 "IndexDescriptor::add()",
255 "The IndexDescriptor is not of the format Format::Dynamic.",
261 !descriptor.dynamicFormat.indexedDataTree->get(dummy, index),
262 "IndexDescriptor::add()",
263 "The IndexDescriptor already contains the Index '" 268 descriptor.dynamicFormat.indexedDataTree->add(
269 descriptor.dynamicFormat.size,
272 descriptor.dynamicFormat.size++;
277 bool returnNegativeForMissingIndex
281 return descriptor.customFormat.indexTree->getLinearIndex(
283 IndexTree::SearchMode::MatchWildcards,
284 returnNegativeForMissingIndex
286 case Format::Dynamic:
288 unsigned int linearIndex;
290 descriptor.dynamicFormat.indexedDataTree->get(
297 else if(returnNegativeForMissingIndex){
302 "IndexDescriptor::getLinearIndex()",
304 "Index not included in the IndexDescriptor '" 312 "IndexDescriptor::getOffset()",
313 "The IndexDescriptor is not of the format" 314 " Format::Custom or Format::Dynamic.",
324 descriptor.customFormat.indexTree->getLinearIndex(
326 IndexTree::SearchMode::StrictMatch,
335 case Format::Dynamic:
339 descriptor.dynamicFormat.indexedDataTree->get(
352 "IndexDescriptor::contains()",
353 "The IndexDescriptor is not of the format" 354 " Format::Custom or Format::Dynamic.",
const IndexTree & getIndexTree() const
Definition: IndexDescriptor.h:240
unsigned int getSize() const
IndexDescriptor & operator=(const IndexDescriptor &rhs)
Definition: IndexException.h:10
Describes the index structure of data stored for several indices.
Definition: IndexDescriptor.h:39
Definition: Serializable.h:43
Data structure for mapping physical indices to a linear index.
virtual std::string serialize(Mode mode) const
std::string toString() const
Definition: Index.h:349
int getLinearIndex(const Index &index, bool returnNegativeForMissingIndex=false) const
Definition: IndexDescriptor.h:275
Data structure for storing data associated with an index.
Format
Definition: IndexDescriptor.h:42
friend bool operator==(const IndexDescriptor &lhs, const IndexDescriptor &rhs)
Data structure for mapping physical indices to linear indices.
Definition: IndexTree.h:35
Physical index.
Definition: Index.h:44
Format getFormat() const
Definition: IndexDescriptor.h:221
friend bool operator!=(const IndexDescriptor &lhs, const IndexDescriptor &rhs)
Definition: IndexDescriptor.h:217
Mode
Definition: Serializable.h:47
std::vector< int > getRanges() const
Definition: IndexDescriptor.h:225
bool contains(const Index &index) const
Definition: IndexDescriptor.h:320
void add(const Index &index)
Definition: IndexDescriptor.h:251
Abstract base class for serializable objects.