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

Use RAII

parent 7fc400f2
No related branches found
No related tags found
1 merge request!358Updates to SDK and alternative fusion
Pipeline #33980 passed
......@@ -43,4 +43,6 @@ namespace voltu
* @return Singleton VolTu runtime instance.
*/
std::shared_ptr<voltu::System> instance();
void release();
}
......@@ -15,3 +15,23 @@
#include <voltu/system.hpp>
#include <voltu/initialise.hpp>
namespace voltu
{
class Voltu
{
public:
inline Voltu() : instance_(voltu::instance()) {}
inline ~Voltu() { instance_.reset(); voltu::release(); }
inline voltu::System* operator->()
{
return instance_.get();
}
private:
std::shared_ptr<voltu::System> instance_;
};
}
......@@ -74,7 +74,7 @@ int main(int argc, char **argv)
}
}
auto vtu = voltu::instance();
voltu::Voltu vtu;
for (const auto &p : paths)
{
......
......@@ -25,14 +25,15 @@
#include <cstdlib>
#include <iostream>
typedef void* Library;
static bool g_init = false;
static Library handle = nullptr;
#ifdef WITH_OPENCV
voltu::GpuUtilities voltu::gpu;
#endif
typedef void* Library;
static Library loadLibrary(const char *file)
{
#if defined(WIN32)
......@@ -116,7 +117,7 @@ std::shared_ptr<voltu::System> voltu::instance()
std::string name = locateLibrary();
std::cout << "Loading VolTu Runtime: " << name << std::endl;
Library handle = loadLibrary(name.c_str());
handle = loadLibrary(name.c_str());
if (handle)
{
......@@ -166,3 +167,9 @@ std::shared_ptr<voltu::System> voltu::instance()
return nullptr;
}
void voltu::release()
{
// TODO: Call a finalise function
if (handle) unloadLibrary(handle);
}
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