diff --git a/SDK/CPP/private/system.cpp b/SDK/CPP/private/system.cpp index b93a4bdc621dae6268032fa6525a6bca89b383d5..84bdbcd406793b0a1b51300b2f7ef0e860e67287 100644 --- a/SDK/CPP/private/system.cpp +++ b/SDK/CPP/private/system.cpp @@ -50,6 +50,9 @@ SystemImpl::~SystemImpl() delete feed_; delete net_; delete root_; + + // FIXME: Check this actually works, can it be restarted? Pool issues? + g_isinit = false; } voltu::Version SystemImpl::getVersion() const diff --git a/SDK/CPP/public/include/voltu/initialise.hpp b/SDK/CPP/public/include/voltu/initialise.hpp index aeae10f6c31dd11db0d8242c73b1e2a1ec49a719..4a6e5b3ffc2c2326b5934d2577d0458605ddc51c 100644 --- a/SDK/CPP/public/include/voltu/initialise.hpp +++ b/SDK/CPP/public/include/voltu/initialise.hpp @@ -11,5 +11,36 @@ namespace voltu { + /** + * @brief Get core VolTu instance. + * + * This method returns a smart pointer to a singleton VolTu runtime + * instance and must be the first VolTu call. On any given machine it is + * only sensible and possible to have one runtime instance of VolTu due to + * its use of hardware devices. Multiple real instances are not possible. + * + * @code + * int main(int argc, char** argv) { + * auto vtu = voltu::instance(); + * + * vtu->open("device:camera"); + * ... + * } + * @endcode + * + * @note + * This method must only be called once. + * + * @throw voltu::exceptions::LibraryLoadFailed + * If runtime not found or is invalid. + * + * @throw voltu::exceptions::RuntimeVersionMismatch + * If major or minor version does not match the SDK headers. + * + * @throw voltu::exceptions::RuntimeAlreadyInUse + * If a runtime instance is in use by another application. + * + * @return Singleton VolTu runtime instance. + */ PY_API std::shared_ptr<voltu::System> instance(); } diff --git a/SDK/CPP/public/include/voltu/system.hpp b/SDK/CPP/public/include/voltu/system.hpp index 72e933bf338506784494a870afe05899b4b636ba..6a7e4cd96387a6e50b4933dad6892eb52104755d 100644 --- a/SDK/CPP/public/include/voltu/system.hpp +++ b/SDK/CPP/public/include/voltu/system.hpp @@ -40,7 +40,12 @@ public: virtual ~System() = default; /** - * @brief Get the semantic version information. + * @brief Get the runtime version information. + * + * This method gets the VolTu version of the runtime shared library, which + * may not be the same as the version of the SDK here. + * + * @see voltu.hpp * * @return Always returns semantic versioning structure. */ diff --git a/SDK/CPP/public/include/voltu/types/errors.hpp b/SDK/CPP/public/include/voltu/types/errors.hpp index a69e976305e34ff79ffcbb77ac12078c433d0f03..b1e77accc50f9975698db4f61be11a5dd7b1c330 100644 --- a/SDK/CPP/public/include/voltu/types/errors.hpp +++ b/SDK/CPP/public/include/voltu/types/errors.hpp @@ -32,7 +32,8 @@ VOLTU_EXCEPTION(BadImageChannel, Exception, "Invalid image channel"); VOLTU_EXCEPTION(NoFrame, Exception, "No frame available"); VOLTU_EXCEPTION(AlreadyInit, Exception, "VolTu already initialised"); VOLTU_EXCEPTION(LibraryLoadFailed, Exception, "Could not load VolTu library"); -VOLTU_EXCEPTION(LibraryVersionMismatch, Exception, "Wrong version of library found"); +VOLTU_EXCEPTION(RuntimeVersionMismatch, Exception, "Wrong version of runtime found"); +VOLTU_EXCEPTION(RuntimeAlreadyInUse, Exception, "VolTu runtime already in use"); VOLTU_EXCEPTION(BadSourceURI, Exception, "Bad source URI"); VOLTU_EXCEPTION(InvalidFrameObject, Exception, "Invalid Frame object"); VOLTU_EXCEPTION(InternalRenderError, Exception, "Internal renderer error"); diff --git a/SDK/CPP/public/voltu.cpp b/SDK/CPP/public/voltu.cpp index 4aef0ba97f9828901d0c2d1f980cb7400f51ae97..bf63ed6b4c1f145f1a36547030e97c898359f78f 100644 --- a/SDK/CPP/public/voltu.cpp +++ b/SDK/CPP/public/voltu.cpp @@ -50,6 +50,7 @@ static void unloadLibrary(Library lib) static std::string locateLibrary() { + // TODO: Use full paths and find correct versions #if defined(WIN32) return "voltu.dll"; #else @@ -76,13 +77,14 @@ std::shared_ptr<voltu::System> voltu::instance() if (!instance) { - throw voltu::exceptions::LibraryLoadFailed(); + throw voltu::exceptions::RuntimeAlreadyInUse(); } + // FIXME: Perhaps use a C method instead for safety? auto ver = instance->getVersion(); if (ver.major != VOLTU_VERSION_MAJOR || ver.minor != VOLTU_VERSION_MINOR) { - throw voltu::exceptions::LibraryVersionMismatch(); + throw voltu::exceptions::RuntimeVersionMismatch(); } return instance;