? startRegForObjClass2.diff
Index: RTIA/DeclarationManagement.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/DeclarationManagement.cc,v
retrieving revision 3.25
diff -u -r3.25 DeclarationManagement.cc
--- RTIA/DeclarationManagement.cc	21 Nov 2008 13:41:52 -0000	3.25
+++ RTIA/DeclarationManagement.cc	3 Apr 2009 06:46:58 -0000
@@ -387,26 +387,16 @@
 startRegistrationForObjectClass(ObjectClassHandle the_class,
                                 TypeException &e)
 {
-    Message req, rep ;
-
-    // Pas de partie locale
+    G.Out(pdGendoc,"enter DeclarationManagement::startRegistrationForObjectClass");
 
-    // Partie Federe
+    Message req;
 
     req.type = Message::START_REGISTRATION_FOR_OBJECT_CLASS ;
     req.setObjectClass(the_class);
 
-    comm->sendUN(&req);
+    comm->requestFederateService(&req);
 
-    comm->receiveUN(&rep);
-
-    if (rep.type != req.type) {
-        D.Out(pdExcept, "Unknown response type when waiting for "
-              "START_REGISTRATION_FOR_OBJECT_CLASS.");
-        throw RTIinternalError("");
-    }
-
-    e = rep.getExceptionType();
+    G.Out(pdGendoc,"exit  DeclarationManagement::startRegistrationForObjectClass");
 }
 
 // ----------------------------------------------------------------------------
Index: RTIA/Files.hh
===================================================================
RCS file: /sources/certi/certi/RTIA/Files.hh,v
retrieving revision 3.7
diff -u -r3.7 Files.hh
--- RTIA/Files.hh	30 Apr 2005 16:38:39 -0000	3.7
+++ RTIA/Files.hh	3 Apr 2009 06:46:58 -0000
@@ -25,6 +25,7 @@
 #define CERTI_RTIA_FILES_HH
 
 #include "FederationManagement.hh"
+#include "DeclarationManagement.hh"
 #include "ObjectManagement.hh"
 #include "NetworkMessage.hh"
 
@@ -35,6 +36,7 @@
 namespace rtia {
 
 class FederationManagement ;
+class DeclarationManagement ;
 class ObjectManagement ;
 
 class Queues
@@ -57,6 +59,7 @@
     NetworkMessage *giveCommandMessage(bool &msg_donne, bool &msg_restant);
 
     FederationManagement *fm ;
+    DeclarationManagement *dm ;
     ObjectManagement *om ;
 
 private:
Index: RTIA/RTIA.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA.cc,v
retrieving revision 3.24
diff -u -r3.24 RTIA.cc
--- RTIA/RTIA.cc	27 Jun 2008 08:22:11 -0000	3.24
+++ RTIA/RTIA.cc	3 Apr 2009 06:46:58 -0000
@@ -50,11 +50,12 @@
     om     = new ObjectManagement(comm, fm, rootObject);
     owm    = new OwnershipManagement(comm, fm);
     dm     = new DeclarationManagement(comm, fm, rootObject);
-    tm     = new TimeManagement(comm, queues, fm, om, owm);
+    tm     = new TimeManagement(comm, queues, fm, dm, om, owm);
     ddm    = new DataDistribution(rootObject, fm, comm);
 
     fm->tm     = tm ;
     queues->fm = fm ;
+    queues->dm = dm ;
     om->tm     = tm ;
 }
 
Index: RTIA/RTIA_network.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA_network.cc,v
retrieving revision 3.31
diff -u -r3.31 RTIA_network.cc
--- RTIA/RTIA_network.cc	2 Apr 2009 19:58:12 -0000	3.31
+++ RTIA/RTIA_network.cc	3 Apr 2009 06:46:58 -0000
@@ -352,6 +352,11 @@
     	  D.Out(pdTrace, "Receiving Message from RTIG, "
     			  " type setASAS.");
 	  break;
