Commit 61a4c480 authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Adding VolumeDataAccessManagerImpl

stubbed out implementation
parent c6ed24a5
......@@ -12,6 +12,7 @@ set(SOURCE_FILES
VDS/VolumeDataRegion.cpp
VDS/VolumeDataHash.cpp
VDS/VolumeDataPageAccessorImpl.cpp
VDS/VolumeDataAccessManagerImpl.cpp
VDS/VolumeDataPageImpl.cpp
VDS/DimensionGroup.cpp
VDS/ParseVDSJson.cpp
......@@ -29,13 +30,15 @@ set (PRIVATE_HEADER_FILES
VDS/VolumeDataRegion.h
VDS/VolumeDataHash.h
VDS/VolumeDataPageAccessorImpl.h
VDS/VolumeDataAccessManagerImpl.h
VDS/VolumeDataPageImpl.h
VDS/DimensionGroup.h
VDS/Hash.h
Math/Vector.h
VDS/Bitmask.h
VDS/ParseVDSJson.h
VDS/MetadataManager.h)
VDS/MetadataManager.h
VDS/IntrusiveList.h)
set (EXPORTED_HEADER_FILES
OpenVDS/OpenVDS.h
......
......@@ -28,6 +28,7 @@
#include "VDS/VolumeDataLayout.h"
#include "VDS/VolumeDataPageAccessorImpl.h"
#include "VDS/VolumeDataAccessManagerImpl.h"
namespace OpenVDS
{
......@@ -42,9 +43,17 @@ VDSHandle *open(const OpenOptions &options, Error &error)
{
return nullptr;
}
ret->dataAccessManager.reset(new VolumeDataAccessManagerImpl(ret.get()));
return ret.release();
}
VolumeDataLayout *layout(VDSHandle *handle)
{
if (!handle)
return nullptr;
return handle->volumeDataLayout.get();
}
VDSHandle* create(const OpenOptions& options, VolumeDataLayoutDescriptor const &layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const &axisDescriptors, std::vector<VolumeDataChannelDescriptor> const &channelDescriptors, MetadataContainer const &metadataContainer, Error &error)
{
error = Error();
......@@ -63,48 +72,4 @@ void destroy(VDSHandle *handle)
delete handle;
}
static VolumeDataLayer *getVolumeDataLayer(VolumeDataLayout *layout, DimensionsND dimension, int channel, int lod, bool isAllowFailure)
{
if(!layout)
{
fprintf(stderr, "Volume data layout is NULL, this is usually because the VDS setup is invalid");
return nullptr;
}
if(channel > layout->getChannelCount())
{
fprintf(stderr, "Specified channel doesn't exist");
return nullptr;
}
VolumeDataLayer *layer = layout->getBaseLayer(DimensionGroupUtil::getDimensionGroupFromDimensionsND(dimension), channel);
if(!layer && !isAllowFailure)
{
fprintf(stderr, "Specified dimension group doesn't exist");
return nullptr;
}
while(layer && layer->getLod() < lod)
{
layer = layer->getParentLayer();
}
if((!layer || layer->getLayerType() == VolumeDataLayer::Virtual) && !isAllowFailure)
{
fprintf(stderr, "Specified LOD doesn't exist");
}
assert(layer || isAllowFailure);
return (layer->getLayerType() != VolumeDataLayer::Virtual) ? layer : nullptr;
}
VolumeDataPageAccessor *createVolumeDataPageAccessor(VolumeDataLayout *layout, DimensionsND dimension, int lod, int channel, int maxPages, Access access)
{
VolumeDataLayer* layer = getVolumeDataLayer(layout, dimension, channel, lod, true);
if (!layer) return NULL;
return new VolumeDataPageAccessorImpl(layer, maxPages, access == Access::Write);
}
}
......@@ -70,13 +70,15 @@ enum class Access
};
struct VDSHandle;
class VolumeDataLayout;
class VolumeDataAccessManager;
class VolumeDataPageAccessor;
OPENVDS_EXPORT VDSHandle* open(const OpenOptions& options, Error &error);
OPENVDS_EXPORT VDSHandle* create(const OpenOptions& options, VolumeDataLayoutDescriptor const &layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const &axisDescriptors, std::vector<VolumeDataChannelDescriptor> const &channelDescriptors, MetadataContainer const &metadataContainer, Error &error);
OPENVDS_EXPORT void destroy(VDSHandle *handle);
OPENVDS_EXPORT VolumeDataPageAccessor *createVolumeDataPageAccessor(VolumeDataLayout *layout, DimensionsND dimension, int lod, int channel, int maxPages, Access access);
OPENVDS_EXPORT VolumeDataLayout *layout(VDSHandle *handle);
OPENVDS_EXPORT VolumeDataAccessManager *dataAccessManager(VDSHandle *handle);
}
#endif //OPENVDS_H
......@@ -41,35 +41,37 @@ struct IndexRegion
IndexRegion(T min, T max) : min(min), max(max) {}
};
class VolumeDataAccessManager;
class VolumeDataAccessor
{
protected:
VolumeDataAccessor() {}
virtual ~VolumeDataAccessor() {}
public:
class Manager
{
protected:
Manager() {}
virtual ~Manager() {}
public:
virtual void destroyVolumeDataAccessor(VolumeDataAccessor *accessor) = 0;
virtual VolumeDataAccessor *cloneVolumeDataAccessor(VolumeDataAccessor const &accessor) = 0;
};
virtual Manager &getManager() = 0;
// class Manager
// {
// protected:
// Manager() {}
// virtual ~Manager() {}
// public:
// virtual void destroyVolumeDataAccessor(VolumeDataAccessor *accessor) = 0;
//
// virtual VolumeDataAccessor *cloneVolumeDataAccessor(VolumeDataAccessor const &accessor) = 0;
// };
virtual VolumeDataAccessManager &getManager() = 0;
virtual VolumeDataLayout const *getLayout() = 0;
struct IndexOutOfRangeException {};
};
class VolumeDataAccess : public VolumeDataAccessor::Manager
class VolumeDataAccessManager // : public VolumeDataAccessor::Manager
{
protected:
VolumeDataAccess() {}
virtual ~VolumeDataAccess() {}
VolumeDataAccessManager() {}
virtual ~VolumeDataAccessManager() {}
public:
/// <summary>
/// Get the VolumeDataLayout object for a VDS.
......@@ -80,7 +82,7 @@ public:
/// <returns>
/// The VolumeDataLayout object associated with the VDS or NULL if there is no valid VolumeDataLayout.
/// </returns>
virtual VolumeDataLayout const *getVolumeDataLayout(VDSHandle *VDS) const = 0;
virtual VolumeDataLayout const *getVolumeDataLayout() const = 0;
/// <summary>
/// Create a volume data page accessor object for the VDS associated with the given VolumeDataLayout object.
......@@ -533,34 +535,34 @@ public:
virtual float getCompletionFactor(int64_t requestID) = 0;
};
template<> inline VolumeDataReadWriteAccessor<IntVector4, double> *VolumeDataAccess::createVolumeDataAccessor<IntVector4, double> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessorR64 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, double> *VolumeDataAccess::createVolumeDataAccessor<IntVector3, double> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessorR64 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, double> *VolumeDataAccess::createVolumeDataAccessor<IntVector2, double> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessorR64 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, float> *VolumeDataAccess::createVolumeDataAccessor<IntVector4, float> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessorR32 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, float> *VolumeDataAccess::createVolumeDataAccessor<IntVector3, float> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessorR32 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, float> *VolumeDataAccess::createVolumeDataAccessor<IntVector2, float> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessorR32 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, uint64_t> *VolumeDataAccess::createVolumeDataAccessor<IntVector4, uint64_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessorU64 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, uint64_t> *VolumeDataAccess::createVolumeDataAccessor<IntVector3, uint64_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessorU64 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, uint64_t> *VolumeDataAccess::createVolumeDataAccessor<IntVector2, uint64_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessorU64 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, uint32_t> *VolumeDataAccess::createVolumeDataAccessor<IntVector4, uint32_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessorU32 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, uint32_t> *VolumeDataAccess::createVolumeDataAccessor<IntVector3, uint32_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessorU32 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, uint32_t> *VolumeDataAccess::createVolumeDataAccessor<IntVector2, uint32_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessorU32 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, uint16_t> *VolumeDataAccess::createVolumeDataAccessor<IntVector4, uint16_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessorU16 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, uint16_t> *VolumeDataAccess::createVolumeDataAccessor<IntVector3, uint16_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessorU16 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, uint16_t> *VolumeDataAccess::createVolumeDataAccessor<IntVector2, uint16_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessorU16 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, uint8_t> *VolumeDataAccess::createVolumeDataAccessor<IntVector4, uint8_t> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessorU8 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, uint8_t> *VolumeDataAccess::createVolumeDataAccessor<IntVector3, uint8_t> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessorU8 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, uint8_t> *VolumeDataAccess::createVolumeDataAccessor<IntVector2, uint8_t> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessorU8 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, bool> *VolumeDataAccess::createVolumeDataAccessor<IntVector4, bool> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessor1Bit(volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, bool> *VolumeDataAccess::createVolumeDataAccessor<IntVector3, bool> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessor1Bit(volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, bool> *VolumeDataAccess::createVolumeDataAccessor<IntVector2, bool> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessor1Bit(volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadAccessor<FloatVector4, double> *VolumeDataAccess::createInterpolatingVolumeDataAccessor<FloatVector4, double>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue, InterpolationMethod interpolationMethod) { return create4DInterpolatingVolumeDataAccessorR64(volumeDataPageAccessor, replacementNoValue, interpolationMethod); }
template<> inline VolumeDataReadAccessor<FloatVector3, double> *VolumeDataAccess::createInterpolatingVolumeDataAccessor<FloatVector3, double>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue, InterpolationMethod interpolationMethod) { return create3DInterpolatingVolumeDataAccessorR64(volumeDataPageAccessor, replacementNoValue, interpolationMethod); }
template<> inline VolumeDataReadAccessor<FloatVector2, double> *VolumeDataAccess::createInterpolatingVolumeDataAccessor<FloatVector2, double>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue, InterpolationMethod interpolationMethod) { return create2DInterpolatingVolumeDataAccessorR64(volumeDataPageAccessor, replacementNoValue, interpolationMethod); }
template<> inline VolumeDataReadAccessor<FloatVector4, float> *VolumeDataAccess::createInterpolatingVolumeDataAccessor<FloatVector4, float> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue, InterpolationMethod interpolationMethod) { return create4DInterpolatingVolumeDataAccessorR32(volumeDataPageAccessor, replacementNoValue, interpolationMethod); }
template<> inline VolumeDataReadAccessor<FloatVector3, float> *VolumeDataAccess::createInterpolatingVolumeDataAccessor<FloatVector3, float> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue, InterpolationMethod interpolationMethod) { return create3DInterpolatingVolumeDataAccessorR32(volumeDataPageAccessor, replacementNoValue, interpolationMethod); }
template<> inline VolumeDataReadAccessor<FloatVector2, float> *VolumeDataAccess::createInterpolatingVolumeDataAccessor<FloatVector2, float> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue, InterpolationMethod interpolationMethod) { return create2DInterpolatingVolumeDataAccessorR32(volumeDataPageAccessor, replacementNoValue, interpolationMethod); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, double> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector4, double> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessorR64 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, double> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector3, double> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessorR64 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, double> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector2, double> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessorR64 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, float> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector4, float> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessorR32 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, float> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector3, float> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessorR32 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, float> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector2, float> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessorR32 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, uint64_t> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector4, uint64_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessorU64 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, uint64_t> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector3, uint64_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessorU64 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, uint64_t> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector2, uint64_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessorU64 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, uint32_t> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector4, uint32_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessorU32 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, uint32_t> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector3, uint32_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessorU32 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, uint32_t> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector2, uint32_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessorU32 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, uint16_t> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector4, uint16_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessorU16 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, uint16_t> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector3, uint16_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessorU16 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, uint16_t> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector2, uint16_t>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessorU16 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, uint8_t> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector4, uint8_t> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessorU8 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, uint8_t> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector3, uint8_t> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessorU8 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, uint8_t> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector2, uint8_t> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessorU8 (volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector4, bool> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector4, bool> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create4DVolumeDataAccessor1Bit(volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector3, bool> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector3, bool> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create3DVolumeDataAccessor1Bit(volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadWriteAccessor<IntVector2, bool> *VolumeDataAccessManager::createVolumeDataAccessor<IntVector2, bool> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue) { return create2DVolumeDataAccessor1Bit(volumeDataPageAccessor, replacementNoValue); }
template<> inline VolumeDataReadAccessor<FloatVector4, double> *VolumeDataAccessManager::createInterpolatingVolumeDataAccessor<FloatVector4, double>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue, InterpolationMethod interpolationMethod) { return create4DInterpolatingVolumeDataAccessorR64(volumeDataPageAccessor, replacementNoValue, interpolationMethod); }
template<> inline VolumeDataReadAccessor<FloatVector3, double> *VolumeDataAccessManager::createInterpolatingVolumeDataAccessor<FloatVector3, double>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue, InterpolationMethod interpolationMethod) { return create3DInterpolatingVolumeDataAccessorR64(volumeDataPageAccessor, replacementNoValue, interpolationMethod); }
template<> inline VolumeDataReadAccessor<FloatVector2, double> *VolumeDataAccessManager::createInterpolatingVolumeDataAccessor<FloatVector2, double>(VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue, InterpolationMethod interpolationMethod) { return create2DInterpolatingVolumeDataAccessorR64(volumeDataPageAccessor, replacementNoValue, interpolationMethod); }
template<> inline VolumeDataReadAccessor<FloatVector4, float> *VolumeDataAccessManager::createInterpolatingVolumeDataAccessor<FloatVector4, float> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue, InterpolationMethod interpolationMethod) { return create4DInterpolatingVolumeDataAccessorR32(volumeDataPageAccessor, replacementNoValue, interpolationMethod); }
template<> inline VolumeDataReadAccessor<FloatVector3, float> *VolumeDataAccessManager::createInterpolatingVolumeDataAccessor<FloatVector3, float> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue, InterpolationMethod interpolationMethod) { return create3DInterpolatingVolumeDataAccessorR32(volumeDataPageAccessor, replacementNoValue, interpolationMethod); }
template<> inline VolumeDataReadAccessor<FloatVector2, float> *VolumeDataAccessManager::createInterpolatingVolumeDataAccessor<FloatVector2, float> (VolumeDataPageAccessor* volumeDataPageAccessor, float replacementNoValue, InterpolationMethod interpolationMethod) { return create2DInterpolatingVolumeDataAccessorR32(volumeDataPageAccessor, replacementNoValue, interpolationMethod); }
template <typename INDEX>
class VolumeDataRegions
......
......@@ -28,6 +28,7 @@
#include "VDS/VolumeDataLayer.h"
#include "VDS/VolumeDataLayout.h"
#include "VDS/MetadataManager.h"
#include "VDS/VolumeDataAccessManagerImpl.h"
#include "IO/IOManager.h"
#include <vector>
......@@ -69,8 +70,8 @@ struct VDSHandle
std::unique_ptr<VolumeDataLayout>
volumeDataLayout;
std::vector<VolumeDataPageAccessor *>
pageAccessors;
std::unique_ptr<VolumeDataAccessManagerImpl>
dataAccessManager;
std::unique_ptr<IOManager>
ioManager;
LayerMetadataContainer
......
/****************************************************************************
** Copyright 2019 The Open Group
** Copyright 2019 Bluware, Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
****************************************************************************/
#ifndef INTRUSIVELIST_H
#define INTRUSIVELIST_H
#include <assert.h>
namespace OpenVDS
{
template <typename Item>
class IntrusiveListNode
{
public:
Item *m_next;
Item *m_prev;
IntrusiveListNode() : m_next(NULL), m_prev(NULL) {}
};
template <typename Item, IntrusiveListNode<Item> Item::*PtrToNode = &Item::node>
class IntrusiveList
{
public:
typedef IntrusiveListNode<Item> Node;
private:
Item *m_firstItem;
Item *m_lastItem;
#ifdef INTRUSIVE_LIST_MAINTAIN_COUNT
int64_t m_count;
#endif
public:
IntrusiveList()
: m_firstItem(NULL)
, m_lastItem(NULL)
#ifdef INTRUSIVE_LIST_MAINTAIN_COUNT
, m_count(0)
#endif
{}
bool isEmpty() const
{
assert(!!m_firstItem == !!m_lastItem);
return mm_firstItem == NULL;
}
Item *getFirstItem() const { return m_firstItem; }
Item *getLastItem() const { return m_lastItem; }
void remove(Item *item)
{
Node &node = item->*PtrToNode;
if(node.m_next)
{
assert((node.m_next->*PtrToNode).m_prev == item && "The prev pointer of the next element has to point to this element");
(node.m_next->*PtrToNode).m_prev = node.m_prev;
}
else
{
assert(m_lastItem == item && "If next pointer is NULL the item has to be the last in the list");
m_lastItem = node.m_prev;
}
if(node.m_prev)
{
assert((node.m_prev->*PtrToNode).m_next == item && "The next pointer of the prev element has to point to this element");
(node.m_prev->*PtrToNode).m_next = node.m_next;
}
else
{
assert(m_firstItem == item && "If prev pointer is NULL the item has to be the first in the list");
m_firstItem = node.m_next;
}
node.m_prev = NULL;
node.m_next = NULL;
#ifdef INTRUSIVE_LIST_MAINTAIN_COUNT
m_count--;
#endif
}
void insertFirst(Item *item)
{
Node &node = item->*PtrToNode;
assert(!node.m_prev && "The item should be removed from a list before being inserted");
assert(!node.m_next && "The item should be removed from a list before being inserted");
if(!m_firstItem)
{
assert(!m_lastItem && "If there is no first element there can't be a last element");
m_firstItem = item;
m_lastItem = item;
}
else
{
assert(m_lastItem && "If there is a first element there must be a last element");
(m_firstItem->*PtrToNode).m_prev = item;
node.m_next = m_firstItem;
m_firstItem = item;
}
#ifdef INTRUSIVE_LIST_MAINTAIN_COUNT
m_count++;
#endif
}
void insertLast(Item *item)
{
Node &node = item->*PtrToNode;
assert(!node.m_prev && "The item should be removed from a list before being inserted");
assert(!node.m_next && "The item should be removed from a list before being inserted");
if(!m_lastItem)
{
assert(!m_firstItem && "If there is no last element there can't be a first element");
m_lastItem = item;
m_firstItem = item;
}
else
{
assert(m_firstItem && "If there is a last element there must be a first element");
(m_lastItem->*PtrToNode).m_next = item;
node.m_prev = m_lastItem;
m_lastItem = item;
}
#ifdef INTRUSIVE_LIST_MAINTAIN_COUNT
m_count++;
#endif
}
void InsertAfter(Item *item, Item *insertionPoint)
{
Node &node = item->*PtrToNode;
assert(!node.m_prev && "The item should be removed from a list before being inserted");
assert(!node.m_next && "The item should be removed from a list before being inserted");
if(!insertionPoint)
{
insertFirst(item);
}
else if(!((insertionPoint->*PtrToNode).m_next))
{
insertLast(item);
}
else
{
node.m_next = (insertionPoint->*PtrToNode).m_next;
node.m_prev = insertionPoint;
(node.m_prev->*PtrToNode).m_next = item;
(node.m_next->*PtrToNode).m_prev = item;
}
#ifdef INTRUSIVE_LIST_MAINTAIN_COUNT
m_count++;
#endif
}
void insertBefore(Item *item, Item *insertionPoint)
{
Node &node = item->*PtrToNode;
assert(!node.m_prev && "The item should be removed from a list before being inserted");
assert(!node.m_next && "The item should be removed from a list before being inserted");
if(!insertionPoint)
{
InsertLast(item);
}
else if(!(insertionPoint->*PtrToNode).m_prev)
{
InsertFirst(item);
}
else
{
node.m_next = insertionPoint;
node.m_prev = (insertionPoint->*PtrToNode).m_prev;
(node.m_prev->*PtrToNode).m_next = item;
(node.m_next->*PtrToNode).m_prev = item;
}
#ifdef INTRUSIVE_LIST_MAINTAIN_COUNT
m_count++;
#endif
}
};
}
#endif
......@@ -72,13 +72,11 @@ MetadataManager::lockPage(int pageIndex, bool *initiateTransfer)
{
assert(initiateTransfer);
std::unique_lock<std::mutex>
lock(m_mutex);
std::unique_lock<std::mutex> lock(m_mutex);
assert(m_pageMap.size() == m_pageList.size());
MetadataPageMap::iterator
mi = m_pageMap.find(pageIndex);
MetadataPageMap::iterator mi = m_pageMap.find(pageIndex);
if(mi != m_pageMap.end())
{
......@@ -109,14 +107,80 @@ MetadataManager::lockPage(int pageIndex, bool *initiateTransfer)
return page;
}
void MetadataManager::initiateTransfer(MetadataPage *page, std::string const &url, bool verbose, const std::vector<std::string>& headers)
void MetadataManager::initiateTransfer(MetadataPage *page, std::string const &url, bool verbose)
{
std::unique_lock<std::mutex>
lock(m_mutex);
std::unique_lock<std::mutex> lock(m_mutex);
assert(!page->m_valid && !page->m_activeTransfer);
page->m_activeTransfer = m_iomanager->requestObject(url, std::make_shared<MetadataPageTransfer>(page->m_data));
}
void MetadataManager::pageTransferError(MetadataPage *page, const char *msg)
{
std::string
errorString = std::string("Failed to transfer metadata page: ") + std::string(msg);
fprintf(stderr, "OpenVDS: %s\n", errorString.c_str());
// what to do
// std::unique_lock<std::mutex> metadataManagersMutexLock(VDSRemotePlugin::s_metadataManagersMutex);
//
// for(auto pluginInstance : m_references)
// {
// pluginInstance->PageTransferCompleted(page);
// }
//TODO pendingrequestchangedcondition.notify_all
}
void MetadataManager::pageTransferCompleted(MetadataPage *page)
{
std::unique_lock<std::mutex> lock(m_mutex);
page->m_valid = true;
page->m_activeTransfer = nullptr;
lock.unlock();
}
uint8_t const *MetadataManager::getPageEntry(MetadataPage *page, int entryIndex) const
{
assert(page->IsValid());
return &page->m_data[entryIndex * m_metadataStatus.m_chunkMetadataByteSize];
}
void MetadataManager::unlockPage(MetadataPage *page)
{
assert(page);
assert(page->m_lockCount > 0);
std::unique_lock<std::mutex> lock(m_mutex);
assert(m_pageMap.size() == m_pageList.size());
assert(m_pageMap.find(page->m_pageIndex) != m_pageMap.end());
page->m_lockCount--;
if(page->m_lockCount == 0 && !page->m_valid)
{
if(page->m_activeTransfer)
{
page->m_activeTransfer->cancel();
page->m_activeTransfer = nullptr;
}
MetadataPageMap::iterator pageMapIterator = m_pageMap.find(page->m_pageIndex);
MetadataPageList::iterator pageListIterator = pageMapIterator->second;
m_pageMap.erase(pageMapIterator);
m_pageList.erase(pageListIterator);
}
limitPages();
}
}
......@@ -109,9 +109,9 @@ namespace OpenVDS
void pageTransferCompleted(MetadataPage *page);
void initiateTransfer(MetadataPage *page, std::string const &url, bool verbose, const std::vector<std::string>& headers);
void initiateTransfer(MetadataPage *page, std::string const &url, bool verbose);
uint8_t const *GetPageEntry(MetadataPage *page, int entry) const;
uint8_t const *getPageEntry(MetadataPage *page, int entry) const;