const SGPropertyNode& _propertyNode;
};
-HLAPropertyDataElement::HLAPropertyDataElement(HLAPropertyReference* propertyReference) :
- _propertyReference(propertyReference)
-{
-}
-
-HLAPropertyDataElement::HLAPropertyDataElement(const HLADataType* dataType, HLAPropertyReference* propertyReference) :
- _dataType(dataType),
- _propertyReference(propertyReference)
-{
-}
-
HLAPropertyDataElement::HLAPropertyDataElement()
{
}
setPropertyNode(propertyNode);
}
+HLAPropertyDataElement::HLAPropertyDataElement(const HLADataType* dataType) :
+ _dataType(dataType)
+{
+}
+
HLAPropertyDataElement::~HLAPropertyDataElement()
{
}
void
HLAPropertyDataElement::setPropertyNode(SGPropertyNode* propertyNode)
{
- _propertyReference = new HLAPropertyReference;
- _propertyReference->setRootNode(propertyNode);
+ _propertyNode = propertyNode;
}
SGPropertyNode*
HLAPropertyDataElement::getPropertyNode()
{
- if (!_propertyReference.valid())
- return 0;
- return _propertyReference->getPropertyNode();
+ return _propertyNode.get();
}
const SGPropertyNode*
HLAPropertyDataElement::getPropertyNode() const
{
- if (!_propertyReference.valid())
- return 0;
- return _propertyReference->getPropertyNode();
+ return _propertyNode.get();
}
} // namespace simgear
#ifndef HLAPropertyDataElement_hxx
#define HLAPropertyDataElement_hxx
-#include <set>
#include <simgear/props/props.hxx>
#include "HLADataElement.hxx"
namespace simgear {
-class HLAPropertyReference : public SGReferenced {
-public:
- HLAPropertyReference()
- { }
- HLAPropertyReference(const std::string& relativePath) :
- _relativePath(relativePath)
- { }
-
- SGPropertyNode* getPropertyNode()
- { return _propertyNode.get(); }
-
- void setRootNode(SGPropertyNode* rootNode)
- {
- if (!rootNode)
- _propertyNode.clear();
- else
- _propertyNode = rootNode->getNode(_relativePath, true);
- }
-
-private:
- std::string _relativePath;
- SGSharedPtr<SGPropertyNode> _propertyNode;
-};
-
-class HLAPropertyReferenceSet : public SGReferenced {
-public:
- void insert(const SGSharedPtr<HLAPropertyReference>& propertyReference)
- {
- _propertyReferenceSet.insert(propertyReference);
- propertyReference->setRootNode(_rootNode.get());
- }
- void remove(const SGSharedPtr<HLAPropertyReference>& propertyReference)
- {
- PropertyReferenceSet::iterator i = _propertyReferenceSet.find(propertyReference);
- if (i == _propertyReferenceSet.end())
- return;
- _propertyReferenceSet.erase(i);
- propertyReference->setRootNode(0);
- }
-
- void setRootNode(SGPropertyNode* rootNode)
- {
- _rootNode = rootNode;
- for (PropertyReferenceSet::iterator i = _propertyReferenceSet.begin();
- i != _propertyReferenceSet.end(); ++i) {
- (*i)->setRootNode(_rootNode.get());
- }
- }
- SGPropertyNode* getRootNode()
- { return _rootNode.get(); }
-
-private:
- SGSharedPtr<SGPropertyNode> _rootNode;
-
- typedef std::set<SGSharedPtr<HLAPropertyReference> > PropertyReferenceSet;
- PropertyReferenceSet _propertyReferenceSet;
-};
-
class HLAPropertyDataElement : public HLADataElement {
public:
- HLAPropertyDataElement(HLAPropertyReference* propertyReference);
- HLAPropertyDataElement(const HLADataType* dataType, HLAPropertyReference* propertyReference);
HLAPropertyDataElement();
HLAPropertyDataElement(SGPropertyNode* propertyNode);
HLAPropertyDataElement(const HLADataType* dataType, SGPropertyNode* propertyNode);
+ HLAPropertyDataElement(const HLADataType* dataType);
virtual ~HLAPropertyDataElement();
virtual bool encode(HLAEncodeStream& stream) const;
class EncodeVisitor;
SGSharedPtr<const HLADataType> _dataType;
- SGSharedPtr<HLAPropertyReference> _propertyReference;
+ SGSharedPtr<SGPropertyNode> _propertyNode;
};
} // namespace simgear