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;
192 IndexTree *indexTree;
199 IndexedDataTree<unsigned int> *indexedDataTree;
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.",