Hi,

Dirk Reiners wrote:
On 01/11/2010 09:17 AM, Carsten Neumann wrote:
only fields marked as changed in the ChangeList are transmitted.
You can construct a changelist that contains the current application
state using RemoteAspect::createCurrentStateChangeList(fc, cl).
The first argument (fc) should be the first container created by the
application (probably best to create a dummy Node right after osgInit())
and the second arg (cl) is the ChangeList to store the information in.

Given that in most cases people would probably want to do a full copy, can we set the fc default to whatever the Factory count is after osgInit()?

hm, I think, although what is mostly wanted is to exclude the prototypes and the start thing is mostly a means to that end. So, how about the attached instead that compares entries in the factory store with their prototype:

if(fc->getType().getPrototype() == NullFC ||
   fc->getType().getPrototype() == fc       )
    continue;

That seems like a better test to me, since it should also be able to deal with the case where a lib with new types is dlopen'd at runtime, i.e. where not all protos are next to each other in the factory store. The NullFC test is needed because for some reason DynFieldAttachments don't have a prototype... ?

Comments?

        Cheers,
                Carsten
Index: Source/System/Cluster/Base/OSGRemoteAspect.h
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Cluster/Base/OSGRemoteAspect.h,v
retrieving revision 1.18
diff -u -r1.18 OSGRemoteAspect.h
--- Source/System/Cluster/Base/OSGRemoteAspect.h	8 Apr 2009 13:33:53 -0000	1.18
+++ Source/System/Cluster/Base/OSGRemoteAspect.h	15 Jan 2010 00:46:03 -0000
@@ -132,7 +132,8 @@
     static clStoreMap &getStore     (void            );
 
     static void createCurrentStateChangeList(const FieldContainerPtr &start,
-                                             ChangeList *cl);
+                                             ChangeList              *cl    );
+    static void createCurrentStateChangeList(ChangeList              *cl    );
 
     /*! \}                                                                 */
     /*---------------------------------------------------------------------*/
Index: Source/System/Cluster/Base/OSGRemoteAspect.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Cluster/Base/OSGRemoteAspect.cpp,v
retrieving revision 1.45
diff -u -r1.45 OSGRemoteAspect.cpp
--- Source/System/Cluster/Base/OSGRemoteAspect.cpp	8 Apr 2009 13:33:53 -0000	1.45
+++ Source/System/Cluster/Base/OSGRemoteAspect.cpp	15 Jan 2010 00:46:04 -0000
@@ -905,32 +905,93 @@
     return _clStore;
 }
 
-void RemoteAspect::createCurrentStateChangeList(const FieldContainerPtr &start, ChangeList *cl)
+void RemoteAspect::createCurrentStateChangeList(
+    const FieldContainerPtr &start, ChangeList *cl)
 {
     if(cl == NULL)
         return;
 
     cl->clearAll();
-    const std::vector<FieldContainerPtr> &fcs = *FieldContainerFactory::the()->getFieldContainerStore();
 
-    bool found_start = false;
-    for(unsigned int i=0;i<fcs.size();++i)
-    {
-        FieldContainerPtr fc = fcs[i];
-        if(fc != NullFC)
+    typedef std::vector<FieldContainerPtr>::const_iterator  FCStoreConstIt;
+
+    bool           foundStart = false;
+    FCStoreConstIt fcIt       =
+        FieldContainerFactory::the()->getFieldContainerStore()->begin();
+    FCStoreConstIt fcEnd      =
+        FieldContainerFactory::the()->getFieldContainerStore()->end  ();
+
+    for(; fcIt != fcEnd; ++fcIt)
+    {
+        // skip destroyed FC
+        if(*fcIt == NullFC)
+            continue;
+
+        // check for start here, in case someone uses a prototype as
+        // start
+        if(*fcIt == start)
+            foundStart = true;
+
+        // skip prototypes
+        if((*fcIt)->getType().getPrototype() == NullFC ||
+           (*fcIt)->getType().getPrototype() == (*fcIt)  )
+        {
+            continue;
+        }
+
+        if(foundStart == true)
         {
-            if(fc == start)
-                found_start = true;
+            cl->addCreated(getContainerId(*fcIt));
+        
+            for(UInt32 i = 0; i < (*fcIt).getRefCount(); ++i)
+                cl->addAddRefd(*fcIt);
 
-            if(found_start)
-            {
-                cl->addCreated(getContainerId(fc));
-                for(UInt32 j=0;j<fc.getRefCount();++j)
-                    cl->addAddRefd(fc);
-                cl->addChanged(fc, FieldBits::AllFields);
-            }
+            cl->addChanged(*fcIt, FieldBits::AllFields);
         }
-    } 
+    }
+}
+
+/*! Fills cl with change list entries so that it represents the current
+    state of the system.
+    For every FieldContainer cl will contain one Create entry, AddRefd entries
+    to bring the ref count to its current value and one Changed entry that
+    marks all fields as modified.
+    All previous contents of cl are removed.
+ */
+void RemoteAspect::createCurrentStateChangeList(ChangeList *cl)
+{
+    if(cl == NULL)
+        return;
+
+    cl->clearAll();
+
+    typedef std::vector<FieldContainerPtr>::const_iterator  FCStoreConstIt;
+
+    FCStoreConstIt fcIt =
+        FieldContainerFactory::the()->getFieldContainerStore()->begin();
+    FCStoreConstIt fcEnd =
+        FieldContainerFactory::the()->getFieldContainerStore()->end  ();
+
+    for(; fcIt != fcEnd; ++fcIt)
+    {
+        // skip destroyed FC
+        if(*fcIt == NullFC)
+            continue;
+
+        // skip prototypes
+        if((*fcIt)->getType().getPrototype() == NullFC ||
+           (*fcIt)->getType().getPrototype() == (*fcIt)  )
+        {
+            continue;
+        }
+
+        cl->addCreated(getContainerId(*fcIt));
+        
+        for(UInt32 i = 0; i < (*fcIt).getRefCount(); ++i)
+            cl->addAddRefd(*fcIt);
+
+        cl->addChanged(*fcIt, FieldBits::AllFields);
+    }
 }
 
 /*-------------------------------------------------------------------------*/
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to