certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] applications/PyHLA/hla/_rti federateambassador....


From: certi-cvs
Subject: [certi-cvs] applications/PyHLA/hla/_rti federateambassador....
Date: Wed, 01 Oct 2008 21:08:58 +0000

CVSROOT:        /sources/certi
Module name:    applications
Changes by:     Petr Gotthard <gotthardp>       08/10/01 21:08:58

Modified files:
        PyHLA/hla/_rti : federateambassador.cpp handles.cpp handles.h 

Log message:
        Completed implementation of RTI:federateAmbassador.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/applications/PyHLA/hla/_rti/federateambassador.cpp?cvsroot=certi&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/applications/PyHLA/hla/_rti/handles.cpp?cvsroot=certi&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/applications/PyHLA/hla/_rti/handles.h?cvsroot=certi&r1=1.1&r2=1.2

Patches:
Index: federateambassador.cpp
===================================================================
RCS file: /sources/certi/applications/PyHLA/hla/_rti/federateambassador.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- federateambassador.cpp      25 Sep 2008 17:17:35 -0000      1.1
+++ federateambassador.cpp      1 Oct 2008 21:08:58 -0000       1.2
@@ -11,7 +11,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
- * $Id: federateambassador.cpp,v 1.1 2008/09/25 17:17:35 gotthardp Exp $
+ * $Id: federateambassador.cpp,v 1.2 2008/10/01 21:08:58 gotthardp Exp $
  */
 
 // note: you must include Python.h before any standard headers are included
@@ -305,15 +305,15 @@
     RTI::InvalidFederationTime, RTI::FederateInternalError)
 {
     // FIXME: theAttributes.getRegion() is not handled
-    // FIXME: EventRetractionHandle is not handled
 
     PyObject_CallMethod((PyObject *)m_federate,
-        "reflectAttributeValues", "O&O&OOs",
+        "reflectAttributeValues", "O&O&sOOO&",
         RtiObjectHandle_ToPython, &theObject,
         AttributeHandleValuePairSet_ToPython, &theAttributes,
+        theTag,
         RtiULongHandle_FromULong(&RtiOrderTypeType, 
theAttributes.getOrderType(0)),
         RtiULongHandle_FromULong(&RtiTransportTypeType, 
theAttributes.getTransportType(0)),
-        theTag);
+        EventRetractionHandle_ToPython, &theHandle);
 
     if(PyObject *exception = PyErr_Occurred()) {
         CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
@@ -348,15 +348,51 @@
 }
 
 void
