Commit 2ffbbb31 authored by Morten Ofstad's avatar Morten Ofstad
Browse files

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

OpenVDSInterface versioning improvements

See merge request !633
parents 1b7b054e 47a80f4d
Pipeline #117288 passed with stages
in 56 minutes and 49 seconds
......@@ -823,7 +823,14 @@ public:
GlobalState *GetGlobalState() final override;
const char *GetOpenVDSName() final override;
const char *GetOpenVDSVersion() final override;
void GetOpenVDSVersion(int &major, int &minor, int &patch) final override;
const char *GetOpenVDSRevision() final override;
static OpenVDSInterfaceImpl &GetInstance()
{
static OpenVDSInterfaceImpl instance;
return instance;
}
};
OpenOptions* OpenVDSInterfaceImpl::CreateOpenOptions(StringWrapper urlWrapper, StringWrapper connectionStringWrapper, ErrorHandler errorHandler, Error *errorPtr)
......@@ -1095,17 +1102,34 @@ const char *OpenVDSInterfaceImpl::GetOpenVDSVersion()
return OPENVDS_VERSION;
}
void OpenVDSInterfaceImpl::GetOpenVDSVersion(int &major, int &minor, int &patch)
{
major = OPENVDS_MAJOR_VERSION;
minor = OPENVDS_MINOR_VERSION;
patch = OPENVDS_PATCH_VERSION;
}
const char *OpenVDSInterfaceImpl::GetOpenVDSRevision()
{
return OPENVDS_REVISION;
}
static OpenVDSInterface *openVDSInterfacePointer = &OpenVDSInterfaceImpl::GetInstance();
#define OPENVDS_STRINGIZE_UNEXPANDED(N) #N
#define OPENVDS_STRINGIZE(N) OPENVDS_STRINGIZE_UNEXPANDED(N)
OpenVDSInterface &GetOpenVDSInterface(const char* version)
{
static OpenVDSInterfaceImpl instance;
static const char expectedVersion[] = OPENVDS_STRINGIZE(OPENVDS_MAJOR_VERSION) "." OPENVDS_STRINGIZE(OPENVDS_MINOR_VERSION) ".";
if(strncmp(version, expectedVersion, sizeof(expectedVersion) - 1) != 0) throw InvalidOperation("OpenVDS interface version mismatch");
if(strcmp(version, OPENVDS_VERSION) != 0) throw InvalidOperation("OpenVDS interface version mismatch");
return instance;
return *openVDSInterfacePointer;
}
void SetOpenVDSInterface(OpenVDSInterface &openVDSInterface)
{
openVDSInterfacePointer = &openVDSInterface;
}
}
......@@ -92,9 +92,24 @@ struct StringWrapper
};
/// <summary>
/// The OpenVDS global interface is used to provide a single versioned entrypoint for the API
/// The OpenVDS versioning interface is a stable base class for the OpenVDS global interface that can be used to check what version of the OpenVDS interface is provided
/// </summary>
class OpenVDSInterface
class OpenVDSVersioningInterface
{
protected:
OpenVDSVersioningInterface() {}
virtual ~OpenVDSVersioningInterface() {}
public:
virtual const char *GetOpenVDSName() = 0;
virtual const char *GetOpenVDSVersion() = 0;
virtual void GetOpenVDSVersion(int &major, int &minor, int &patch) = 0;
virtual const char *GetOpenVDSRevision() = 0;
};
/// <summary>
/// The OpenVDS interface is used to provide a versioned entrypoint for the API with wrappers for standard types to ensure ABI compatibility
/// </summary>
class OpenVDSInterface : public OpenVDSVersioningInterface
{
protected:
OpenVDSInterface() {}
......@@ -122,13 +137,11 @@ public:
virtual void RetryableClose(VDSHandle handle) = 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;
virtual const char *GetOpenVDSRevision() = 0;
};
#ifndef OPENVDS_REPLACE_INTERFACE
OPENVDS_EXPORT OpenVDSInterface &GetOpenVDSInterface(const char* version);
OPENVDS_EXPORT void SetOpenVDSInterface(OpenVDSInterface &openVDSInterface);
#endif
}
......
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