[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[certi-cvs] certi/RTIG Federation.cc
From: |
CERTI CVS commits |
Subject: |
[certi-cvs] certi/RTIG Federation.cc |
Date: |
Wed, 28 Sep 2011 20:03:49 +0000 |
CVSROOT: /sources/certi
Module name: certi
Changes by: Eric NOULARD <erk> 11/09/28 20:03:49
Modified files:
RTIG : Federation.cc
Log message:
Merged
patch #7625: startRegistrationForObjectClass callback started in
publishObject
from Jan-Patrick.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/Federation.cc?cvsroot=certi&r1=3.145&r2=3.146
Patches:
Index: Federation.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/Federation.cc,v
retrieving revision 3.145
retrieving revision 3.146
diff -u -b -r3.145 -r3.146
--- Federation.cc 14 Sep 2011 13:30:33 -0000 3.145
+++ Federation.cc 28 Sep 2011 20:03:49 -0000 3.146
@@ -18,7 +18,7 @@
// along with this program ; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// $Id: Federation.cc,v 3.145 2011/09/14 13:30:33 erk Exp $
+// $Id: Federation.cc,v 3.146 2011/09/28 20:03:49 erk Exp $
// ----------------------------------------------------------------------------
#include <config.h>
@@ -1604,6 +1604,73 @@
// It may throw *NotDefined*
root->ObjectClasses->publish(federate, object, attributes, pub);
+ if (attributes.size()!=0) { // do only for subscription
+ // get object class from object class handle
+ ObjectClass *objectClass =
root->ObjectClasses->getObjectFromHandle(object);
+
+ // get publishers of attributes
+ ObjectClassAttribute::PublishersList_t publishers;
+ ObjectClassAttribute::PublishersList_t tmp_publishers;
+
+ // first for: iterate through the attribute list and get publishers of
+ // each attribute
+ // second for: iterate through the temporary publishers list and store
+ // non-duplicate entries in publishers
+
+ // get attributes of object class
+ const ObjectClass::HandleClassAttributeMap& attributeMap =
objectClass->getHandleClassAttributeMap();
+
+ for (ObjectClass::HandleClassAttributeMap::const_iterator i =
attributeMap.begin();
+ i != attributeMap.end(); ++i) {
+ tmp_publishers = i->second->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
+ 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);
+ }
+ }
+
+ // broadcastSomeMessage needs a vector, no set -> conversion
+ vector<FederateHandle> federate_vector(federate_set.size());
+ std::copy(federate_set.begin(), federate_set.end(),
federate_vector.begin());
+
+ NM_Start_Registration_For_Object_Class msg ;
+ msg.setFederate(federate);
+ msg.setFederation(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
+ //
+
+ }
+
+
D.Out(pdRegister,
"Federation %d: Federate %d(un)publishes %d attrib. of ObjClass
%d.",
handle, federate, attributes.size(), object);
@@ -1898,17 +1965,18 @@
// get object class from object class handle
ObjectClass *objectClass =
root->ObjectClasses->getObjectFromHandle(object);
- // get attributes of object class
+ // get publishers of attributes
ObjectClassAttribute::PublishersList_t publishers;
+ ObjectClassAttribute::PublishersList_t tmp_publishers;
- // get publishers of attributes
// first for: iterate through the attribute list and get publishers of
// each attribute
// second for: iterate through the temporary publishers list and store
// non-duplicate entries in publishers
- ObjectClassAttribute::PublishersList_t tmp_publishers;
+ // get attributes of object class
const ObjectClass::HandleClassAttributeMap& attributeMap =
objectClass->getHandleClassAttributeMap();
+
for (ObjectClass::HandleClassAttributeMap::const_iterator i =
attributeMap.begin();
i != attributeMap.end(); ++i) {
tmp_publishers = i->second->getPublishers();
@@ -2726,5 +2794,5 @@
}} // namespace certi/rtig
-// $Id: Federation.cc,v 3.145 2011/09/14 13:30:33 erk Exp $
+// $Id: Federation.cc,v 3.146 2011/09/28 20:03:49 erk Exp $