-Py_FederateAmbassador::receiveInteraction(RTI::InteractionClassHandle, const 
RTI::ParameterHandleValuePairSet &, 
-    const RTI::FedTime &, const char *, RTI::EventRetractionHandle) 
-throw (RTI::InteractionClassNotKnown, RTI::InteractionParameterNotKnown, 
RTI::InvalidFederationTime,
-    RTI::FederateInternalError) { }
+Py_FederateAmbassador::receiveInteraction(RTI::InteractionClassHandle 
theInteraction,
+    const RTI::ParameterHandleValuePairSet& theParameters,
+    const RTI::FedTime& theTime, const char *theTag, 
RTI::EventRetractionHandle theHandle)
+throw (RTI::InteractionClassNotKnown, RTI::InteractionParameterNotKnown,
+    RTI::InvalidFederationTime, RTI::FederateInternalError)
+{
+    // FIXME: theParameters.getRegion() is not handled
+
+    PyObject_CallMethod((PyObject *)m_federate,
+        "receiveInteraction", "O&O&sOOO&",
+        RtiInteractionClassHandle_ToPython, &theInteraction,
+        ParameterHandleValuePairSet_ToPython, &theParameters,
+        theTag,
+        RtiULongHandle_FromULong(&RtiOrderTypeType, 
theParameters.getOrderType()),
+        RtiULongHandle_FromULong(&RtiTransportTypeType, 
theParameters.getTransportType()),
+        EventRetractionHandle_ToPython, &theHandle);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, InteractionClassNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, InteractionParameterNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, InvalidFederationTime)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::receiveInteraction(RTI::InteractionClassHandle, const 
RTI::ParameterHandleValuePairSet &, 
-    const char *) 
-throw (RTI::InteractionClassNotKnown, RTI::InteractionParameterNotKnown, 
RTI::FederateInternalError) { }
+Py_FederateAmbassador::receiveInteraction(RTI::InteractionClassHandle 
theInteraction,
+    const RTI::ParameterHandleValuePairSet& theParameters, const char *theTag)
+throw (RTI::InteractionClassNotKnown, RTI::InteractionParameterNotKnown,
+    RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "receiveInteraction", "O&O&sOO",
+        RtiInteractionClassHandle_ToPython, &theInteraction,
+        ParameterHandleValuePairSet_ToPython, &theParameters,
+        theTag,
+        RtiULongHandle_FromULong(&RtiOrderTypeType, 
theParameters.getOrderType()),
+        RtiULongHandle_FromULong(&RtiTransportTypeType, 
theParameters.getTransportType()));
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, InteractionClassNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, InteractionParameterNotKnown)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
 Py_FederateAmbassador::removeObjectInstance(RTI::ObjectHandle theObject, const 
RTI::FedTime &theTime,
@@ -366,10 +402,11 @@
     const RTIfedTime& time = theTime;
 
     PyObject_CallMethod((PyObject *)m_federate,
-        "removeObjectInstance", "O&sd",
+        "removeObjectInstance", "O&sdO&",
         RtiObjectHandle_ToPython, &theObject,
         theTag,
-        time.getTime());
+        time.getTime(),
+        EventRetractionHandle_ToPython, &theHandle);
 
     if(PyObject *exception = PyErr_Occurred()) {
         CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
@@ -383,10 +420,9 @@
 throw (RTI::ObjectNotKnown, RTI::FederateInternalError)
 {
     PyObject_CallMethod((PyObject *)m_federate,
-        "removeObjectInstance", "O&sO",
+        "removeObjectInstance", "O&s",
         RtiObjectHandle_ToPython, &theObject,
-        theTag,
-        Py_None); // no RTI::FedTime provided
+        theTag);
 
     if(PyObject *exception = PyErr_Occurred()) {
         CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
@@ -395,71 +431,259 @@
 }
 
 void
-Py_FederateAmbassador::attributesInScope(RTI::ObjectHandle, const 
RTI::AttributeHandleSet &) 
-throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, 
RTI::FederateInternalError) { }
+Py_FederateAmbassador::attributesInScope(RTI::ObjectHandle theObject, const 
RTI::AttributeHandleSet& theAttributes)
+throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "attributesInScope", "O&O&",
+        RtiObjectHandle_ToPython, &theObject,
+        AttributeHandleSet_ToPython, &theAttributes);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotKnown)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::attributesOutOfScope(RTI::ObjectHandle, const 
RTI::AttributeHandleSet &) 
-throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, 
RTI::FederateInternalError) { }
+Py_FederateAmbassador::attributesOutOfScope(RTI::ObjectHandle theObject, const 
RTI::AttributeHandleSet& theAttributes)
+throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "attributesOutOfScope", "O&O&",
+        RtiObjectHandle_ToPython, &theObject,
+        AttributeHandleSet_ToPython, &theAttributes);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotKnown)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::provideAttributeValueUpdate(RTI::ObjectHandle, const 
RTI::AttributeHandleSet &) 
+Py_FederateAmbassador::provideAttributeValueUpdate(RTI::ObjectHandle 
theObject, const RTI::AttributeHandleSet& theAttributes)
 throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::AttributeNotOwned,
-    RTI::FederateInternalError) { }
+    RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "provideAttributeValueUpdate", "O&O&",
+        RtiObjectHandle_ToPython, &theObject,
+        AttributeHandleSet_ToPython, &theAttributes);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotOwned)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::turnUpdatesOnForObjectInstance(RTI::ObjectHandle, const 
RTI::AttributeHandleSet &) 
-throw (RTI::ObjectNotKnown, RTI::AttributeNotOwned, 
RTI::FederateInternalError) { }
+Py_FederateAmbassador::turnUpdatesOnForObjectInstance(RTI::ObjectHandle 
theObject, const RTI::AttributeHandleSet& theAttributes)
+throw (RTI::ObjectNotKnown, RTI::AttributeNotOwned, RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "turnUpdatesOnForObjectInstance", "O&O&",
+        RtiObjectHandle_ToPython, &theObject,
+        AttributeHandleSet_ToPython, &theAttributes);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotOwned)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::turnUpdatesOffForObjectInstance(RTI::ObjectHandle, 
const RTI::AttributeHandleSet &) 
-throw (RTI::ObjectNotKnown, RTI::AttributeNotOwned, 
RTI::FederateInternalError) { }
+Py_FederateAmbassador::turnUpdatesOffForObjectInstance(RTI::ObjectHandle 
theObject, const RTI::AttributeHandleSet& theAttributes)
+throw (RTI::ObjectNotKnown, RTI::AttributeNotOwned, RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "turnUpdatesOffForObjectInstance", "O&O&",
+        RtiObjectHandle_ToPython, &theObject,
+        AttributeHandleSet_ToPython, &theAttributes);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotOwned)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 // Ownership Management
 
 void
