Line data Source code
1 : #pragma once 2 : 3 : #include "BlockDescriptor.h" 4 : 5 : #include <vector> 6 : 7 : namespace elsa 8 : { 9 : /** 10 : * @brief Class representing a block descriptor whose different blocks may have completely 11 : * different descriptors. 12 : * 13 : * @author Matthias Wieczorek - initial code 14 : * @author David Frank - rewrite 15 : * @author Nikola Dinev - various enhancements 16 : * @author Tobias Lasser - rewrite, modularization, modernization 17 : * 18 : * There are no restrictions whatsoever imposed on the descriptors of different blocks. 19 : * Different blocks may even have different number of dimensions. 20 : * 21 : * The full descriptor will always be one-dimensional, and with a spacing of one. The size of it 22 : * will be the sum of the sizes of all the descriptors, i.e. the sizes returned by 23 : * DataDescriptor::getNumberOfCoefficients() for each descriptor in the list. 24 : */ 25 : class RandomBlocksDescriptor : public BlockDescriptor 26 : { 27 : public: 28 : /** 29 : * @brief Construct a RandomBlocksDescriptor from a list of descriptors 30 : * 31 : * @param[in] blockDescriptors the list of descriptors of each block 32 : * 33 : * @throw InvalidArgumentError if the list is empty 34 : */ 35 : RandomBlocksDescriptor( 36 : const std::vector<std::unique_ptr<DataDescriptor>>& blockDescriptors); 37 : 38 : /** 39 : * @brief Construct a RandomBlocksDescriptor from a list of descriptors 40 : * 41 : * @param[in] blockDescriptors the list of descriptors of each block 42 : * 43 : * @throw InvalidArgumentError if the list is empty 44 : */ 45 : RandomBlocksDescriptor(std::vector<std::unique_ptr<DataDescriptor>>&& blockDescriptors); 46 : 47 : /// make copy constructor deletion explicit 48 : RandomBlocksDescriptor(const RandomBlocksDescriptor&) = delete; 49 : 50 : /// default desctructor 51 689 : ~RandomBlocksDescriptor() override = default; 52 : 53 : /// return the number of blocks 54 : index_t getNumberOfBlocks() const override; 55 : 56 : /// return the DataDescriptor of the i-th block 57 : const DataDescriptor& getDescriptorOfBlock(index_t i) const override; 58 : 59 : /// return the offset to access the data of the i-th block 60 : index_t getOffsetOfBlock(index_t i) const override; 61 : 62 : protected: 63 : /// vector of DataDescriptors describing the individual blocks 64 : std::vector<std::unique_ptr<DataDescriptor>> _blockDescriptors; 65 : 66 : /// vector of the individual block data offsets 67 : IndexVector_t _blockOffsets; 68 : 69 : /// implement the polymorphic clone operation 70 : RandomBlocksDescriptor* cloneImpl() const override; 71 : 72 : /// implement the polymorphic comparison operation 73 : bool isEqual(const DataDescriptor& other) const override; 74 : 75 : private: 76 : /// return the total number of coefficients of the descriptors in the list as an IndexVector 77 : IndexVector_t 78 : determineSize(const std::vector<std::unique_ptr<DataDescriptor>>& blockDescriptors); 79 : }; 80 : } // namespace elsa