hla: use the property based interface from the property data element.
This commit is contained in:
parent
3451012bca
commit
40d72b3ba7
1 changed files with 39 additions and 12 deletions
|
@ -323,6 +323,34 @@ private:
|
||||||
ObjectClassConfigList _objectClassConfigList;
|
ObjectClassConfigList _objectClassConfigList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PropertyReferenceSet : public SGReferenced {
|
||||||
|
public:
|
||||||
|
void insert(const std::string& relativePath, const SGSharedPtr<sg::HLAPropertyDataElement>& dataElement)
|
||||||
|
{
|
||||||
|
if (_rootNode.valid())
|
||||||
|
dataElement->setPropertyNode(_rootNode->getNode(relativePath, true));
|
||||||
|
_pathDataElementPairList.push_back(PathDataElementPair(relativePath, dataElement));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setRootNode(SGPropertyNode* rootNode)
|
||||||
|
{
|
||||||
|
_rootNode = rootNode;
|
||||||
|
for (PathDataElementPairList::iterator i = _pathDataElementPairList.begin();
|
||||||
|
i != _pathDataElementPairList.end(); ++i) {
|
||||||
|
i->second->setPropertyNode(_rootNode->getNode(i->first, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SGPropertyNode* getRootNode()
|
||||||
|
{ return _rootNode.get(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
SGSharedPtr<SGPropertyNode> _rootNode;
|
||||||
|
|
||||||
|
typedef std::pair<std::string, SGSharedPtr<sg::HLAPropertyDataElement> > PathDataElementPair;
|
||||||
|
typedef std::list<PathDataElementPair> PathDataElementPairList;
|
||||||
|
PathDataElementPairList _pathDataElementPairList;
|
||||||
|
};
|
||||||
|
|
||||||
class AbstractSimTime : public SGReferenced {
|
class AbstractSimTime : public SGReferenced {
|
||||||
public:
|
public:
|
||||||
virtual ~AbstractSimTime() {}
|
virtual ~AbstractSimTime() {}
|
||||||
|
@ -533,7 +561,7 @@ private:
|
||||||
// Factory class that is used to create an apternative data element for the multiplayer property attribute
|
// Factory class that is used to create an apternative data element for the multiplayer property attribute
|
||||||
class MPPropertyVariantDataElementFactory : public sg::HLAVariantArrayDataElement::AlternativeDataElementFactory {
|
class MPPropertyVariantDataElementFactory : public sg::HLAVariantArrayDataElement::AlternativeDataElementFactory {
|
||||||
public:
|
public:
|
||||||
MPPropertyVariantDataElementFactory(sg::HLAPropertyReferenceSet* propertyReferenceSet) :
|
MPPropertyVariantDataElementFactory(PropertyReferenceSet* propertyReferenceSet) :
|
||||||
_propertyReferenceSet(propertyReferenceSet)
|
_propertyReferenceSet(propertyReferenceSet)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -551,19 +579,19 @@ public:
|
||||||
|
|
||||||
// The relative property path should be in the semantics field name
|
// The relative property path should be in the semantics field name
|
||||||
std::string relativePath = dataType->getAlternativeSemantics(index);
|
std::string relativePath = dataType->getAlternativeSemantics(index);
|
||||||
sg::HLAPropertyReference* propertyReference = new sg::HLAPropertyReference(relativePath);
|
sg::HLAPropertyDataElement* dataElement = new sg::HLAPropertyDataElement(alternativeDataType, (SGPropertyNode*)0);
|
||||||
_propertyReferenceSet->insert(propertyReference);
|
_propertyReferenceSet->insert(relativePath, dataElement);
|
||||||
return new sg::HLAPropertyDataElement(alternativeDataType, propertyReference);
|
return dataElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SGSharedPtr<sg::HLAPropertyReferenceSet> _propertyReferenceSet;
|
SGSharedPtr<PropertyReferenceSet> _propertyReferenceSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MPAttributeCallback : public sg::HLAObjectInstance::AttributeCallback {
|
class MPAttributeCallback : public sg::HLAObjectInstance::AttributeCallback {
|
||||||
public:
|
public:
|
||||||
MPAttributeCallback() :
|
MPAttributeCallback() :
|
||||||
_propertyReferenceSet(new sg::HLAPropertyReferenceSet),
|
_propertyReferenceSet(new PropertyReferenceSet),
|
||||||
_mpProperties(new sg::HLAVariantArrayDataElement)
|
_mpProperties(new sg::HLAVariantArrayDataElement)
|
||||||
{
|
{
|
||||||
_mpProperties->setAlternativeDataElementFactory(new MPPropertyVariantDataElementFactory(_propertyReferenceSet.get()));
|
_mpProperties->setAlternativeDataElementFactory(new MPPropertyVariantDataElementFactory(_propertyReferenceSet.get()));
|
||||||
|
@ -595,7 +623,7 @@ public:
|
||||||
sg::HLAVariantArrayDataElement* getMPProperties() const
|
sg::HLAVariantArrayDataElement* getMPProperties() const
|
||||||
{ return _mpProperties.get(); }
|
{ return _mpProperties.get(); }
|
||||||
|
|
||||||
SGSharedPtr<sg::HLAPropertyReferenceSet> _propertyReferenceSet;
|
SGSharedPtr<PropertyReferenceSet> _propertyReferenceSet;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SGSharedPtr<sg::HLAAbstractLocation> _location;
|
SGSharedPtr<sg::HLAAbstractLocation> _location;
|
||||||
|
@ -792,7 +820,7 @@ private:
|
||||||
|
|
||||||
objectInstance.setAttributes(attributePathElementMap);
|
objectInstance.setAttributes(attributePathElementMap);
|
||||||
}
|
}
|
||||||
void attachPropertyDataElements(sg::HLAPropertyReferenceSet& propertyReferenceSet,
|
void attachPropertyDataElements(PropertyReferenceSet& propertyReferenceSet,
|
||||||
sg::HLAAttributePathElementMap& attributePathElementMap,
|
sg::HLAAttributePathElementMap& attributePathElementMap,
|
||||||
const AttributePathPropertyMap& attributePathPropertyMap)
|
const AttributePathPropertyMap& attributePathPropertyMap)
|
||||||
{
|
{
|
||||||
|
@ -800,10 +828,9 @@ private:
|
||||||
i != attributePathPropertyMap.end(); ++i) {
|
i != attributePathPropertyMap.end(); ++i) {
|
||||||
for (PathPropertyMap::const_iterator j = i->second.begin();
|
for (PathPropertyMap::const_iterator j = i->second.begin();
|
||||||
j != i->second.end(); ++j) {
|
j != i->second.end(); ++j) {
|
||||||
SGSharedPtr<sg::HLAPropertyReference> propertyReference;
|
sg::HLAPropertyDataElement* dataElement = new sg::HLAPropertyDataElement;
|
||||||
propertyReference = new sg::HLAPropertyReference(j->second);
|
propertyReferenceSet.insert(j->second, dataElement);
|
||||||
propertyReferenceSet.insert(propertyReference);
|
attributePathElementMap[i->first][j->first] = dataElement;
|
||||||
attributePathElementMap[i->first][j->first] = new sg::HLAPropertyDataElement(propertyReference);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue