Skip to content
Snippets Groups Projects
Commit 6982d519 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

More documentation the exceptions

parent c2c16d4c
No related branches found
No related tags found
No related merge requests found
Pipeline #33746 passed
......@@ -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
......
......@@ -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();
}
......@@ -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.
*/
......
......@@ -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");
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment