More work towards a unified interface for accessing properties

This commit is contained in:
Alexander Bock
2014-08-30 10:01:11 +02:00
parent 79174d5b6c
commit 9671921331
9 changed files with 168 additions and 61 deletions

View File

@@ -35,27 +35,42 @@ namespace properties {
class PropertyOwner {
public:
static const char URISeparator = '.';
PropertyOwner();
virtual ~PropertyOwner();
void setName(std::string name);
virtual const std::string& name() const;
const std::vector<Property*>& properties() const;
Property* property(const std::string& id) const;
bool hasProperty(const std::string& id) const;
const std::vector<PropertyOwner*>& subOwners() const;
PropertyOwner* subOwner(const std::string& name) const;
bool hasSubOwner(const std::string& name) const;
void setPropertyGroupName(std::string groupID, std::string name);
const std::string& propertyGroupName(const std::string& groupID) const;
protected:
void addProperty(Property* prop);
void addProperty(Property& prop);
void addPropertySubOwner(PropertyOwner* owner);
void addPropertySubOwner(PropertyOwner& owner);
void removeProperty(Property* prop);
void removeProperty(Property& prop);
void removePropertySubOwner(PropertyOwner* owner);
void removePropertySubOwner(PropertyOwner& owner);
private:
std::string _name;
std::vector<Property*> _properties;
std::vector<PropertyOwner*> _subOwners;
std::map<std::string, std::string> _groupNames;
};

View File

@@ -38,7 +38,6 @@ class SceneGraphNode;
SceneGraph* sceneGraph();
SceneGraphNode* sceneGraphNode(const std::string& name);
properties::Property* property(const std::string& uri);
properties::Property* property(const std::string& nodeName, const std::string& propertyName);
} // namespace

View File

@@ -28,6 +28,7 @@
// open space includes
#include <openspace/rendering/renderable.h>
#include <openspace/scenegraph/ephemeris.h>
#include <openspace/properties/propertyowner.h>
#include <openspace/scenegraph/scenegraph.h>
#include <ghoul/misc/dictionary.h>
@@ -40,7 +41,7 @@
namespace openspace {
class SceneGraphNode {
class SceneGraphNode : public properties::PropertyOwner {
public:
static std::string RootNodeName;
@@ -61,11 +62,9 @@ public:
// set & get
void addNode(SceneGraphNode* child);
void setName(const std::string& name);
void setParent(SceneGraphNode* parent);
const psc& position() const;
psc worldPosition() const;
std::string nodeName() const;
SceneGraphNode* parent() const;
const std::vector<SceneGraphNode*>& children() const;
@@ -86,7 +85,6 @@ private:
// essential
std::vector<SceneGraphNode*> _children;
SceneGraphNode* _parent;
std::string _nodeName;
Ephemeris* _ephemeris;
// renderable