Adapt ISWAManager and KameleonWrapper to removal of singleton

This commit is contained in:
Alexander Bock
2018-11-05 21:11:01 -05:00
parent 1742ed032d
commit 3ff7b974f5
4 changed files with 32 additions and 7 deletions
+23
View File
@@ -94,6 +94,8 @@ namespace {
namespace openspace {
IswaManager* IswaManager::_instance = nullptr;
IswaManager::IswaManager()
: properties::PropertyOwner({ "IswaManager" })
, _baseUrl("https://iswa-demo-server.herokuapp.com/")
@@ -118,6 +120,27 @@ IswaManager::~IswaManager() {
_cygnetInformation.clear();
}
void IswaManager::initialize() {
ghoul_assert(!isInitialized(), "IswaManager is already initialized");
_instance = new IswaManager;
}
void IswaManager::deinitialize() {
ghoul_assert(isInitialized(), "IswaManager is not initialized");
delete _instance;
_instance = nullptr;
}
bool IswaManager::isInitialized() {
return _instance != nullptr;
}
IswaManager& IswaManager::ref() {
ghoul_assert(isInitialized(), "IswaManager is not initialized");
return *_instance;
}
void IswaManager::addIswaCygnet(int id, const std::string& type, std::string group) {
if (id > 0) {
createScreenSpace(id);
+8 -5
View File
@@ -26,7 +26,6 @@
#define __OPENSPACE_MODULE_ISWA___ISWAMANAGER___H__
#include <openspace/properties/propertyowner.h>
#include <ghoul/designpattern/singleton.h>
#include <openspace/engine/downloadmanager.h>
#include <ghoul/designpattern/event.h>
@@ -68,10 +67,7 @@ struct MetadataFuture {
bool isFinished;
};
class IswaManager : public ghoul::Singleton<IswaManager>, public properties::PropertyOwner
{
friend class ghoul::Singleton<IswaManager>;
class IswaManager : public properties::PropertyOwner {
public:
enum CygnetType { Texture, Data, Kameleon, NoType };
enum CygnetGeometry { Plane, Sphere };
@@ -79,6 +75,11 @@ public:
IswaManager();
~IswaManager();
static void initialize();
static void deinitialize();
static bool isInitialized();
static IswaManager& ref();
void addIswaCygnet(int id, const std::string& type = "Texture",
std::string group = "");
void addKameleonCdf(std::string group, int pos);
@@ -127,6 +128,8 @@ private:
ghoul::Event<> _iswaEvent;
std::string _baseUrl;
static IswaManager* _instance;
};
} //namespace openspace
+1
View File
@@ -29,6 +29,7 @@
#include <ghoul/logging/logmanager.h>
#include <ghoul/fmt.h>
#include <ghoul/glm.h>
#include <ghoul/misc/assert.h>
#include <ghoul/misc/misc.h>
#ifdef WIN32