-Py_FederateAmbassador::requestAttributeOwnershipAssumption(RTI::ObjectHandle, 
const RTI::AttributeHandleSet &, 
-    const char *) 
+Py_FederateAmbassador::requestAttributeOwnershipAssumption(RTI::ObjectHandle 
theObject,
+    const RTI::AttributeHandleSet& offeredAttributes, const char *theTag)
 throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::AttributeAlreadyOwned,
-    RTI::AttributeNotPublished, RTI::FederateInternalError) { }
+    RTI::AttributeNotPublished, RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "requestAttributeOwnershipAssumption", "O&O&s",
+        RtiObjectHandle_ToPython, &theObject,
+        AttributeHandleSet_ToPython, &offeredAttributes,
+        theTag);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeAlreadyOwned)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotPublished)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::attributeOwnershipDivestitureNotification(RTI::ObjectHandle,
 const RTI::AttributeHandleSet &) 
+Py_FederateAmbassador::attributeOwnershipDivestitureNotification(RTI::ObjectHandle
 theObject,
+    const RTI::AttributeHandleSet& releasedAttributes)
 throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::AttributeNotOwned,
-    RTI::AttributeDivestitureWasNotRequested, RTI::FederateInternalError) { }
+    RTI::AttributeDivestitureWasNotRequested, RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "attributeOwnershipDivestitureNotification", "O&O&",
+        RtiObjectHandle_ToPython, &theObject,
+        AttributeHandleSet_ToPython, &releasedAttributes);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotOwned)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeDivestitureWasNotRequested)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::attributeOwnershipAcquisitionNotification(RTI::ObjectHandle,
 const RTI::AttributeHandleSet &) 
+Py_FederateAmbassador::attributeOwnershipAcquisitionNotification(RTI::ObjectHandle
 theObject,
+    const RTI::AttributeHandleSet& securedAttributes)
 throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, 
RTI::AttributeAcquisitionWasNotRequested,
-    RTI::AttributeAlreadyOwned, RTI::AttributeNotPublished, 
RTI::FederateInternalError) { }
+    RTI::AttributeAlreadyOwned, RTI::AttributeNotPublished, 
RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "attributeOwnershipAcquisitionNotification", "O&O&",
+        RtiObjectHandle_ToPython, &theObject,
+        AttributeHandleSet_ToPython, &securedAttributes);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeAcquisitionWasNotRequested)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeAlreadyOwned)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotPublished)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::attributeOwnershipUnavailable(RTI::ObjectHandle, const 
RTI::AttributeHandleSet &) 
+Py_FederateAmbassador::attributeOwnershipUnavailable(RTI::ObjectHandle 
theObject, const RTI::AttributeHandleSet& theAttributes)
 throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::AttributeAlreadyOwned,
-    RTI::AttributeAcquisitionWasNotRequested, RTI::FederateInternalError) { }
+    RTI::AttributeAcquisitionWasNotRequested, RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "attributeOwnershipUnavailable", "O&O&",
+        RtiObjectHandle_ToPython, &theObject,
+        AttributeHandleSet_ToPython, &theAttributes);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeAlreadyOwned)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeAcquisitionWasNotRequested)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::requestAttributeOwnershipRelease(RTI::ObjectHandle, 
const RTI::AttributeHandleSet &, 
-    const char *) 
-throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::AttributeNotOwned, 
RTI::FederateInternalError) { }
+Py_FederateAmbassador::requestAttributeOwnershipRelease(RTI::ObjectHandle 
theObject,
+    const RTI::AttributeHandleSet& candidateAttribute, const char *theTag)
+throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::AttributeNotOwned,
+    RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "requestAttributeOwnershipRelease", "O&O&s",
+        RtiObjectHandle_ToPython, &theObject,
+        AttributeHandleSet_ToPython, &candidateAttribute,
+        theTag);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotOwned)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::confirmAttributeOwnershipAcquisitionCancellation(RTI::ObjectHandle,
-    const RTI::AttributeHandleSet &) 
+Py_FederateAmbassador::confirmAttributeOwnershipAcquisitionCancellation(RTI::ObjectHandle
 theObject,
+    const RTI::AttributeHandleSet& theAttributes)
 throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::AttributeAlreadyOwned,
