]> git.mxchange.org Git - simgear.git/blobdiff - simgear/hla/HLAObjectInstance.cxx
Make tsync part of libSimGearCore when building shared libraries
[simgear.git] / simgear / hla / HLAObjectInstance.cxx
index 0324d328b54a3584b6f811984e175007867f32af..22d8309e28a37bff77a9dfec28c774e63ff8f25e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 - 2010  Mathias Froehlich - Mathias.Froehlich@web.de
+// Copyright (C) 2009 - 2012  Mathias Froehlich - Mathias.Froehlich@web.de
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Library General Public
@@ -24,7 +24,7 @@
 #include "HLAEnumeratedDataElement.hxx"
 #include "HLAFixedRecordDataElement.hxx"
 #include "HLAObjectClass.hxx"
-#include "HLAVariantDataElement.hxx"
+#include "HLAVariantRecordDataElement.hxx"
 #include "RTIObjectClass.hxx"
 #include "RTIObjectInstance.hxx"
 
@@ -123,7 +123,7 @@ HLAObjectInstance::getAttributeDataElement(unsigned index) const
     return _rtiObjectInstance->getDataElement(index);
 }
 
-class HLAObjectInstance::DataElementFactoryVisitor : public HLADataTypeVisitor {
+class HLAObjectInstance::DataElementFactoryVisitor : public HLADataElementFactoryVisitor {
 public:
     DataElementFactoryVisitor(const HLAPathElementMap& pathElementMap) :
         _pathElementMap(pathElementMap)
@@ -150,7 +150,7 @@ public:
         if (_dataElement.valid())
             return;
 
-        _dataElement = new HLASCharDataElement(&dataType);
+        HLADataElementFactoryVisitor::apply(dataType);
     }
     virtual void apply(const HLAUInt8DataType& dataType)
     {
@@ -158,7 +158,7 @@ public:
         if (_dataElement.valid())
             return;
 
-        _dataElement = new HLAUCharDataElement(&dataType);
+        HLADataElementFactoryVisitor::apply(dataType);
     }
     virtual void apply(const HLAInt16DataType& dataType)
     {
@@ -166,7 +166,7 @@ public:
         if (_dataElement.valid())
             return;
 
-        _dataElement = new HLAShortDataElement(&dataType);
+        HLADataElementFactoryVisitor::apply(dataType);
     }
     virtual void apply(const HLAUInt16DataType& dataType)
     {
@@ -174,7 +174,7 @@ public:
         if (_dataElement.valid())
             return;
 
-        _dataElement = new HLAUShortDataElement(&dataType);
+        HLADataElementFactoryVisitor::apply(dataType);
     }
     virtual void apply(const HLAInt32DataType& dataType)
     {
@@ -182,7 +182,7 @@ public:
         if (_dataElement.valid())
             return;
 
-        _dataElement = new HLAIntDataElement(&dataType);
+        HLADataElementFactoryVisitor::apply(dataType);
     }
     virtual void apply(const HLAUInt32DataType& dataType)
     {
@@ -190,7 +190,7 @@ public:
         if (_dataElement.valid())
             return;
 
-        _dataElement = new HLAUIntDataElement(&dataType);
+        HLADataElementFactoryVisitor::apply(dataType);
     }
     virtual void apply(const HLAInt64DataType& dataType)
     {
@@ -198,7 +198,7 @@ public:
         if (_dataElement.valid())
             return;
 
-        _dataElement = new HLALongDataElement(&dataType);
+        HLADataElementFactoryVisitor::apply(dataType);
     }
     virtual void apply(const HLAUInt64DataType& dataType)
     {
@@ -206,7 +206,7 @@ public:
         if (_dataElement.valid())
             return;
 
-        _dataElement = new HLAULongDataElement(&dataType);
+        HLADataElementFactoryVisitor::apply(dataType);
     }
     virtual void apply(const HLAFloat32DataType& dataType)
     {
@@ -214,7 +214,7 @@ public:
         if (_dataElement.valid())
             return;
 
-        _dataElement = new HLAFloatDataElement(&dataType);
+        HLADataElementFactoryVisitor::apply(dataType);
     }
     virtual void apply(const HLAFloat64DataType& dataType)
     {
@@ -222,7 +222,7 @@ public:
         if (_dataElement.valid())
             return;
 
-        _dataElement = new HLADoubleDataElement(&dataType);
+        HLADataElementFactoryVisitor::apply(dataType);
     }
 
     class ArrayDataElementFactory : public HLAArrayDataElement::DataElementFactory {
@@ -287,7 +287,7 @@ public:
         if (_dataElement.valid())
             return;
 
-        _dataElement = new HLAEnumeratedDataElement(&dataType);
+        HLADataElementFactoryVisitor::apply(dataType);
     }
 
     virtual void apply(const HLAFixedRecordDataType& dataType)
@@ -312,9 +312,9 @@ public:
         _dataElement = recordDataElement;
     }
 
