Initial commit: Final state of the master project

This commit is contained in:
2017-09-16 09:41:37 +02:00
commit 696180d43b
832 changed files with 169717 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
#pragma once
#include "BaseTreePoolBuilder.h"
#include "../../core/Util/BoolArray.h"
class AdaptivePointerPoolBuilder : public BaseTreePoolBuilder
{
public:
AdaptivePointerPoolBuilder(bool useLookupTable, unsigned8 maskSize, unsigned8 size1 = 1, unsigned8 size2 = 2, unsigned8 size3 = 3) : BaseTreePoolBuilder(), mMaskSize(maskSize), mMaskBits(std::vector<unsigned8>{size1, size2, size3}), mUseLookupTable(useLookupTable)
{
assert(maskSize == 1 || maskSize == 2);
assert(size1 <= 4 && size2 <= 4 && size3 <= 4);
}
virtual ~AdaptivePointerPoolBuilder() override {}
std::string GetFullFileName(const std::string& fileName) const override;
protected:
void InitBuild(const BaseTree* tree) override;
void FinishBuild(const BaseTree* tree) override;
bool WordAligned() const override { return false; }
unsigned8 GetBytesPerPointer(const BaseTree* tree, const unsigned32& nodeIndex) const override;
std::vector<unsigned8> WrapPointer(const BaseTree* tree, const unsigned32& nodeIndex, const unsigned32& indexInPool, const unsigned32& pointer) const override;
size_t GetPoolInfoSize(const BaseTree* tree) const override;
std::vector<unsigned8> GetPoolInfo(const BaseTree* tree, const std::vector<size_t>& nodePointers, const std::vector<unsigned32>& nodeOrder) override;
size_t GetAdditionalPoolInfoSize(const BaseTree* tree) const override;
std::vector<unsigned8> GetAdditionalPoolInfo(const BaseTree* tree, const std::vector<size_t>& nodePointers, const std::vector<unsigned32>& nodeOrder) override;
void OrderNodes(const BaseTree* tree, std::vector<unsigned32>& nodeOrder) const override;
static void OrderNodes(const BaseTree* tree, std::vector<unsigned32>& nodeOrder, const std::vector<size_t>& parentCounts);
void ClearVariables();
size_t GetMaxLookupTableSize() const;
unsigned8 GetMinimumSizeOfPointer(const unsigned32& index) const;
// Calculates in which "section" this pointer is. Wraps to pointer to a pointer within that sections and returns the mask.
unsigned32 GetShortenedPointerTo(const unsigned32& pointer, unsigned8& mask) const;
void CalculateEverything(const BaseTree* tree, std::vector<unsigned8>& pointerSizes, std::vector<unsigned8>& pointerSizesPerLevel, std::vector<unsigned32>& levelOffsets, std::vector<size_t>& parentCounts, std::vector<std::vector<unsigned32>>& lookupTableNodesPerLevel, BoolArray& nodeWithinLookupTable) const;
// Size of the mask used to indicate the size of pointers
const unsigned8 mMaskSize;
// Indicates how many bits each index of the mask indicates. Standard is "1, 2, 3", but
// one could image stuff such as "1, 1, 2", when 00 indicates the first 64 nodes, 01 the second 64 nodes, and 10 the next 16K nodes.
const std::vector<unsigned8> mMaskBits;
const bool mUseLookupTable;
// Variables used during the current build
// Pointer sizes for each individual node within the tree
std::vector<unsigned8> mPointerSizes;
// Pointer sizes for direct (byte precision) pointers per level
std::vector<unsigned8> mPointerSizePerLevel;
// Level offsets as the index of the first node in each level
std::vector<unsigned32> mNodeLevelOffsets;
std::vector<unsigned32> mPointerLevelOffsets;
//std::vector<unsigned32> mLevelOffsets;
std::vector<size_t> mParentCounts;
std::vector<std::vector<unsigned32>> mLookupTableNodesPerLevel;
BoolArray mNodeWithinLookupTable;
bool mBuildInitiated = false;
};