Make OpenSpaceModule a properties::PropertyOwner so that it can own properties

Add properties owned by OpenSpaceModule to the global settings engine (closing #104)
This commit is contained in:
Alexander Bock
2016-07-31 19:26:55 +02:00
parent 393f39de2e
commit 6bd0ef7102
5 changed files with 22 additions and 19 deletions

View File

@@ -29,13 +29,19 @@
#include <openspace/properties/scalarproperty.h>
#include <openspace/properties/optionproperty.h>
#include <vector>
namespace openspace {
class OpenSpaceModule;
class SettingsEngine : public properties::PropertyOwner {
public:
SettingsEngine();
void initialize();
void setModules(std::vector<OpenSpaceModule*> modules);
private:
void initEyeSeparation();

View File

@@ -25,7 +25,10 @@
#ifndef __OPENSPACEMODULE_H__
#define __OPENSPACEMODULE_H__
#include <openspace/properties/propertyowner.h>
#include <string>
#include <vector>
namespace openspace {
@@ -34,7 +37,7 @@ namespace openspace {
* into a useful granularity to be mostly used self-sufficiently. Each OpenSpaceModule
* needs a unique, nonempty <code>name</code>.
*/
class OpenSpaceModule {
class OpenSpaceModule : public properties::PropertyOwner {
public:
/**
* Constructs the OpenSpaceModule with a specific \p name. The uniqueness of the
@@ -61,12 +64,6 @@ public:
*/
void deinitialize();
/**
* Returns the name for this OpenSpaceModule.
* \return THe name for this OpenSpaceModule
*/
std::string name() const;
protected:
/**
* Customization point for each derived class. The internalInitialize method is called
@@ -85,9 +82,6 @@ protected:
* path tokens.
*/
std::string modulePath() const;
/// The name of this OpenSpaceModule
const std::string _name;
};
} // namespace openspace

View File

@@ -421,6 +421,7 @@ bool OpenSpaceEngine::initialize() {
// Initialize the SettingsEngine
_settingsEngine->initialize();
_settingsEngine->setModules(_moduleEngine->modules());
// Initialize the Scene
Scene* sceneGraph = new Scene;

View File

@@ -27,6 +27,7 @@
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/util/openspacemodule.h>
#include <openspace/scene/scene.h>
#include <ghoul/ghoul.h>
@@ -45,7 +46,12 @@ void SettingsEngine::initialize() {
initEyeSeparation();
initSceneFiles();
}
void SettingsEngine::setModules(std::vector<OpenSpaceModule*> modules) {
for (OpenSpaceModule* m : modules) {
addPropertySubOwner(m);
}
}
void SettingsEngine::initEyeSeparation() {
addProperty(_eyeSeparation);

View File

@@ -36,10 +36,10 @@ namespace {
namespace openspace {
OpenSpaceModule::OpenSpaceModule(std::string name)
: _name(std::move(name))
{
ghoul_assert(!_name.empty(), "Name must not be empty");
OpenSpaceModule::OpenSpaceModule(std::string name) {
ghoul_assert(!name.empty(), "Name must not be empty");
setName(name);
}
void OpenSpaceModule::initialize() {
@@ -63,10 +63,6 @@ void OpenSpaceModule::deinitialize() {
internalDeinitialize();
}
std::string OpenSpaceModule::name() const {
return _name;
}
std::string OpenSpaceModule::modulePath() const {
std::string moduleName = name();
std::transform(moduleName.begin(), moduleName.end(), moduleName.begin(), tolower);