-    RTI::AttributeAcquisitionWasNotCanceled, RTI::FederateInternalError) { }
+    RTI::AttributeAcquisitionWasNotCanceled, RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "confirmAttributeOwnershipAcquisitionCancellation", "O&O&",
+        RtiObjectHandle_ToPython, &theObject,
+        AttributeHandleSet_ToPython, &theAttributes);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeAlreadyOwned)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeAcquisitionWasNotCanceled)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::informAttributeOwnership(RTI::ObjectHandle, 
RTI::AttributeHandle, RTI::FederateHandle) 
-throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, 
RTI::FederateInternalError) { }
+Py_FederateAmbassador::informAttributeOwnership(RTI::ObjectHandle theObject,
+    RTI::AttributeHandle theAttribute, RTI::FederateHandle theOwner)
+throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "informAttributeOwnership", "O&O&O&",
+        RtiObjectHandle_ToPython, &theObject,
+        RtiAttributeHandle_ToPython, &theAttribute,
+        RtiFederateHandle_ToPython, &theOwner);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotKnown)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::attributeIsNotOwned(RTI::ObjectHandle, 
RTI::AttributeHandle) 
-throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, 
RTI::FederateInternalError) { }
+Py_FederateAmbassador::attributeIsNotOwned(RTI::ObjectHandle theObject, 
RTI::AttributeHandle theAttribute)
+throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "attributeIsNotOwned", "O&O&",
+        RtiObjectHandle_ToPython, &theObject,
+        RtiAttributeHandle_ToPython, &theAttribute);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotKnown)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 void
-Py_FederateAmbassador::attributeOwnedByRTI(RTI::ObjectHandle, 
RTI::AttributeHandle) 
-throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, 
RTI::FederateInternalError) { }
+Py_FederateAmbassador::attributeOwnedByRTI(RTI::ObjectHandle theObject, 
RTI::AttributeHandle theAttribute)
+throw (RTI::ObjectNotKnown, RTI::AttributeNotKnown, RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "attributeOwnedByRTI", "O&O&",
+        RtiObjectHandle_ToPython, &theObject,
+        RtiAttributeHandle_ToPython, &theAttribute);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, ObjectNotKnown)
+        CATCH_PYTHON_EXCEPTION(exception, AttributeNotKnown)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 // Time Management
 
@@ -512,8 +736,18 @@
 }
 
 void
-Py_FederateAmbassador::requestRetraction(RTI::EventRetractionHandle) 
-throw (RTI::EventNotKnown, RTI::FederateInternalError) { }
+Py_FederateAmbassador::requestRetraction(RTI::EventRetractionHandle theHandle)
+throw (RTI::EventNotKnown, RTI::FederateInternalError)
+{
+    PyObject_CallMethod((PyObject *)m_federate,
+        "requestRetraction", "O&",
+        EventRetractionHandle_ToPython, &theHandle);
+
+    if(PyObject *exception = PyErr_Occurred()) {
+        CATCH_PYTHON_EXCEPTION(exception, EventNotKnown)
+        throw SetFromPyException<RTI::FederateInternalError>(exception);
+    }
+}
 
 static PyMethodDef federate_methods[] =
 {
@@ -589,4 +823,4 @@
     PyModule_AddObject(module, "FederateAmbassador", (PyObject 
*)&FederateAmbassadorObjectType);
 }
 
-// $Id: federateambassador.cpp,v 1.1 2008/09/25 17:17:35 gotthardp Exp $
+// $Id: federateambassador.cpp,v 1.2 2008/10/01 21:08:58 gotthardp Exp $