+      case NetworkMessage::START_REGISTRATION_FOR_OBJECT_CLASS:
+    	  D.Out(pdTrace, "Receiving Message from RTIG, "
+    			  " type StartRegForObjClass.");
+    	  queues->insertLastCommand(msg);
+	  break;
       	
       default:
       {
Index: RTIA/Statistics.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/Statistics.cc,v
retrieving revision 3.18
diff -u -r3.18 Statistics.cc
--- RTIA/Statistics.cc	6 Nov 2008 14:28:58 -0000	3.18
+++ RTIA/Statistics.cc	3 Apr 2009 06:46:58 -0000
@@ -298,6 +298,12 @@
 	RTI_MSG_NAME(NetworkMessage::DDM_UNSUBSCRIBE_INTERACTION);
         RTI_MSG_NAME(NetworkMessage::PROVIDE_ATTRIBUTE_VALUE_UPDATE);
         RTI_MSG_NAME(NetworkMessage::GET_FED_FILE);
+	RTI_MSG_NAME(NetworkMessage::SET_CLASS_RELEVANCE_ADVISORY_SWITCH);
+	RTI_MSG_NAME(NetworkMessage::SET_INTERACTION_RELEVANCE_ADVISORY_SWITCH);
+	RTI_MSG_NAME(NetworkMessage::SET_ATTRIBUTE_RELEVANCE_ADVISORY_SWITCH);
+	RTI_MSG_NAME(NetworkMessage::SET_ATTRIBUTE_SCOPE_ADVISORY_SWITCH);
+	RTI_MSG_NAME(NetworkMessage::START_REGISTRATION_FOR_OBJECT_CLASS);
+	RTI_MSG_NAME(NetworkMessage::STOP_REGISTRATION_FOR_OBJECT_CLASS);
 
         initialized = true ;
     }
Index: RTIA/TimeManagement.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/TimeManagement.cc,v
retrieving revision 3.46
diff -u -r3.46 TimeManagement.cc
--- RTIA/TimeManagement.cc	2 Apr 2009 19:58:12 -0000	3.46
+++ RTIA/TimeManagement.cc	3 Apr 2009 06:46:58 -0000
@@ -69,6 +69,7 @@
 TimeManagement::TimeManagement(Communications *GC,
                                Queues *GQueues,
                                FederationManagement *GF,
+                               DeclarationManagement *GD,
                                ObjectManagement *GO,
                                OwnershipManagement *GP)
     : LBTS()
@@ -76,6 +77,7 @@
     comm = GC ;
     queues = GQueues ;
     fm = GF ;
+    dm = GD ;
     om = GO ;
     owm = GP ;
 
@@ -365,6 +367,9 @@
       case NetworkMessage::TIME_CONSTRAINED_ENABLED:
         this->timeConstrainedEnabled(msg.getDate(), msg.exception);
         break;
+      case NetworkMessage::START_REGISTRATION_FOR_OBJECT_CLASS:
+	dm->startRegistrationForObjectClass(msg.objectClass, msg.exception);
+        break;
 
       default:
 	std::stringstream errorMsg;
@@ -759,7 +764,6 @@
     // 1st try, give a command message. (requestPause, etc.)
     msg = queues->giveCommandMessage(msg_donne, msg_restant);
 
