Commit 0ba20192 authored by Morten Ofstad's avatar Morten Ofstad
Browse files

Merge branch 'feature/morten.ofstad/ErrorHandler' into 'master'

Change the OpenVDSInterface to use an ErrorHandler callback

See merge request !625
parents 81139be9 c474d582
Pipeline #115140 passed with stages
in 108 minutes and 47 seconds
......@@ -26,3 +26,4 @@ cmake-build*
/**/CMakeFiles
binpackage
pytest.ini
/3rdparty/cxxopts-3.0.0
......@@ -788,34 +788,47 @@ class OpenVDSInterfaceImpl : public OpenVDSInterface
OpenVDSInterfaceImpl() {}
~OpenVDSInterfaceImpl() {}
VDSHandle Open(const OpenOptions& options, Error &error);
VDSHandle Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, Error &error);
public:
OpenOptions* CreateOpenOptions(StringWrapper url, StringWrapper connectionString, Error& error) final override;
class ErrorGuard : public Error
{
ErrorHandler m_errorHandler;
Error *m_errorPtr;
public:
ErrorGuard(ErrorHandler errorHandler, Error *errorPtr) : Error(), m_errorHandler(errorHandler), m_errorPtr(errorPtr) {}
~ErrorGuard() noexcept(false) { m_errorHandler(m_errorPtr, code, string.c_str()); }
};
OpenOptions* CreateOpenOptions(StringWrapper url, StringWrapper connectionString, ErrorHandler errorHandler, Error *errorPtr=nullptr) final override;
bool IsSupportedProtocol(StringWrapper url) final override;
VDSHandle Open(StringWrapper url, StringWrapper connectionString, Error& error) final override;
VDSHandle OpenWithAdaptiveCompressionTolerance(StringWrapper url, StringWrapper connectionString, float waveletAdaptiveTolerance, Error& error) final override;
VDSHandle OpenWithAdaptiveCompressionRatio(StringWrapper url, StringWrapper connectionString, float waveletAdaptiveRatio, Error& error) final override;
VDSHandle Open(const OpenOptions& options, Error& error) final override;
VDSHandle Open(IOManager*ioManager, Error &error) final override;
VDSHandle Open(StringWrapper url, StringWrapper connectionString, ErrorHandler errorHandler, Error *errorPtr=nullptr) final override;
VDSHandle OpenWithAdaptiveCompressionTolerance(StringWrapper url, StringWrapper connectionString, float waveletAdaptiveTolerance, ErrorHandler errorHandler, Error *errorPtr=nullptr) final override;
VDSHandle OpenWithAdaptiveCompressionRatio(StringWrapper url, StringWrapper connectionString, float waveletAdaptiveRatio, ErrorHandler errorHandler, Error *errorPtr=nullptr) final override;
VDSHandle Open(const OpenOptions& options, ErrorHandler errorHandler, Error *errorPtr=nullptr) final override;
VDSHandle Open(IOManager*ioManager, ErrorHandler errorHandler, Error *errorPtr=nullptr) final override;
bool IsCompressionMethodSupported(CompressionMethod compressionMethod) final override;
VDSHandle Create(StringWrapper url, StringWrapper connectionString, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, Error& error) final override;
VDSHandle Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, Error& error) final override;
VDSHandle Create(IOManager* ioManager, VolumeDataLayoutDescriptor const &layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const &metadata, CompressionMethod compressionMethod, float compressionTolerance, Error &error) final override;
VDSHandle Create(StringWrapper url, StringWrapper connectionString, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, ErrorHandler errorHandler, Error *errorPtr=nullptr) final override;
VDSHandle Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, ErrorHandler errorHandler, Error *errorPtr=nullptr) final override;
VDSHandle Create(IOManager* ioManager, VolumeDataLayoutDescriptor const &layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const &metadata, CompressionMethod compressionMethod, float compressionTolerance, ErrorHandler errorHandler, Error *errorPtr=nullptr) final override;
VolumeDataLayout *GetLayout(VDSHandle handle) final override;
IVolumeDataAccessManager *GetAccessManagerInterface(VDSHandle handle) final override;
CompressionMethod GetCompressionMethod(VDSHandle handle) final override;
float GetCompressionTolerance(VDSHandle handle) final override;
void Close(VDSHandle handle) final override;
void Close(VDSHandle handle, Error &error) final override;
void Close(VDSHandle handle, ErrorHandler errorHandler, Error *errorPtr=nullptr) final override;
void RetryableClose(VDSHandle handle) final override;
void RetryableClose(VDSHandle handle, Error &error) final override;
void RetryableClose(VDSHandle handle, ErrorHandler errorHandler, Error *errorPtr=nullptr) final override;
GlobalState *GetGlobalState() final override;
const char *GetOpenVDSName() final override;
const char *GetOpenVDSVersion() final override;
const char *GetOpenVDSRevision() final override;
};
OpenOptions* OpenVDSInterfaceImpl::CreateOpenOptions(StringWrapper urlWrapper, StringWrapper connectionStringWrapper, Error& error)
OpenOptions* OpenVDSInterfaceImpl::CreateOpenOptions(StringWrapper urlWrapper, StringWrapper connectionStringWrapper, ErrorHandler errorHandler, Error *errorPtr)
{
ErrorGuard error(errorHandler, errorPtr);
return OpenVDS::CreateOpenOptions(urlWrapper, connectionStringWrapper, error);
}
......@@ -830,18 +843,20 @@ bool OpenVDSInterfaceImpl::IsSupportedProtocol(StringWrapper url)
return false;
}
VDSHandle OpenVDSInterfaceImpl::Open(StringWrapper url, StringWrapper connectionString, Error& error)
VDSHandle OpenVDSInterfaceImpl::Open(StringWrapper url, StringWrapper connectionString, ErrorHandler errorHandler, Error *errorPtr)
{
std::unique_ptr<OpenOptions> openOptions(CreateOpenOptions(url, connectionString, error));
ErrorGuard error(errorHandler, errorPtr);
std::unique_ptr<OpenOptions> openOptions(OpenVDS::CreateOpenOptions(url, connectionString, error));
if (error.code || !openOptions)
return nullptr;
return Open(*(openOptions.get()), error);
}
VDSHandle OpenVDSInterfaceImpl::OpenWithAdaptiveCompressionTolerance(StringWrapper url, StringWrapper connectionString, float waveletAdaptiveTolerance, Error& error)
VDSHandle OpenVDSInterfaceImpl::OpenWithAdaptiveCompressionTolerance(StringWrapper url, StringWrapper connectionString, float waveletAdaptiveTolerance, ErrorHandler errorHandler, Error *errorPtr)
{
std::unique_ptr<OpenOptions> openOptions(CreateOpenOptions(url, connectionString, error));
ErrorGuard error(errorHandler, errorPtr);
std::unique_ptr<OpenOptions> openOptions(OpenVDS::CreateOpenOptions(url, connectionString, error));
if (error.code || !openOptions)
return nullptr;
......@@ -851,9 +866,10 @@ VDSHandle OpenVDSInterfaceImpl::OpenWithAdaptiveCompressionTolerance(StringWrapp
return Open(*(openOptions.get()), error);
}
VDSHandle OpenVDSInterfaceImpl::OpenWithAdaptiveCompressionRatio(StringWrapper url, StringWrapper connectionString, float waveletAdaptiveRatio, Error& error)
VDSHandle OpenVDSInterfaceImpl::OpenWithAdaptiveCompressionRatio(StringWrapper url, StringWrapper connectionString, float waveletAdaptiveRatio, ErrorHandler errorHandler, Error *errorPtr)
{
std::unique_ptr<OpenOptions> openOptions(CreateOpenOptions(url, connectionString, error));
ErrorGuard error(errorHandler, errorPtr);
std::unique_ptr<OpenOptions> openOptions(OpenVDS::CreateOpenOptions(url, connectionString, error));
if (error.code || !openOptions)
return nullptr;
......@@ -863,10 +879,10 @@ VDSHandle OpenVDSInterfaceImpl::OpenWithAdaptiveCompressionRatio(StringWrapper u
return Open(*(openOptions.get()), error);
}
VDSHandle OpenVDSInterfaceImpl::Open(IOManager *ioManager, Error& error)
VDSHandle OpenVDSInterfaceImpl::Open(IOManager *ioManager, ErrorHandler errorHandler, Error *errorPtr)
{
ErrorGuard error(errorHandler, errorPtr);
std::unique_ptr<VDS> ret(new VDS());
error = Error();
if(Init(ret.get(), new VolumeDataStoreIOManager(*ret, ioManager), error))
{
......@@ -882,7 +898,6 @@ VDS *OpenVDSInterfaceImpl::Open(const OpenOptions &options, Error &error)
{
std::unique_ptr<VDS> ret(new VDS());
std::unique_ptr<VolumeDataStore> volumeDataStore;
error = Error();
if(options.connectionType != OpenOptions::VDSFile)
{
......@@ -915,6 +930,12 @@ VDS *OpenVDSInterfaceImpl::Open(const OpenOptions &options, Error &error)
}
}
VDS *OpenVDSInterfaceImpl::Open(const OpenOptions &options, ErrorHandler errorHandler, Error *errorPtr)
{
ErrorGuard error(errorHandler, errorPtr);
return Open(options, error);
}
VolumeDataLayout *OpenVDSInterfaceImpl::GetLayout(VDS *vds)
{
if (!vds)
......@@ -934,10 +955,10 @@ bool OpenVDSInterfaceImpl::IsCompressionMethodSupported(CompressionMethod compre
return VolumeDataStore::IsCompressionMethodSupported(compressionMethod);
}
VDSHandle OpenVDSInterfaceImpl::Create(IOManager *ioManager, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, Error& error)
VDSHandle OpenVDSInterfaceImpl::Create(IOManager *ioManager, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, ErrorHandler errorHandler, Error *errorPtr)
{
ErrorGuard error(errorHandler, errorPtr);
std::unique_ptr<VDS> ret(new VDS());
error = Error();
if(Init(ret.get(), new VolumeDataStoreIOManager(*ret, ioManager), layoutDescriptor, axisDescriptors, channelDescriptors, metadata, compressionMethod, compressionTolerance, error))
{
......@@ -949,20 +970,20 @@ VDSHandle OpenVDSInterfaceImpl::Create(IOManager *ioManager, VolumeDataLayoutDes
}
}
VDSHandle OpenVDSInterfaceImpl::Create(StringWrapper url, StringWrapper connectionString, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, Error& error)
VDSHandle OpenVDSInterfaceImpl::Create(StringWrapper url, StringWrapper connectionString, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, ErrorHandler errorHandler, Error *errorPtr)
{
std::unique_ptr<OpenOptions> openOptions(CreateOpenOptions(url, connectionString, error));
ErrorGuard error(errorHandler, errorPtr);
std::unique_ptr<OpenOptions> openOptions(OpenVDS::CreateOpenOptions(url, connectionString, error));
if (error.code || !openOptions)
return nullptr;
return Create(*openOptions, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, compressionMethod, compressionTolerance, error);
}
VDSHandle OpenVDSInterfaceImpl::Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, Error& error)
VDSHandle OpenVDSInterfaceImpl::Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, Error &error)
{
std::unique_ptr<VDS> ret(new VDS());
std::unique_ptr<VolumeDataStore> volumeDataStore;
error = Error();
if(options.connectionType != OpenOptions::VDSFile)
{
......@@ -990,6 +1011,12 @@ VDSHandle OpenVDSInterfaceImpl::Create(const OpenOptions& options, VolumeDataLay
}
}
VDSHandle OpenVDSInterfaceImpl::Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, ErrorHandler errorHandler, Error *errorPtr)
{
ErrorGuard error(errorHandler, errorPtr);
return Create(options, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, compressionMethod, compressionTolerance, error);
}
CompressionMethod OpenVDSInterfaceImpl::GetCompressionMethod(VDSHandle handle)
{
return handle->volumeDataLayout->GetCompressionMethod();
......@@ -1014,11 +1041,13 @@ void OpenVDSInterfaceImpl::Close(VDS *vds)
}
}
void OpenVDSInterfaceImpl::Close(VDS *vds, Error &error)
void OpenVDSInterfaceImpl::Close(VDS *vds, ErrorHandler errorHandler, Error *errorPtr)
{
error = Error();
ErrorGuard error(errorHandler, errorPtr);
if (!vds)
return;
vds->volumeDataStore->Close(error);
vds->accessManager->Invalidate();
delete vds;
......@@ -1038,9 +1067,9 @@ void OpenVDSInterfaceImpl::RetryableClose(VDS *vds)
delete vds;
}
void OpenVDSInterfaceImpl::RetryableClose(VDS *vds, Error &error)
void OpenVDSInterfaceImpl::RetryableClose(VDS *vds, ErrorHandler errorHandler, Error *errorPtr)
{
error = Error();
ErrorGuard error(errorHandler, errorPtr);
if (!vds)
return;
if(vds->volumeDataStore->Close(error))
......
......@@ -602,7 +602,7 @@ typedef VDSError Error;
/// with url and string instead if this is not needed.
/// </returns>
inline OpenOptions* CreateOpenOptions(std::string url, std::string connectionString, Error& error) { return GetOpenVDSInterface(OPENVDS_VERSION).CreateOpenOptions(url, connectionString, error); }
inline OpenOptions* CreateOpenOptions(std::string url, std::string connectionString, Error& error) { return GetOpenVDSInterface(OPENVDS_VERSION).CreateOpenOptions(url, connectionString, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error); }
/// <summary>
/// Verifies that the url is a supported protocol
......@@ -629,7 +629,7 @@ inline bool IsSupportedProtocol(std::string url) { return GetOpenVDSInterface(OP
/// <returns>
/// The VDS handle that can be used to get the VolumeDataLayout and the VolumeDataAccessManager
/// </returns>
inline VDSHandle Open(std::string url, std::string connectionString, Error& error) { return GetOpenVDSInterface(OPENVDS_VERSION).Open(url, connectionString, error); }
inline VDSHandle Open(std::string url, std::string connectionString, Error& error) { return GetOpenVDSInterface(OPENVDS_VERSION).Open(url, connectionString, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error); }
/// <summary>
/// Open an existing VDS with adaptive compression tolerance.
......@@ -652,7 +652,7 @@ inline VDSHandle Open(std::string url, std::string connectionString, Error& erro
/// <returns>
/// The VDS handle that can be used to get the VolumeDataLayout and the VolumeDataAccessManager
/// </returns>
inline VDSHandle OpenWithAdaptiveCompressionTolerance(std::string url, std::string connectionString, float waveletAdaptiveTolerance, Error& error) { return GetOpenVDSInterface(OPENVDS_VERSION).OpenWithAdaptiveCompressionTolerance(url, connectionString, waveletAdaptiveTolerance, error); }
inline VDSHandle OpenWithAdaptiveCompressionTolerance(std::string url, std::string connectionString, float waveletAdaptiveTolerance, Error& error) { return GetOpenVDSInterface(OPENVDS_VERSION).OpenWithAdaptiveCompressionTolerance(url, connectionString, waveletAdaptiveTolerance, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error); }
/// <summary>
/// Open an existing VDS with adaptive compression ratio.
......@@ -676,7 +676,7 @@ inline VDSHandle OpenWithAdaptiveCompressionTolerance(std::string url, std::stri
/// <returns>
/// The VDS handle that can be used to get the VolumeDataLayout and the VolumeDataAccessManager
/// </returns>
inline VDSHandle OpenWithAdaptiveCompressionRatio(std::string url, std::string connectionString, float waveletAdaptiveRatio, Error& error) { return GetOpenVDSInterface(OPENVDS_VERSION).OpenWithAdaptiveCompressionRatio(url, connectionString, waveletAdaptiveRatio, error); }
inline VDSHandle OpenWithAdaptiveCompressionRatio(std::string url, std::string connectionString, float waveletAdaptiveRatio, Error& error) { return GetOpenVDSInterface(OPENVDS_VERSION).OpenWithAdaptiveCompressionRatio(url, connectionString, waveletAdaptiveRatio, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error); }
/// <summary>
/// Open an existing VDS.
......@@ -692,7 +692,7 @@ inline VDSHandle OpenWithAdaptiveCompressionRatio(std::string url, std::string c
/// <returns>
/// The VDS handle that can be used to get the VolumeDataLayout and the VolumeDataAccessManager
/// </returns>
inline VDSHandle Open(std::string url, Error& error) { return GetOpenVDSInterface(OPENVDS_VERSION).Open(url, std::string(), error); }
inline VDSHandle Open(std::string url, Error& error) { return GetOpenVDSInterface(OPENVDS_VERSION).Open(url, std::string(), [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error); }
/// <summary>
/// Open an existing VDS
......@@ -706,7 +706,7 @@ inline VDSHandle Open(std::string url, Error& error) { return GetOpenVDSInterfac
/// <returns>
/// The VDS handle that can be used to get the VolumeDataLayout and the VolumeDataAccessManager
/// </returns>
inline VDSHandle Open(const OpenOptions& options, Error& error) { return GetOpenVDSInterface(OPENVDS_VERSION).Open(options, error); }
inline VDSHandle Open(const OpenOptions& options, Error& error) { return GetOpenVDSInterface(OPENVDS_VERSION).Open(options, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error); }
/// <summary>
/// Open an existing VDS
......@@ -720,7 +720,7 @@ inline VDSHandle Open(const OpenOptions& options, Error& error) { return GetOpen
/// <returns>
/// The VDS handle that can be used to get the VolumeDataLayout and the VolumeDataAccessManager
/// </returns>
inline VDSHandle Open(IOManager*ioManager, Error &error) { return GetOpenVDSInterface(OPENVDS_VERSION).Open(ioManager, error); }
inline VDSHandle Open(IOManager*ioManager, Error &error) { return GetOpenVDSInterface(OPENVDS_VERSION).Open(ioManager, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error); }
/// <summary>
/// Check if a compression method is supported.
......@@ -759,7 +759,7 @@ inline bool IsCompressionMethodSupported(CompressionMethod compressionMethod) {
/// </returns>
inline VDSHandle Create(std::string url, std::string connectionString, VolumeDataLayoutDescriptor const& layoutDescriptor, std::vector<VolumeDataAxisDescriptor> axisDescriptors, std::vector<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, Error& error)
{
return GetOpenVDSInterface(OPENVDS_VERSION).Create(url, connectionString, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, compressionMethod, compressionTolerance, error);
return GetOpenVDSInterface(OPENVDS_VERSION).Create(url, connectionString, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, compressionMethod, compressionTolerance, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error);
}
/// <summary>
......@@ -781,7 +781,7 @@ inline VDSHandle Create(std::string url, std::string connectionString, VolumeDat
/// </returns>
inline VDSHandle Create(std::string url, std::string connectionString, VolumeDataLayoutDescriptor const& layoutDescriptor, std::vector<VolumeDataAxisDescriptor> axisDescriptors, std::vector<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, Error& error)
{
return GetOpenVDSInterface(OPENVDS_VERSION).Create(url, connectionString, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, CompressionMethod::None, 0, error);
return GetOpenVDSInterface(OPENVDS_VERSION).Create(url, connectionString, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, CompressionMethod::None, 0, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error);
}
/// <summary>
......@@ -806,7 +806,7 @@ inline VDSHandle Create(std::string url, std::string connectionString, VolumeDat
/// </returns>
inline VDSHandle Create(std::string url, VolumeDataLayoutDescriptor const& layoutDescriptor, std::vector<VolumeDataAxisDescriptor> axisDescriptors, std::vector<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, Error& error)
{
return GetOpenVDSInterface(OPENVDS_VERSION).Create(url, std::string(), layoutDescriptor, axisDescriptors, channelDescriptors, metadata, compressionMethod, compressionTolerance, error);
return GetOpenVDSInterface(OPENVDS_VERSION).Create(url, std::string(), layoutDescriptor, axisDescriptors, channelDescriptors, metadata, compressionMethod, compressionTolerance, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error);
}
/// <summary>
......@@ -825,7 +825,7 @@ inline VDSHandle Create(std::string url, VolumeDataLayoutDescriptor const& layou
/// </returns>
inline VDSHandle Create(std::string url, VolumeDataLayoutDescriptor const& layoutDescriptor, std::vector<VolumeDataAxisDescriptor> axisDescriptors, std::vector<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, Error& error)
{
return GetOpenVDSInterface(OPENVDS_VERSION).Create(url, std::string(), layoutDescriptor, axisDescriptors, channelDescriptors, metadata, CompressionMethod::None, 0, error);
return GetOpenVDSInterface(OPENVDS_VERSION).Create(url, std::string(), layoutDescriptor, axisDescriptors, channelDescriptors, metadata, CompressionMethod::None, 0, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error);
}
/// <summary>
......@@ -848,7 +848,7 @@ inline VDSHandle Create(std::string url, VolumeDataLayoutDescriptor const& layou
/// </returns>
inline VDSHandle Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, std::vector<VolumeDataAxisDescriptor> axisDescriptors, std::vector<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, Error& error)
{
return GetOpenVDSInterface(OPENVDS_VERSION).Create(options, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, compressionMethod, compressionTolerance, error);
return GetOpenVDSInterface(OPENVDS_VERSION).Create(options, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, compressionMethod, compressionTolerance, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error);
}
/// <summary>
......@@ -865,7 +865,7 @@ inline VDSHandle Create(const OpenOptions& options, VolumeDataLayoutDescriptor c
/// </returns>
inline VDSHandle Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, std::vector<VolumeDataAxisDescriptor> axisDescriptors, std::vector<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, Error& error)
{
return GetOpenVDSInterface(OPENVDS_VERSION).Create(options, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, CompressionMethod::None, 0, error);
return GetOpenVDSInterface(OPENVDS_VERSION).Create(options, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, CompressionMethod::None, 0, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error);
}
/// <summary>
......@@ -888,7 +888,7 @@ inline VDSHandle Create(const OpenOptions& options, VolumeDataLayoutDescriptor c
/// </returns>
inline VDSHandle Create(IOManager* ioManager, VolumeDataLayoutDescriptor const &layoutDescriptor, std::vector<VolumeDataAxisDescriptor> axisDescriptors, std::vector<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const &metadata, CompressionMethod compressionMethod, float compressionTolerance, Error &error)
{
return GetOpenVDSInterface(OPENVDS_VERSION).Create(ioManager, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, compressionMethod, compressionTolerance, error);
return GetOpenVDSInterface(OPENVDS_VERSION).Create(ioManager, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, compressionMethod, compressionTolerance, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error);
}
/// <summary>
......@@ -905,7 +905,7 @@ inline VDSHandle Create(IOManager* ioManager, VolumeDataLayoutDescriptor const &
/// </returns>
inline VDSHandle Create(IOManager* ioManager, VolumeDataLayoutDescriptor const &layoutDescriptor, std::vector<VolumeDataAxisDescriptor> axisDescriptors, std::vector<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const &metadata, Error &error)
{
return Create(ioManager, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, CompressionMethod::None, 0, error);
return GetOpenVDSInterface(OPENVDS_VERSION).Create(ioManager, layoutDescriptor, axisDescriptors, channelDescriptors, metadata, CompressionMethod::None, 0, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error);
}
/// <summary>
......@@ -987,7 +987,7 @@ inline void Close(VDSHandle handle) { return GetOpenVDSInterface(OPENVDS_VERSION
/// <param name="error">
/// If an error occured, the error code and message will be written to this output parameter
/// </param>
inline void Close(VDSHandle handle, Error &error) { return GetOpenVDSInterface(OPENVDS_VERSION).Close(handle, error); }
inline void Close(VDSHandle handle, Error &error) { return GetOpenVDSInterface(OPENVDS_VERSION).Close(handle, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error); }
#if !defined(JAVA_WRAPPER_GENERATOR)
/// <summary>
......@@ -1008,7 +1008,7 @@ inline void RetryableClose(VDSHandle handle) { return GetOpenVDSInterface(OPENVD
/// <param name="error">
/// If an error occured, the error code and message will be written to this output parameter
/// </param>
inline void RetryableClose(VDSHandle handle, Error &error) { return GetOpenVDSInterface(OPENVDS_VERSION).RetryableClose(handle, error); }
inline void RetryableClose(VDSHandle handle, Error &error) { return GetOpenVDSInterface(OPENVDS_VERSION).RetryableClose(handle, [](Error *error, int errorCode, const char *errorMessage) { error->code = errorCode; error->string = errorMessage; }, &error); }
/// <summary>
/// Get the GlobalState interface
......@@ -1070,7 +1070,7 @@ public:
/// <summary>
/// Close the VDS and free up all associated resources if the close succeeds.
/// </summary>
void RetryableClose(Error &error) { if(m_VDS) { OpenVDS::RetryableClose(m_VDS, error); if(error.code == 0) m_VDS = VDSHandle(); } else { error = Error(); } }
void RetryableClose(Error &error) { if(m_VDS) { OpenVDS::RetryableClose(m_VDS, error); } else { error = Error(); } }
operator VDSHandle() const { return m_VDS; }
operator bool() const { return m_VDS != nullptr; }
......
......@@ -100,25 +100,27 @@ protected:
OpenVDSInterface() {}
virtual ~OpenVDSInterface() {}
public:
virtual OpenOptions* CreateOpenOptions(StringWrapper url, StringWrapper connectionString, Error& error) = 0;
typedef void (*ErrorHandler)(Error *error, int errorCode, const char *errorMessage);
virtual OpenOptions* CreateOpenOptions(StringWrapper url, StringWrapper connectionString, ErrorHandler errorHandler, Error *error=nullptr) = 0;
virtual bool IsSupportedProtocol(StringWrapper url) = 0;
virtual VDSHandle Open(StringWrapper url, StringWrapper connectionString, Error& error) = 0;
virtual VDSHandle OpenWithAdaptiveCompressionTolerance(StringWrapper url, StringWrapper connectionString, float waveletAdaptiveTolerance, Error& error) = 0;
virtual VDSHandle OpenWithAdaptiveCompressionRatio(StringWrapper url, StringWrapper connectionString, float waveletAdaptiveRatio, Error& error) = 0;
virtual VDSHandle Open(const OpenOptions& options, Error& error) = 0;
virtual VDSHandle Open(IOManager*ioManager, Error &error) = 0;
virtual VDSHandle Open(StringWrapper url, StringWrapper connectionString, ErrorHandler errorHandler, Error *error=nullptr) = 0;
virtual VDSHandle OpenWithAdaptiveCompressionTolerance(StringWrapper url, StringWrapper connectionString, float waveletAdaptiveTolerance, ErrorHandler errorHandler, Error *error=nullptr) = 0;
virtual VDSHandle OpenWithAdaptiveCompressionRatio(StringWrapper url, StringWrapper connectionString, float waveletAdaptiveRatio, ErrorHandler errorHandler, Error *error=nullptr) = 0;
virtual VDSHandle Open(const OpenOptions& options, ErrorHandler errorHandler, Error *error=nullptr) = 0;
virtual VDSHandle Open(IOManager*ioManager, ErrorHandler errorHandler, Error *error=nullptr) = 0;
virtual bool IsCompressionMethodSupported(CompressionMethod compressionMethod) = 0;
virtual VDSHandle Create(StringWrapper url, StringWrapper connectionString, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, Error& error) = 0;
virtual VDSHandle Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, Error& error) = 0;
virtual VDSHandle Create(IOManager* ioManager, VolumeDataLayoutDescriptor const &layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const &metadata, CompressionMethod compressionMethod, float compressionTolerance, Error &error) = 0;
virtual VDSHandle Create(StringWrapper url, StringWrapper connectionString, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, ErrorHandler errorHandler, Error *error=nullptr) = 0;
virtual VDSHandle Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const& metadata, CompressionMethod compressionMethod, float compressionTolerance, ErrorHandler errorHandler, Error *error=nullptr) = 0;
virtual VDSHandle Create(IOManager* ioManager, VolumeDataLayoutDescriptor const &layoutDescriptor, VectorWrapper<VolumeDataAxisDescriptor> axisDescriptors, VectorWrapper<VolumeDataChannelDescriptor> channelDescriptors, MetadataReadAccess const &metadata, CompressionMethod compressionMethod, float compressionTolerance, ErrorHandler errorHandler, Error *error=nullptr) = 0;
virtual VolumeDataLayout *GetLayout(VDSHandle handle) = 0;
virtual IVolumeDataAccessManager *GetAccessManagerInterface(VDSHandle handle) = 0;
virtual CompressionMethod GetCompressionMethod(VDSHandle handle) = 0;
virtual float GetCompressionTolerance(VDSHandle handle) = 0;
virtual void Close(VDSHandle handle) = 0;
virtual void Close(VDSHandle handle, Error &error) = 0;
virtual void Close(VDSHandle handle, ErrorHandler errorHandler, Error *error=nullptr) = 0;
virtual void RetryableClose(VDSHandle handle) = 0;
virtual void RetryableClose(VDSHandle handle, Error &error) = 0;
virtual void RetryableClose(VDSHandle handle, ErrorHandler errorHandler, Error *error=nullptr) = 0;
virtual GlobalState *GetGlobalState() = 0;
virtual const char *GetOpenVDSName() = 0;
virtual const char *GetOpenVDSVersion() = 0;
......
......@@ -131,13 +131,13 @@ enum class VolumeDataMapping : uint64_t
enum class CompressionMethod
{
None,
Wavelet,
RLE,
Zip,
WaveletNormalizeBlock,
WaveletLossless,
WaveletNormalizeBlockLossless
None, ///< No compression is applied; data is stored 'as is'
Wavelet, ///< Voxel values are compressed using a lossy wavelet compression algorithm. This usually produces excellent results for continuous data, but is not applicable when dealing with discrete values.
RLE, ///< Voxel values are compressed using run-length encoding which is a fast, lossless algorithm. This gives good results when the same value is often repeated for adjacent voxels, for example classification data.
Zip, ///< Voxel values are compressed using zip (zlib) which is a slower, lossless algorithm that gives fairly good compression for all types of data.
WaveletNormalizeBlock, ///< This method is experimental and no guarantee is made that decompression for data compressed in this format will be supported in future versions. Voxel values are compressed using a lossy wavelet compression algorithm. Also the threshold takes into account the absolute average of each block. This is good for data that varies a lot in signal strength. This usually produces excellent results for continuous data, but is not applicable when dealing with discrete values.
WaveletLossless, ///< Voxel values are compressed using a losslees wavelet compression algorithm. This usually produces excellent results for continuous data, but is not applicable when dealing with discrete values.
WaveletNormalizeBlockLossless ///< This method is experimental and no guarantee is made that decompression for data compressed in this format will be supported in future versions. Voxel values are compressed using a lossless wavelet compression algorithm. Also the threshold takes into account the absolute average of each block. This is good for data that varies a lot in signal strength. This usually produces excellent results for continuous data, but is not applicable when dealing with discrete values.
};
inline bool CompressionMethod_IsWavelet(CompressionMethod compressionMethod)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment