diff --git a/container/ArrayList.h b/container/ArrayList.h index 59e5eef4..57b2f94d 100644 --- a/container/ArrayList.h +++ b/container/ArrayList.h @@ -6,10 +6,9 @@ #include /** - * A List that stores its values in an array. - * - * The backend is an array that can be allocated by the class itself or supplied via ctor. - * + * @brief A List that stores its values in an array. + * @details The backend is an array that can be allocated + * by the class itself or supplied via ctor. * * @ingroup container */ diff --git a/container/FIFO.h b/container/FIFO.h index 134da9b8..00f56993 100644 --- a/container/FIFO.h +++ b/container/FIFO.h @@ -3,6 +3,11 @@ #include +/** + * @brief Simple First-In-First-Out data structure + * @tparam T Entry Type + * @tparam capacity Maximum capacity + */ template class FIFO { private: diff --git a/container/HybridIterator.h b/container/HybridIterator.h index b34fdfd0..1c56aa13 100644 --- a/container/HybridIterator.h +++ b/container/HybridIterator.h @@ -67,7 +67,7 @@ public: } bool operator==(HybridIterator other) { - return value == other->value; + return value == other.value; } bool operator!=(HybridIterator other) { diff --git a/container/IndexedRingMemoryArray.h b/container/IndexedRingMemoryArray.h index eacfe3e5..4ab174f4 100644 --- a/container/IndexedRingMemoryArray.h +++ b/container/IndexedRingMemoryArray.h @@ -8,20 +8,27 @@ #include #include +/** + * Index is the Type used for the list of indices. + * + * @tparam T Type which destribes the index. Needs to be a child of SerializeIF + * to be able to make it persistent + */ template class Index: public SerializeIF{ /** - * Index is the Type used for the list of indices. The template parameter is the type which describes the index, it needs to be a child of SerializeIF to be able to make it persistent + * */ - static_assert(std::is_base_of::value,"Wrong Type for Index, Type must implement SerializeIF"); + static_assert(std::is_base_of::value, + "Wrong Type for Index, Type must implement SerializeIF"); public: Index():blockStartAddress(0),size(0),storedPackets(0){} - Index(uint32_t startAddress):blockStartAddress(startAddress),size(0),storedPackets(0){ - + Index(uint32_t startAddress):blockStartAddress(startAddress), + size(0),storedPackets(0) { } - void setBlockStartAddress(uint32_t newAddress){ + void setBlockStartAddress(uint32_t newAddress) { this->blockStartAddress = newAddress; } @@ -33,7 +40,7 @@ public: return &indexType; } - T* modifyIndexType(){ + T* modifyIndexType() { return &indexType; } /** @@ -128,26 +135,35 @@ private: }; - +/** + * @brief Indexed Ring Memory Array is a class for a ring memory with indices. + * @details + * It assumes that the newest data comes in last + * It uses the currentWriteBlock as pointer to the current writing position + * The currentReadBlock must be set manually + * @tparam T + */ template class IndexedRingMemoryArray: public SerializeIF, public ArrayList, uint32_t>{ /** - * Indexed Ring Memory Array is a class for a ring memory with indices. It assumes that the newest data comes in last - * It uses the currentWriteBlock as pointer to the current writing position - * The currentReadBlock must be set manually + * */ public: - IndexedRingMemoryArray(uint32_t startAddress, uint32_t size, uint32_t bytesPerBlock, SerializeIF* additionalInfo, - bool overwriteOld) :ArrayList,uint32_t>(NULL,(uint32_t)10,(uint32_t)0),totalSize(size),indexAddress(startAddress),currentReadSize(0),currentReadBlockSizeCached(0),lastBlockToReadSize(0), additionalInfo(additionalInfo),overwriteOld(overwriteOld){ - + IndexedRingMemoryArray(uint32_t startAddress, uint32_t size, uint32_t bytesPerBlock, + SerializeIF* additionalInfo, bool overwriteOld): + ArrayList,uint32_t>(NULL,(uint32_t)10,(uint32_t)0),totalSize(size), + indexAddress(startAddress),currentReadSize(0),currentReadBlockSizeCached(0), + lastBlockToReadSize(0), additionalInfo(additionalInfo),overwriteOld(overwriteOld) + { //Calculate the maximum number of indices needed for this blocksize uint32_t maxNrOfIndices = floor(static_cast(size)/static_cast(bytesPerBlock)); //Calculate the Size needeed for the index itself uint32_t serializedSize = 0; - if(additionalInfo!=NULL){ + if(additionalInfo!=NULL) { serializedSize += additionalInfo->getSerializedSize(); } + //Size of current iterator type Index tempIndex; serializedSize += tempIndex.getSerializedSize(); @@ -162,6 +178,7 @@ public: error << "IndexedRingMemory: Store is too small for index" << std::endl; } uint32_t useableSize = totalSize - serializedSize; + //Update the totalSize for calculations totalSize = useableSize; @@ -178,12 +195,10 @@ public: this->allocated = true; //Check trueNumberOfBlocks - if(trueNumberOfBlocks<1){ + if(trueNumberOfBlocks<1) { error << "IndexedRingMemory: Invalid Number of Blocks: " << trueNumberOfBlocks; } - - //Fill address into index uint32_t address = trueStartAddress; for (typename IndexedRingMemoryArray::Iterator it = this->begin();it!=this->end();++it) { @@ -193,7 +208,6 @@ public: address += bytesPerBlock; } - //Initialize iterators currentWriteBlock = this->begin(); currentReadBlock = this->begin(); @@ -232,10 +246,10 @@ public: (*typeResetFnc)(it->modifyIndexType()); } - /* + /** * Reading + * @param it */ - void setCurrentReadBlock(typename IndexedRingMemoryArray::Iterator it){ currentReadBlock = it; currentReadBlockSizeCached = it->getSize(); @@ -248,6 +262,7 @@ public: lastBlockToRead = currentWriteBlock; lastBlockToReadSize = currentWriteBlock->getSize(); } + /** * Sets the last block to read to this iterator. * Can be used to dump until block x @@ -292,33 +307,39 @@ public: uint32_t getCurrentReadAddress() const { return getAddressOfCurrentReadBlock() + currentReadSize; } + /** - * Adds readSize to the current size and checks if the read has no more data left and advances the read block + * Adds readSize to the current size and checks if the read has no more data + * left and advances the read block. * @param readSize The size that was read * @return Returns true if the read can go on */ bool addReadSize(uint32_t readSize) { - if(currentReadBlock == lastBlockToRead){ + if(currentReadBlock == lastBlockToRead) { //The current read block is the last to read - if((currentReadSize+readSize) return true currentReadSize += readSize; return true; - }else{ + } + else { //Reached end of read -> return false currentReadSize = lastBlockToReadSize; return false; } - }else{ + } + else { //We are not in the last Block - if((currentReadSize + readSize)::Iterator it(currentReadBlock); //Search if any block between this and the last block is not empty @@ -421,13 +442,13 @@ public: T* modifyCurrentWriteBlockIndexType(){ return currentWriteBlock->modifyIndexType(); } + void updatePreviousWriteSize(uint32_t size, uint32_t storedPackets){ typename IndexedRingMemoryArray::Iterator it = getPreviousBlock(currentWriteBlock); it->addSize(size); it->addStoredPackets(storedPackets); } - /** * Checks if the block has enough space for sizeToWrite * @param sizeToWrite The data to be written in the Block @@ -436,7 +457,10 @@ public: bool hasCurrentWriteBlockEnoughSpace(uint32_t sizeToWrite){ typename IndexedRingMemoryArray::Iterator next = getNextWrite(); uint32_t addressOfNextBlock = next->getBlockStartAddress(); - uint32_t availableSize = ((addressOfNextBlock+totalSize) - (getAddressOfCurrentWriteBlock()+getSizeOfCurrentWriteBlock()))%totalSize; + uint32_t availableSize = + ( ( addressOfNextBlock + totalSize ) - + (getAddressOfCurrentWriteBlock() + getSizeOfCurrentWriteBlock())) + % totalSize; return (sizeToWrite < availableSize); } @@ -694,7 +718,4 @@ private: }; - - - #endif /* FRAMEWORK_CONTAINER_INDEXEDRINGMEMORY_H_ */ diff --git a/container/SinglyLinkedList.h b/container/SinglyLinkedList.h index 5c9de6cf..b926bd00 100644 --- a/container/SinglyLinkedList.h +++ b/container/SinglyLinkedList.h @@ -4,7 +4,9 @@ #include #include /** - * \ingroup container + * @brief Linked list data structure, + * each entry has a pointer to the next entry (singly) + * @ingroup container */ template class LinkedElement {