Index: handles.cpp
===================================================================
RCS file: /sources/certi/applications/PyHLA/hla/_rti/handles.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- handles.cpp 25 Sep 2008 17:17:35 -0000      1.1
+++ handles.cpp 1 Oct 2008 21:08:58 -0000       1.2
@@ -11,7 +11,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
- * $Id: handles.cpp,v 1.1 2008/09/25 17:17:35 gotthardp Exp $
+ * $Id: handles.cpp,v 1.2 2008/10/01 21:08:58 gotthardp Exp $
  */
 
 // note: you must include Python.h before any standard headers are included
@@ -51,16 +51,14 @@
     return 1; // success
 }
 
-PyObject *RtiObjectClassHandle_ToPython(void *addr)
+PyObject *RtiObjectClassHandle_ToPython(RTI::ObjectClassHandle *value)
 {
-    RTI::ObjectClassHandle& value = *(RTI::ObjectClassHandle *)addr;
-    return RtiULongHandle_FromULong(&RtiObjectClassHandleType, value);
+    return RtiULongHandle_FromULong(&RtiObjectClassHandleType, *value);
 }
 
-PyObject *RtiInteractionClassHandle_ToPython(void *addr)
+PyObject *RtiInteractionClassHandle_ToPython(RTI::InteractionClassHandle 
*value)
 {
-    RTI::InteractionClassHandle& value = *(RTI::InteractionClassHandle *)addr;
-    return RtiULongHandle_FromULong(&RtiInteractionClassHandleType, value);
+    return RtiULongHandle_FromULong(&RtiInteractionClassHandleType, *value);
 }
 
 int RtiAttributeHandle_FromPython(RtiULongHandleObject *value, 
RTI::AttributeHandle *result)
@@ -75,6 +73,23 @@
     return 1; // success
 }
 