-
     // 2nd try, give a FIFO message. (discoverObject, etc.)
     if (!msg_donne){
         if ( _asynchronous_delivery || (_avancee_en_cours != PAS_D_AVANCEE) || (! _est_contraint)) {
Index: RTIA/TimeManagement.hh
===================================================================
RCS file: /sources/certi/certi/RTIA/TimeManagement.hh,v
retrieving revision 3.18
diff -u -r3.18 TimeManagement.hh
--- RTIA/TimeManagement.hh	3 Jun 2008 08:45:49 -0000	3.18
+++ RTIA/TimeManagement.hh	3 Apr 2009 06:46:58 -0000
@@ -28,6 +28,7 @@
 #include "certi.hh"
 #include "Communications.hh"
 #include "FederationManagement.hh"
+#include "DeclarationManagement.hh"
 #include "ObjectManagement.hh"
 #include "OwnershipManagement.hh"
 #include "Files.hh"
@@ -75,6 +76,7 @@
     TimeManagement(Communications *,
                    Queues*,
                    FederationManagement *,
+		   DeclarationManagement *,
                    ObjectManagement *,
                    OwnershipManagement *);
 
@@ -135,6 +137,7 @@
     Communications *comm ;
     Queues *queues ;
     FederationManagement *fm ;
+    DeclarationManagement *dm ;
     ObjectManagement *om ;
     OwnershipManagement *owm ;
 
Index: RTIG/Federation.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/Federation.cc,v
retrieving revision 3.104
diff -u -r3.104 Federation.cc
--- RTIG/Federation.cc	2 Apr 2009 19:58:09 -0000	3.104
+++ RTIG/Federation.cc	3 Apr 2009 06:46:59 -0000
@@ -1779,47 +1779,93 @@
     // It may throw *NotDefined
     root->ObjectClasses->subscribe(federate, object, attributes, list_size);
 
-    // get object class from object class handle	
-    ObjectClass *objectClass = root->ObjectClasses->getObjectFromHandle(object);
+    /*
+     * The subscription process in CERTI:
+     * In RTIG.cc the network messages SUBSCRIBE_OBJECT_CLASS and UNSUBSCRIBE_
+     * OBJECT_CLASS are both mapped to the method processSubscribeObject within
+     * RTIG_processing.cc. RTIG_proccessing invokes this method 
+     * (subscribeObject). 
+     * The above code line (root->ObjectClasses->subscribe(...) calls the 
+     * subscription within the CERTI library in ObjectClassSet.cc. Further on,
+     * ObjectClassSet::subscribe invokes ObjectClass::subscribe. That method 
+     * first unsubscribes all attributes, afterwards the subscription is 
+     * done in a for loop til list_size.  
+     * This means: Unsubscription and subscription are realized by the same
+     * method. Only the list_size parameter controls the
+     * unsubscription/subscription process.
+     *
+     * Do we need a cleaner solution, e.g. separate methods for subscription/
+     * unsubscription?
+     */
+
+    if (list_size!=0) {  // do only for subscription
+        // get object class from object class handle	
+        ObjectClass *objectClass = root->ObjectClasses->getObjectFromHandle(object);
+
+        // get attributes of object class
+        ObjectClass::AttributeList_t attrForObjClass = objectClass->getAttributeList();
+
+        ObjectClassAttribute::PublishersList_t publishers;
+        publishers.clear();
+
+        // get publishers of attributes	
+        // first for: iterate through the attribute list and get publishers of 
+        //            each attribtue
+        // second for: iterate through the temporal publishers list and store 
+        //             non-duplicate entries in publishers
+        ObjectClassAttribute::PublishersList_t tmp_publishers;
+        tmp_publishers.clear();
+        for (ObjectClass::AttributeList_t::const_iterator 
+            i=attrForObjClass.begin();
+	    i!=attrForObjClass.end(); 
+	    i++) {
+    	    tmp_publishers = (*i)->getPublishers();
+            for (ObjectClassAttribute::PublishersList_t::const_iterator
+                j=tmp_publishers.begin(); 
+	        j!=tmp_publishers.end(); 
+	        j++) {
+	            // insert only non-duplicate entries ->
+	            // pair<iterator, bool> set::insert(const TYPE& val);
+	            publishers.insert(*j);
+            }
+	    tmp_publishers.clear();
+        }
 
-    // get attributes of object class
-    ObjectClass::AttributeList_t attrForObjClass = objectClass->getAttributeList();
+        // notify all publishers
+        std::set<FederateHandle> federate_set;
+
+        for (ObjectClassAttribute::PublishersList_t::const_iterator
+            k=publishers.begin(); 
+	    k!=publishers.end(); 
+	    k++) {
+
+	    if (getFederate(*k).isClassRelevanceAdvisorySwitch()) {
+	        federate_set.insert(*k);
+	    }
+        }
 
-    ObjectClassAttribute::PublishersList_t publishers;
-    publishers.clear();
+        // broadcastSomeMessage needs a vector, no set -> conversion
+        vector<FederateHandle> federate_vector(federate_set.begin(),federate_set.end()); 
+    
+        NM_Start_Registration_For_Object_Class msg ;
+        msg.federate = federate ;
+        msg.federation = handle ;
+        msg.setObjectClass(object);
+
+        this->broadcastSomeMessage(&msg, 0, federate_vector, (unsigned short)federate_vector.size());
+
+        publishers.clear();
+        federate_set.clear();
+        federate_vector.clear();	
+    } 
+    else {	// unsubscribe branch
+	/* test if objectclass is subscribed by anyone else
+         * -> yes : do nothing
+         * -> no : test if publisher sets its CRA switch
+         *  	-> no : do nothing
+         *  	-> yes : inform publisher with federate service stopRegistrationForObjectClass
+         */
 
-    // get publishers of attributes	
-    // first for: iterate through the attribute list and get publishers of 
-    //            each attribtue
-    // second for: iterate through the temporal publishers list and store 
-    //             non-duplicate entries in publishers
-    ObjectClassAttribute::PublishersList_t tmp_publishers;
-    tmp_publishers.clear();
-    for (ObjectClass::AttributeList_t::const_iterator 
-         i=attrForObjClass.begin();
-	 i!=attrForObjClass.end(); 
-	 i++) {
-    	 tmp_publishers = (*i)->getPublishers();
-         for (ObjectClassAttribute::PublishersList_t::const_iterator
-             j=tmp_publishers.begin(); 
-	     j!=tmp_publishers.end(); 
-	     j++) {
-	     // insert only non-duplicate entries ->
-	     // pair<iterator, bool> set::insert(const TYPE& val);
-	     publishers.insert(*j);
-         }
-	 tmp_publishers.clear();
-    }
-
-    // notify all publishers
-    for (ObjectClassAttribute::PublishersList_t::const_iterator
-        k=publishers.begin(); 
-	k!=publishers.end(); 
-	k++) {
-	// what shall we do when subscriber and publisher are the same?
-	if (getFederate(*k).isClassRelevanceAdvisorySwitch()) {
-		// invoke startRegistrationForObjectClass
-	}
     }
 
     D.Out(pdRegister,
Index: RTIG/RTIG_processing.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/RTIG_processing.cc,v
retrieving revision 3.81
diff -u -r3.81 RTIG_processing.cc
--- RTIG/RTIG_processing.cc	2 Apr 2009 19:58:10 -0000	3.81
+++ RTIG/RTIG_processing.cc	3 Apr 2009 06:46:59 -0000
@@ -814,9 +814,6 @@
 				sub ? req->handleArray : arrayVide,
 				sub ? req->handleArraySize : 0);
 
-    /* here we want a callback -> inform publisher(s) of objectclass
-     * with startRegistrationForObjectClass */
-
     D.Out(pdRegister,
           "Federate %u of Federation %u subscribed to object class %d.",
           req->federate, req->federation, req->objectClass);
Index: libCERTI/NM_Classes.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/NM_Classes.cc,v
retrieving revision 3.14
diff -u -r3.14 NM_Classes.cc
--- libCERTI/NM_Classes.cc	20 Nov 2008 18:21:56 -0000	3.14
+++ libCERTI/NM_Classes.cc	3 Apr 2009 06:46:59 -0000
@@ -159,6 +159,12 @@
 	case NetworkMessage::SET_ATTRIBUTE_SCOPE_ADVISORY_SWITCH:
 	        msg = new NM_Set_Attribute_Scope_Advisory_Switch();
 		break;
+	case NetworkMessage::START_REGISTRATION_FOR_OBJECT_CLASS:
+	        msg = new NM_Start_Registration_For_Object_Class();
+		break;
+	case NetworkMessage::STOP_REGISTRATION_FOR_OBJECT_CLASS:
+	        msg = new NM_Stop_Registration_For_Object_Class();
+		break;
 	case NetworkMessage::TURN_INTERACTIONS_ON:
 		msg = new NM_Turn_Interactions_On(); 
 		break;
@@ -566,6 +572,52 @@
 }
 /*<END>---------- Time_Constrained_Enabled ------------<END>*/
 
+/*<BEGIN>---------- Start_Registration_For_Object_Class ------------<BEGIN>*/
+NM_Start_Registration_For_Object_Class::NM_Start_Registration_For_Object_Class() {
+	this->name = "START_REGISTRATION_FOR_OBJECT_CLASS";
+	this->type = NetworkMessage::START_REGISTRATION_FOR_OBJECT_CLASS;
+	/* specific field init */
+}
+NM_Start_Registration_For_Object_Class::~NM_Start_Registration_For_Object_Class() {
+}
+void NM_Start_Registration_For_Object_Class::serialize(MessageBuffer& msgBuffer) {
+	/* call mother class */      
+	Super::serialize(msgBuffer); 
+	/* specific code (if any) goes here */
+	msgBuffer.write_int32(objectClass);
+} /* end of serialize */ 
+void NM_Start_Registration_For_Object_Class::deserialize(MessageBuffer& msgBuffer) {
+	/* call mother class */      
+	Super::deserialize(msgBuffer); 
+	/* specific code (if any) goes here */
+	objectClass = msgBuffer.read_int32();
+} /* end of deserialize */
+
+/*<END>---------- Start_Registration_For_Object_Class ------------<END>*/
+
+/*<BEGIN>---------- Stop_Registration_For_Object_Class ------------<BEGIN>*/
+NM_Stop_Registration_For_Object_Class::NM_Stop_Registration_For_Object_Class() {
+	this->name = "STOP_REGISTRATION_FOR_OBJECT_CLASS";
+	this->type = NetworkMessage::STOP_REGISTRATION_FOR_OBJECT_CLASS;
+	/* specific field init */
+}
+NM_Stop_Registration_For_Object_Class::~NM_Stop_Registration_For_Object_Class() {
+}
+void NM_Stop_Registration_For_Object_Class::serialize(MessageBuffer& msgBuffer) {
+	/* call mother class */      
+	Super::serialize(msgBuffer); 
+	/* specific code (if any) goes here */
+	msgBuffer.write_int32(objectClass);
+} /* end of serialize */ 
+void NM_Stop_Registration_For_Object_Class::deserialize(MessageBuffer& msgBuffer) {
+	/* call mother class */      
+	Super::deserialize(msgBuffer); 
+	/* specific code (if any) goes here */
+	objectClass = msgBuffer.read_int32();
+} /* end of deserialize */
+
+/*<END>---------- Stop_Registration_For_Object_Class ------------<END>*/
+
 /*<BEGIN>---------- Set_Class_Relevance_Advisory_Switch ------------<BEGIN>*/
 NM_Set_Class_Relevance_Advisory_Switch::NM_Set_Class_Relevance_Advisory_Switch() {
 	this->name = "SET_CLASS_RELEVANCE_ADVISORY_SWITCH";
Index: libCERTI/NM_Classes.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/NM_Classes.hh,v
retrieving revision 3.9
diff -u -r3.9 NM_Classes.hh
--- libCERTI/NM_Classes.hh	20 Nov 2008 18:21:56 -0000	3.9
+++ libCERTI/NM_Classes.hh	3 Apr 2009 06:46:59 -0000
@@ -275,6 +275,38 @@
 
 /*<END>---------- Time_Constrained_Enabled ------------<END>*/
 
+/*<BEGIN>---------- Start_Registration_For_Object_Class  ------------<BEGIN>*/
+class CERTI_EXPORT NM_Start_Registration_For_Object_Class : public NetworkMessage {
+public:
+	typedef NetworkMessage Super;
+	NM_Start_Registration_For_Object_Class();
+	virtual ~NM_Start_Registration_For_Object_Class();
+	virtual void serialize(MessageBuffer& msgBuffer);
+	virtual void deserialize(MessageBuffer& msgBuffer);
+	const ObjectClassHandle getObjectClass() const {return objectClass;};
+	void setObjectClass(ObjectClassHandle newObjectClass) {objectClass=newObjectClass;};
+protected:
+	/* specific field */
+private:
+};
+
+/*<END>---------- Start_Registration_For_Object_Class ------------<END>*/
+
+/*<BEGIN>---------- Stop_Registration_For_Object_Class  ------------<BEGIN>*/
+class CERTI_EXPORT NM_Stop_Registration_For_Object_Class : public NetworkMessage {
+public:
+	typedef NetworkMessage Super;
+	NM_Stop_Registration_For_Object_Class();
+	virtual ~NM_Stop_Registration_For_Object_Class();
+	virtual void serialize(MessageBuffer& msgBuffer);
+	virtual void deserialize(MessageBuffer& msgBuffer);
+	/* specific Getter/Setter */
+protected:
+	/* specific field */
+private:
+};
+
+/*<END>---------- Stop_Registration_For_Object_Class ------------<END>*/
 
 /*<BEGIN>---------- Set_Class_Relevance_Advisory_Switch ------------<BEGIN>*/
 class CERTI_EXPORT NM_Set_Class_Relevance_Advisory_Switch : public NetworkMessage {
Index: libCERTI/NetworkMessage.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/NetworkMessage.hh,v
retrieving revision 3.45
diff -u -r3.45 NetworkMessage.hh
--- libCERTI/NetworkMessage.hh	2 Apr 2009 19:58:09 -0000	3.45
+++ libCERTI/NetworkMessage.hh	3 Apr 2009 06:46:59 -0000
@@ -143,6 +143,8 @@
 		SET_INTERACTION_RELEVANCE_ADVISORY_SWITCH,
 		SET_ATTRIBUTE_RELEVANCE_ADVISORY_SWITCH,
 		SET_ATTRIBUTE_SCOPE_ADVISORY_SWITCH,
+		START_REGISTRATION_FOR_OBJECT_CLASS,
+		STOP_REGISTRATION_FOR_OBJECT_CLASS,
 		LAST		
 	} Message_T;	
 
Index: libRTI/RTIambPrivateRefs.cc
===================================================================
RCS file: /sources/certi/certi/libRTI/RTIambPrivateRefs.cc,v
retrieving revision 3.17
diff -u -r3.17 RTIambPrivateRefs.cc
--- libRTI/RTIambPrivateRefs.cc	2 Apr 2009 19:58:06 -0000	3.17
+++ libRTI/RTIambPrivateRefs.cc	3 Apr 2009 06:46:59 -0000
@@ -667,8 +667,7 @@
 
       case Message::START_REGISTRATION_FOR_OBJECT_CLASS:
         try {
-            fed_amb->startRegistrationForObjectClass(
-                msg->getObjectClass());
+            fed_amb->startRegistrationForObjectClass(msg->getObjectClass());
         }
         CATCH_FEDERATE_AMBASSADOR_EXCEPTIONS("startRegistrationForObjectClass")
         break ;