-    class VariantDataElementFactory : public HLAVariantDataElement::DataElementFactory {
+    class VariantRecordDataElementFactory : public HLAVariantRecordDataElement::DataElementFactory {
     public:
-        VariantDataElementFactory(const HLADataElement::Path& path, const HLAPathElementMap& pathElementMap) :
+        VariantRecordDataElementFactory(const HLADataElement::Path& path, const HLAPathElementMap& pathElementMap) :
             _path(path)
         {
             for (HLAPathElementMap::const_iterator i = pathElementMap.lower_bound(path);
@@ -325,9 +325,9 @@ public:
                 _pathElementMap.insert(*i);
             }
         }
-        virtual HLADataElement* createElement(const HLAVariantDataElement& element, unsigned index)
+        virtual HLADataElement* createElement(const HLAVariantRecordDataElement& element, unsigned index)
         {
-            const HLAVariantDataType* dataType = element.getDataType();
+            const HLAVariantRecordDataType* dataType = element.getDataType();
             if (!dataType)
                 return 0;
             const HLADataType* alternativeDataType = element.getAlternativeDataType();
@@ -344,22 +344,19 @@ public:
         HLAPathElementMap _pathElementMap;
     };
 
-    virtual void apply(const HLAVariantDataType& dataType)
+    virtual void apply(const HLAVariantRecordDataType& dataType)
     {
         _dataElement = createDataElement(_path, dataType);
         if (_dataElement.valid())
             return;
 
-        SGSharedPtr<HLAVariantDataElement> variantDataElement;
-        variantDataElement = new HLAVariantDataElement(&dataType);
-        variantDataElement->setDataElementFactory(new VariantDataElementFactory(_path, _pathElementMap));
+        SGSharedPtr<HLAVariantRecordDataElement> variantRecordDataElement;
+        variantRecordDataElement = new HLAVariantRecordDataElement(&dataType);
+        variantRecordDataElement->setDataElementFactory(new VariantRecordDataElementFactory(_path, _pathElementMap));
 
-        _dataElement = variantDataElement;
+        _dataElement = variantRecordDataElement;
     }
 
-    const SGSharedPtr<HLADataElement>& getDataElement() const
-    { return _dataElement; }
-
 private:
     SGSharedPtr<HLADataElement> createDataElement(const HLADataElement::Path& path, const HLADataType& dataType)
     {
@@ -381,7 +378,6 @@ private:
         return dataElement;
     }
 
-    SGSharedPtr<HLADataElement> _dataElement;
     const HLAPathElementMap& _pathElementMap;
     HLADataElement::Path _path;
 };
@@ -413,26 +409,6 @@ HLAObjectInstance::setAttributes(const HLAAttributePathElementMap& attributePath
     }
 }
 
-void
-HLAObjectInstance::requestAttributeUpdate(unsigned index)
-{
-    if (!_rtiObjectInstance.valid()) {
-        SG_LOG(SG_IO, SG_ALERT, "Trying to request attribute update for inactive object!");
-        return;
-    }
-    _rtiObjectInstance->setRequestAttributeUpdate(index, true);
-}
-
-void
-HLAObjectInstance::requestAttributeUpdate()
-{
-    if (!_rtiObjectInstance.valid()) {
-        SG_LOG(SG_IO, SG_ALERT, "Trying to request attribute update for inactive object!");
-        return;
-    }
-    _rtiObjectInstance->setRequestAttributeUpdate(true);
-}
-
 void
 HLAObjectInstance::registerInstance()
 {
@@ -471,16 +447,6 @@ HLAObjectInstance::deleteInstance(const RTIData& tag)
     _rtiObjectInstance->deleteObjectInstance(tag);
 }
 
-void
-HLAObjectInstance::localDeleteInstance()
-{
-    if (!_rtiObjectInstance.valid()) {
-        SG_LOG(SG_IO, SG_ALERT, "Trying to delete inactive object!");
-        return;
-    }
-   _rtiObjectInstance->localDeleteObjectInstance();
-}
-
 void
 HLAObjectInstance::updateAttributeValues(const RTIData& tag)
 {
@@ -505,16 +471,6 @@ HLAObjectInstance::updateAttributeValues(const SGTimeStamp& timeStamp, const RTI
     _rtiObjectInstance->updateAttributeValues(timeStamp, tag);
 }
 
-void
-HLAObjectInstance::reflectQueuedAttributeValues(const SGTimeStamp& timeStamp)
-{
-    if (!_rtiObjectInstance.valid()) {
-        SG_LOG(SG_IO, SG_INFO, "Not updating inactive object!");
-        return;
-    }
-    _rtiObjectInstance->reflectQueuedAttributeValues(timeStamp);
-}
-
 void
 HLAObjectInstance::removeInstance(const RTIData& tag)
 {