hla: remove the now unused HLAPropertyReference{,Set}.

This commit is contained in:
Mathias Froehlich 2011-10-03 13:11:27 +02:00
parent 2e13c1fa4b
commit 92976b7735
2 changed files with 10 additions and 81 deletions

View File

@ -198,17 +198,6 @@ protected:
const SGPropertyNode& _propertyNode; const SGPropertyNode& _propertyNode;
}; };
HLAPropertyDataElement::HLAPropertyDataElement(HLAPropertyReference* propertyReference) :
_propertyReference(propertyReference)
{
}
HLAPropertyDataElement::HLAPropertyDataElement(const HLADataType* dataType, HLAPropertyReference* propertyReference) :
_dataType(dataType),
_propertyReference(propertyReference)
{
}
HLAPropertyDataElement::HLAPropertyDataElement() HLAPropertyDataElement::HLAPropertyDataElement()
{ {
} }
@ -224,6 +213,11 @@ HLAPropertyDataElement::HLAPropertyDataElement(const HLADataType* dataType, SGPr
setPropertyNode(propertyNode); setPropertyNode(propertyNode);
} }
HLAPropertyDataElement::HLAPropertyDataElement(const HLADataType* dataType) :
_dataType(dataType)
{
}
HLAPropertyDataElement::~HLAPropertyDataElement() HLAPropertyDataElement::~HLAPropertyDataElement()
{ {
} }
@ -284,24 +278,19 @@ HLAPropertyDataElement::setDataType(const HLADataType* dataType)
void void
HLAPropertyDataElement::setPropertyNode(SGPropertyNode* propertyNode) HLAPropertyDataElement::setPropertyNode(SGPropertyNode* propertyNode)
{ {
_propertyReference = new HLAPropertyReference; _propertyNode = propertyNode;
_propertyReference->setRootNode(propertyNode);
} }
SGPropertyNode* SGPropertyNode*
HLAPropertyDataElement::getPropertyNode() HLAPropertyDataElement::getPropertyNode()
{ {
if (!_propertyReference.valid()) return _propertyNode.get();
return 0;
return _propertyReference->getPropertyNode();
} }
const SGPropertyNode* const SGPropertyNode*
HLAPropertyDataElement::getPropertyNode() const HLAPropertyDataElement::getPropertyNode() const
{ {
if (!_propertyReference.valid()) return _propertyNode.get();
return 0;
return _propertyReference->getPropertyNode();
} }
} // namespace simgear } // namespace simgear

View File

@ -18,77 +18,17 @@
#ifndef HLAPropertyDataElement_hxx #ifndef HLAPropertyDataElement_hxx
#define HLAPropertyDataElement_hxx #define HLAPropertyDataElement_hxx
#include <set>
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
#include "HLADataElement.hxx" #include "HLADataElement.hxx"
namespace simgear { 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 { class HLAPropertyDataElement : public HLADataElement {
public: public:
HLAPropertyDataElement(HLAPropertyReference* propertyReference);
HLAPropertyDataElement(const HLADataType* dataType, HLAPropertyReference* propertyReference);
HLAPropertyDataElement(); HLAPropertyDataElement();
HLAPropertyDataElement(SGPropertyNode* propertyNode); HLAPropertyDataElement(SGPropertyNode* propertyNode);
HLAPropertyDataElement(const HLADataType* dataType, SGPropertyNode* propertyNode); HLAPropertyDataElement(const HLADataType* dataType, SGPropertyNode* propertyNode);
HLAPropertyDataElement(const HLADataType* dataType);
virtual ~HLAPropertyDataElement(); virtual ~HLAPropertyDataElement();
virtual bool encode(HLAEncodeStream& stream) const; virtual bool encode(HLAEncodeStream& stream) const;
@ -106,7 +46,7 @@ private:
class EncodeVisitor; class EncodeVisitor;
SGSharedPtr<const HLADataType> _dataType; SGSharedPtr<const HLADataType> _dataType;
SGSharedPtr<HLAPropertyReference> _propertyReference; SGSharedPtr<SGPropertyNode> _propertyNode;
}; };
} // namespace simgear } // namespace simgear