+PyObject *RtiAttributeHandle_ToPython(RTI::AttributeHandle *value)
+{
+    return RtiULongHandle_FromULong(&RtiAttributeHandleType, *value);
+}
+
+int RtiParameterHandle_FromPython(RtiULongHandleObject *value, 
RTI::ParameterHandle *result)
+{
+    if(result == NULL || !PyObject_TypeCheck(value, &RtiParameterHandleType)) {
+        PyErr_SetString(PyExc_TypeError,
+            "ParameterHandle object required");
+        return 0; // failure
+    }
+
+    *result = value->ob_ival;
+    return 1; // success
+}
+
 int RtiObjectHandle_FromPython(RtiULongHandleObject *value, RTI::ObjectHandle 
*result)
 {
     if(result == NULL || !PyObject_TypeCheck(value, &RtiObjectHandleType)) {
@@ -132,6 +147,16 @@
     return 1; // success
 }
 
+PyObject *
+AttributeHandleSet_ToPython(RTI::AttributeHandleSet *value)
+{
+    PyObject *result = PyTuple_New(value->size());
+    for(RTI::ULong i = 0; i < value->size(); i++)
+        PyTuple_SetItem(result, i, 
RtiULongHandle_FromULong(&RtiAttributeHandleType, value->getHandle(i)));
+
+    return result;
+}
+
 int
 AttributeHandleValuePairSet_FromPython(PyObject *value, 
RTI::AttributeHandleValuePairSet **result)
 {
@@ -194,6 +219,68 @@
     return result;
 }
 
+int
+ParameterHandleValuePairSet_FromPython(PyObject *value, 
RTI::ParameterHandleValuePairSet **result)
+{
+    if(value == NULL || !PyMapping_Check(value)) {
+        PyErr_SetString(PyExc_TypeError,
+            "mapping {ParameterHandle:string} required");
+        return 0; // failure
+    }
+
+    PyObject *items = PyMapping_Items(value);
+    if(items == NULL)
+        return 0; // failure
+
+    PyObject *iter = PyObject_GetIter(items);
+    if(iter == NULL) {
+        Py_DECREF(items);
+        return 0; // failure
+    }
+
+    *result = RTI::ParameterSetFactory::create(PySequence_Size(items));
+
+    PyObject *item;
+    while((item = PyIter_Next(iter)) != NULL) {
+        RTI::ParameterHandle theHandle;
+        const char *valueData;
+        int valueSize;
+
+        if(!PyArg_ParseTuple(item, "O&s#",
+            RtiParameterHandle_FromPython, &theHandle,
+            &valueData, &valueSize))
+            return 0; // failure
+
+        (*result)->add(theHandle, valueData, valueSize);
+    }
+
+    Py_DECREF(iter);
+    Py_DECREF(items);
+
+    return 1; // success
+}
+
+PyObject *
+ParameterHandleValuePairSet_ToPython(RTI::ParameterHandleValuePairSet *value)
+{
+    PyObject *result = PyDict_New();
+    for(RTI::ULong i = 0; i < value->size(); i++)
+    {
+        PyObject *atHandle = RtiULongHandle_FromULong(&RtiParameterHandleType, 
value->getHandle(i));
+
+        RTI::ULong length;
+        char* data = value->getValuePointer(i, length);
+        PyObject *atData = PyString_FromStringAndSize(data, length);
+
+        PyDict_SetItem(result, atHandle, atData);
+
+        Py_DECREF(atHandle);
+        Py_DECREF(atData);
+    }
+
+    return result;
+}
+
 static int
 ulonghandle_print(RtiULongHandleObject *v, FILE *fp, int flags)
 {
@@ -576,4 +663,4 @@
     PyModule_AddObject(module, "EventRetractionHandle", (PyObject 
*)&EventRetractionHandleType);
 }
 
-// $Id: handles.cpp,v 1.1 2008/09/25 17:17:35 gotthardp Exp $
+// $Id: handles.cpp,v 1.2 2008/10/01 21:08:58 gotthardp Exp $

Index: handles.h
===================================================================
RCS file: /sources/certi/applications/PyHLA/hla/_rti/handles.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- handles.h   25 Sep 2008 17:17:36 -0000      1.1
+++ handles.h   1 Oct 2008 21:08:58 -0000       1.2
@@ -11,7 +11,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
- * $Id: handles.h,v 1.1 2008/09/25 17:17:36 gotthardp Exp $
+ * $Id: handles.h,v 1.2 2008/10/01 21:08:58 gotthardp Exp $
  */
 
 #ifndef RTI_HANDLES_H
@@ -37,9 +37,14 @@
 PyObject* RtiULongHandle_FromULong(PyTypeObject *type, unsigned long val);
 
 int RtiObjectClassHandle_FromPython(RtiULongHandleObject *value, 
RTI::ObjectClassHandle *addr);
-PyObject *RtiObjectClassHandle_ToPython(void *addr);
-PyObject *RtiInteractionClassHandle_ToPython(void *addr);
+PyObject *RtiObjectClassHandle_ToPython(RTI::ObjectClassHandle *value);
+
+PyObject *RtiInteractionClassHandle_ToPython(RTI::InteractionClassHandle 
*value);
+
 int RtiAttributeHandle_FromPython(RtiULongHandleObject *value, 
RTI::AttributeHandle *result);
+PyObject *RtiAttributeHandle_ToPython(RTI::AttributeHandle *value);
+
+int RtiParameterHandle_FromPython(RtiULongHandleObject *value, 
RTI::ParameterHandle *result);
 
 int RtiObjectHandle_FromPython(RtiULongHandleObject *value, RTI::ObjectHandle 
*result);
 PyObject *RtiObjectHandle_ToPython(RTI::ObjectHandle *value);
@@ -47,10 +52,14 @@
 PyObject *RtiFederateHandle_ToPython(RTI::FederateHandle *value);
 
 int AttributeHandleSet_FromPython(PyObject *value, RTI::AttributeHandleSet 
**result);
+PyObject *AttributeHandleSet_ToPython(RTI::AttributeHandleSet *value);
 
 int AttributeHandleValuePairSet_FromPython(PyObject *value, 
RTI::AttributeHandleValuePairSet **result);
 PyObject 
*AttributeHandleValuePairSet_ToPython(RTI::AttributeHandleValuePairSet *value);
 
+int ParameterHandleValuePairSet_FromPython(PyObject *value, 
RTI::ParameterHandleValuePairSet **result);
+PyObject 
*ParameterHandleValuePairSet_ToPython(RTI::ParameterHandleValuePairSet *value);
+
 typedef struct {
     PyObject_HEAD
     RTI::EventRetractionHandle ob_value;
@@ -65,4 +74,4 @@
 
 #endif // RTI_HANDLES_H
 
-// $Id: handles.h,v 1.1 2008/09/25 17:17:36 gotthardp Exp $
+// $Id: handles.h,v 1.2 2008/10/01 21:08:58 gotthardp Exp $




reply via email to

[Prev in Thread] Current Thread [Next in Thread]