certi-cvs
[Top][All Lists]
Advanced

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

[certi-cvs] certi/libCERTI InteractionSet.hh ObjectClassSet...


From: certi-cvs
Subject: [certi-cvs] certi/libCERTI InteractionSet.hh ObjectClassSet...
Date: Sat, 08 Nov 2008 01:11:24 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     Eric NOULARD <erk>      08/11/08 01:11:24

Modified files:
        libCERTI       : InteractionSet.hh ObjectClassSet.hh 
                         Interaction.cc TreeNamedAndHandledSet.hh 
                         InteractionSet.cc XmlParser.cc 
                         ObjectClassSet.cc RootObject.cc ObjectClass.cc 

Log message:
        Now we should be near to both HLA 1.3 and IEEE-1516 compliant regarding 
        object class name
        and
        interaction class name handling

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/InteractionSet.hh?cvsroot=certi&r1=3.22&r2=3.23
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClassSet.hh?cvsroot=certi&r1=3.34&r2=3.35
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Interaction.cc?cvsroot=certi&r1=3.48&r2=3.49
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/TreeNamedAndHandledSet.hh?cvsroot=certi&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/InteractionSet.cc?cvsroot=certi&r1=3.27&r2=3.28
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/XmlParser.cc?cvsroot=certi&r1=3.28&r2=3.29
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClassSet.cc?cvsroot=certi&r1=3.43&r2=3.44
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/RootObject.cc?cvsroot=certi&r1=3.38&r2=3.39
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClass.cc?cvsroot=certi&r1=3.59&r2=3.60

Patches:
Index: InteractionSet.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/InteractionSet.hh,v
retrieving revision 3.22
retrieving revision 3.23
diff -u -b -r3.22 -r3.23
--- InteractionSet.hh   2 Nov 2008 01:01:52 -0000       3.22
+++ InteractionSet.hh   8 Nov 2008 01:11:23 -0000       3.23
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: InteractionSet.hh,v 3.22 2008/11/02 01:01:52 erk Exp $
+// $Id: InteractionSet.hh,v 3.23 2008/11/08 01:11:23 erk Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _CERTI_INTERACTION_SET_HH
@@ -48,8 +48,9 @@
         * Add an interaction class to the set.
         * @pre theClass should be non NULL
         * @param[in] theClass the object class to be added
+        * @param[in] parentClass the parent class (may be NULL)
         */
-       void addClass(Interaction *theClass);
+       void addClass(Interaction *theClass, Interaction *parentClass);
 
        // --------------------------
        // -- RTI Support Services --
@@ -150,4 +151,4 @@
 
 #endif // _CERTI_INTERACTION_SET_HH
 
-// $Id: InteractionSet.hh,v 3.22 2008/11/02 01:01:52 erk Exp $
+// $Id: InteractionSet.hh,v 3.23 2008/11/08 01:11:23 erk Exp $

Index: ObjectClassSet.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClassSet.hh,v
retrieving revision 3.34
retrieving revision 3.35
diff -u -b -r3.34 -r3.35
--- ObjectClassSet.hh   2 Nov 2008 01:01:52 -0000       3.34
+++ ObjectClassSet.hh   8 Nov 2008 01:11:23 -0000       3.35
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: ObjectClassSet.hh,v 3.34 2008/11/02 01:01:52 erk Exp $
+// $Id: ObjectClassSet.hh,v 3.35 2008/11/08 01:11:23 erk Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _CERTI_OBJECT_CLASS_SET_HH
@@ -56,8 +56,9 @@
        /**
         * Add an object class to the set.
         * @param[in] theClass the object class to be added
+        * @param[in] parentClass the parent class (may be NULL)
         */
-       void addClass(ObjectClass *theClass) throw (RTIinternalError);
+       void addClass(ObjectClass *theClass,ObjectClass *parentClass) throw 
(RTIinternalError);
 
        // RTI Support Services
        AttributeHandle getAttributeHandle(const char *the_name,
@@ -196,4 +197,4 @@
 
 #endif // _CERTI_OBJECT_CLASS_SET_HH
 
-// $Id: ObjectClassSet.hh,v 3.34 2008/11/02 01:01:52 erk Exp $
+// $Id: ObjectClassSet.hh,v 3.35 2008/11/08 01:11:23 erk Exp $

Index: Interaction.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Interaction.cc,v
retrieving revision 3.48
retrieving revision 3.49
diff -u -b -r3.48 -r3.49
--- Interaction.cc      2 Nov 2008 00:26:40 -0000       3.48
+++ Interaction.cc      8 Nov 2008 01:11:23 -0000       3.49
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: Interaction.cc,v 3.48 2008/11/02 00:26:40 erk Exp $
+// $Id: Interaction.cc,v 3.49 2008/11/08 01:11:23 erk Exp $
 // ----------------------------------------------------------------------------
 
 
@@ -71,7 +71,7 @@
 } /* end of ~Interaction */
 
 void Interaction::addSubclass(Interaction *sc) {
-       subClasses->addClass(sc);
+       subClasses->addClass(sc,NULL);
 }
 
 // ----------------------------------------------------------------------------
@@ -538,4 +538,4 @@
 
 } // namespace certi
 
-// $Id: Interaction.cc,v 3.48 2008/11/02 00:26:40 erk Exp $
+// $Id: Interaction.cc,v 3.49 2008/11/08 01:11:23 erk Exp $

Index: TreeNamedAndHandledSet.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/TreeNamedAndHandledSet.hh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- TreeNamedAndHandledSet.hh   2 Nov 2008 01:01:52 -0000       1.3
+++ TreeNamedAndHandledSet.hh   8 Nov 2008 01:11:23 -0000       1.4
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: TreeNamedAndHandledSet.hh,v 1.3 2008/11/02 01:01:52 erk Exp $
+// $Id: TreeNamedAndHandledSet.hh,v 1.4 2008/11/08 01:11:23 erk Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _TreeNamedAndHandledSet_HH
@@ -81,21 +81,16 @@
        std::string getSetName() const {return setName;};
 
        /**
-        * Add an object to the set.
-        * @param[in] object the object to be added
+        * Add an object to the set and build parent <--> child relationship.
+        * @param[in,out] child the object to be added
+        *                the child will be linked to his parent.
+        * @param[in,out] parent the parent object of the child
+        *                the parent will get updated with a link to the
+        *                new child.
         * @throw RTIinternalError the object cannot be stored in the set
         *                         may be because of a name collision
         */
-       void add(ObjectType *object) throw (RTIinternalError);
-
-       /**
-        * Build inheritance relation between two objects class.
-        * @param[in,out] child the future child object class
-        * @param[in,out] parent the parent object class
-        * @post the child and parent object classes are linked
-        *       with inheritance relationship.
-        */
-       void buildParentRelation(ObjectType *child, ObjectType *parent);
+       void add(ObjectType *child, ObjectType* parent=NULL) throw 
(RTIinternalError);
 
        /**
         * Get the handle corresponding to the name.
@@ -175,6 +170,15 @@
         * Mainly used for displaying the set.
         */
        std::string        setName;
+private:
+       /**
+        * Build inheritance relation between two objects class.
+        * @param[in,out] child the future child object class
+        * @param[in,out] parent the parent object class
+        * @post the child and parent object classes are linked
+        *       with inheritance relationship.
+        */
+       void buildParentRelation(ObjectType *child, ObjectType *parent);
 };
 
 template <typename ObjectType>
@@ -192,7 +196,7 @@
         *    we delete the content
         * If not we only clear the map in order to avoid double deletion.
         *
-        * FIXME EN: this is a trick in order because we do not
+        * FIXME EN: this is a trick because we do not
         *           really maintain a tree of ObjectClass in order
         *           to support flat object class name
         *           ("Boule" instead of "Bille.Boule")
@@ -212,90 +216,119 @@
 
 template <typename ObjectType>
 void
-TreeNamedAndHandledSet<ObjectType>::add(ObjectType *object)
+TreeNamedAndHandledSet<ObjectType>::add(ObjectType *child, ObjectType *parent)
        throw (RTIinternalError) {
        typename Name2ObjectMap_t::iterator findit;
        std::stringstream             msg;
 
+       /* build hierarchical name if a parent is given */
+       if (NULL!=parent) {
+               std::string parentName = parent->getName();
+               /*
+                * Inclusion or exclusion of those prefix is optional
+                * see IEEE-1516.1-2000 - 10.1.1 Names
+                * Do not build HLA root name in the hierarchical name
+                */
+               if (!((parentName=="ObjectRoot") ||
+                         (parentName=="InteractionRoot") ||
+                         (parentName=="HLAobjectRoot") ||
+                         (parentName=="HLAinteractionRoot")
+                         )
+                         ){
+                       child->setName(parentName+"."+child->getName());
+               }
+               //std::cout << "Adding child :" << child->getName() << 
std::endl;
+               buildParentRelation(child,parent);
+       }
+
     /*
      * Check whether addition of this object class
      * will generate a name collision or not.
      * i.e. we may not add an object class of the SAME
      * name to the object class set
      */
-    findit = fromName.find(object->getName());
+    findit = fromName.find(child->getName());
     if (findit != fromName.end()) {
        msg << "Name collision another object class named <"
-           << object->getName()
+           << child->getName()
            << "> with handle <"
            << findit->second->getHandle()
            << "> was found when trying to add identically named object class 
with handle <"
-           << object->getHandle();
+           << child->getHandle();
        throw RTIinternalError(msg.str().c_str());
     }
     /* store ref to new object in Object from Handle Map */
-    fromHandle[object->getHandle()] = object;
+    fromHandle[child->getHandle()] = child;
     /* store ref to new object in Object from Name Map */
-    fromName[object->getName()] = object;
+    fromName[child->getName()] = child;
 } /* end of add */
 
 template <typename ObjectType>
 void
 TreeNamedAndHandledSet<ObjectType>::buildParentRelation(ObjectType* child, 
ObjectType* parent) {
+       /* Link the child to its parent */
     child->setSuperclass(parent->getHandle());
-    child->setSecurityLevelId(parent->getSecurityLevelId());
+    /* Declare a new child for the parent */
     parent->addSubclass(child);
+    /* Security Level of the child is inherited from parent */
+    child->setSecurityLevelId(parent->getSecurityLevelId());
+    /* Add inherited feature from parent to child */
     parent->addToChild(child);
-}
+} /* end of buildParentRelation */
 
 template <typename ObjectType>
 typename TreeNamedAndHandledSet<ObjectType>::HandleType
 TreeNamedAndHandledSet<ObjectType>::getHandleFromName(std::string name) const
     throw (NameNotFound) {
 
-    std::string                                currentName;
-    std::string                              remainingName;
-    HandleType                               currentHandle;
-    ObjectType*                              currentObject;
-    TreeNamedAndHandledSet<ObjectType> const*   currentSet;
-       named_const_iterator                              iter;
+       named_const_iterator   findit;
+       std::string            sname;
+       std::string            prefix;
 
-       currentSet    = this;
-       remainingName = name;
+       sname = name;
+       prefix = Named::getNextClassName(sname);
     /*
-     * If the name is qualified (a.k.a. hierarchical name) like "Bille.Boule"
-     * then iterate through subClass in order to reach the leaf "unqualified 
name"
-     */
-    while (Named::isQualifiedClassName(remainingName)) {
+        * Inclusion or exclusion of those prefix is optional
+        * see IEEE-1516.1-2000 - 10.1.1 Names
+        * Do not build HLA root name in the hierarchical name
+        */
+       if (!((prefix=="ObjectRoot") ||
+                 (prefix=="InteractionRoot") ||
+                 (prefix=="HLAobjectRoot") ||
+                 (prefix=="HLAinteractionRoot")
+            )
+          ) {
+               sname = name;
+       }
        /*
-        * The first current should be the name of
-        * of a child of the current set
+        * First try to find the named object
+        * This should be an efficient binary_search
         */
-       currentName = Named::getNextClassName(remainingName);
-               /*
-                * Get the handle of the child
-                * NOTE that we won't recurse more than once here
-                * since the provided 'currentName' is not qualified 'by design'
-                * The recursive deepness is at most 2.
-                */
-               currentHandle = currentSet->getHandleFromName(currentName);
-               /* Get the corresponding object */
-               currentObject = currentSet->getObjectFromHandle(currentHandle);
-               /* now update currentClassSet */
-               currentSet    = currentObject->getSubClasses();
+       findit = fromName.find(sname);
+       std::cout << "Looking for " << sname << std::endl;
+       /* If found return the handle */
+       if (findit != fromName.end()) {
+               return findit->second->getHandle();
     }
 
     /*
-     * Now the current classClassSet should be a leaf
-     * so that we can search in the
+        * If not found then look for shortcut name
+        * this is a CERTI non-standard behavior
      */
-    iter = currentSet->fromName.find(remainingName);
+       if (!Named::isQualifiedClassName(sname)) {
+               /* linear search in the whole set */
+               for (findit=fromName.begin(); findit!=fromName.end();++findit) {
+                       if (Named::getLeafClassName(findit->first) == sname) {
+                               return findit->second->getHandle();
+                       }
+                       else {
+                       std::cout <<    Named::getLeafClassName(findit->first) 
<< "- and -" << sname << " - dot not match" << std::endl;
+                       }
+               }
+       }
 
-       if (iter != currentSet->fromName.end()) {
-               return iter->second->getHandle();
-       } else {
+       /* every search has failed */
                throw NameNotFound(name.c_str());
-       }
 } /* end of getObjectClassHandle */
 
 template <typename ObjectType>

Index: InteractionSet.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/InteractionSet.cc,v
retrieving revision 3.27
retrieving revision 3.28
diff -u -b -r3.27 -r3.28
--- InteractionSet.cc   2 Nov 2008 01:01:53 -0000       3.27
+++ InteractionSet.cc   8 Nov 2008 01:11:23 -0000       3.28
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: InteractionSet.cc,v 3.27 2008/11/02 01:01:53 erk Exp $
+// $Id: InteractionSet.cc,v 3.28 2008/11/08 01:11:23 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include "Interaction.hh"
@@ -50,12 +50,12 @@
 } /* end of ~InteractionSet */
 
 void
-InteractionSet::addClass(Interaction *newClass) {
+InteractionSet::addClass(Interaction *newClass, Interaction *parentClass) {
 
        D.Out(pdInit, "Adding new interaction class %d, ", 
newClass->getHandle());
        /* link to server */
        newClass->server = server ;
-       add(newClass);
+       add(newClass,parentClass);
 } /* end of addClass */
 
 // ----------------------------------------------------------------------------
@@ -158,9 +158,7 @@
 InteractionClassHandle
 InteractionSet::getInteractionClassHandle(const std::string& class_name) const
 throw (NameNotFound)  {
-
        return getHandleFromName(class_name);
-
 } /* end of getInteractionClassHandle */
 
 // ----------------------------------------------------------------------------
@@ -169,7 +167,7 @@
 InteractionSet::getInteractionClassName(InteractionClassHandle the_handle) 
const
 throw (InteractionClassNotDefined)
 {
-       return getNameFromHandle(the_handle);
+       return getNameFromHandle(+the_handle);
 } /* end of getInteractionClassName */
 
 // ----------------------------------------------------------------------------
@@ -277,4 +275,4 @@
 
 } // namespace certi
 
-// $Id: InteractionSet.cc,v 3.27 2008/11/02 01:01:53 erk Exp $
+// $Id: InteractionSet.cc,v 3.28 2008/11/08 01:11:23 erk Exp $

Index: XmlParser.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/XmlParser.cc,v
retrieving revision 3.28
retrieving revision 3.29
diff -u -b -r3.28 -r3.29
--- XmlParser.cc        31 Oct 2008 13:50:25 -0000      3.28
+++ XmlParser.cc        8 Nov 2008 01:11:23 -0000       3.29
@@ -19,8 +19,6 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 // ----------------------------------------------------------------------------
 
-
-
 #include "XmlParser.hh"
 #include "ObjectClassSet.hh"
 #include "InteractionSet.hh"

Index: ObjectClassSet.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClassSet.cc,v
retrieving revision 3.43
retrieving revision 3.44
diff -u -b -r3.43 -r3.44
--- ObjectClassSet.cc   2 Nov 2008 01:01:53 -0000       3.43
+++ ObjectClassSet.cc   8 Nov 2008 01:11:23 -0000       3.44
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: ObjectClassSet.cc,v 3.43 2008/11/02 01:01:53 erk Exp $
+// $Id: ObjectClassSet.cc,v 3.44 2008/11/08 01:11:23 erk Exp $
 // ----------------------------------------------------------------------------
 
 // Project
@@ -61,12 +61,12 @@
 } /* end of ~ObjectClassSet */
 
 void
-ObjectClassSet::addClass(ObjectClass *newClass) throw (RTIinternalError)
+ObjectClassSet::addClass(ObjectClass *newClass,ObjectClass *parentClass) throw 
(RTIinternalError)
 {
        D.Out(pdInit, "Adding new object class %d.", newClass->getHandle());
        /* link to server */
     newClass->server = server ;
-       add(newClass);
+       add(newClass,parentClass);
 
 } /* end of addClass */
 
@@ -256,8 +256,7 @@
 //! getObjectClassHandle.
 ObjectClassHandle
 ObjectClassSet::getObjectClassHandle(std::string class_name) const
-    throw (NameNotFound){
-
+throw (NameNotFound){
        return getHandleFromName(class_name);
 } /* end of getObjectClassHandle */
 
@@ -706,4 +705,4 @@
 
 } // namespace certi
 
-// $Id: ObjectClassSet.cc,v 3.43 2008/11/02 01:01:53 erk Exp $
+// $Id: ObjectClassSet.cc,v 3.44 2008/11/08 01:11:23 erk Exp $

Index: RootObject.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/RootObject.cc,v
retrieving revision 3.38
retrieving revision 3.39
diff -u -b -r3.38 -r3.39
--- RootObject.cc       2 Nov 2008 01:01:53 -0000       3.38
+++ RootObject.cc       8 Nov 2008 01:11:23 -0000       3.39
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: RootObject.cc,v 3.38 2008/11/02 01:01:53 erk Exp $
+// $Id: RootObject.cc,v 3.39 2008/11/08 01:11:23 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include "Object.hh"
@@ -341,27 +341,14 @@
 
 void
 RootObject::addObjectClass(ObjectClass* currentOC,ObjectClass* parentOC) {
-       if (NULL != parentOC) {
-               ObjectClasses->buildParentRelation(currentOC, parentOC);
-       }
-       /*
-        * FIXME EN we must add the class to object root
-        * after we did build the parent relation
-        * this is awkward but we need it for
-        * the "server" link to be OK
-        * We need to fix this.
-        */
-       ObjectClasses->addClass(currentOC);
+       ObjectClasses->addClass(currentOC,parentOC);
 } /* end of addObjectClass */
 
 void
 RootObject::addInteractionClass(Interaction* currentIC, Interaction* parentIC) 
{
-       if (NULL!=parentIC) {
-               Interactions->buildParentRelation(currentIC, parentIC);
-       }
-       Interactions->addClass(currentIC);
+       Interactions->addClass(currentIC,parentIC);
 } /* end of addInteractionClass */
 
 } // namespace certi
 
-// $Id: RootObject.cc,v 3.38 2008/11/02 01:01:53 erk Exp $
+// $Id: RootObject.cc,v 3.39 2008/11/08 01:11:23 erk Exp $

Index: ObjectClass.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClass.cc,v
retrieving revision 3.59
retrieving revision 3.60
diff -u -b -r3.59 -r3.60
--- ObjectClass.cc      2 Nov 2008 00:26:41 -0000       3.59
+++ ObjectClass.cc      8 Nov 2008 01:11:24 -0000       3.60
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: ObjectClass.cc,v 3.59 2008/11/02 00:26:41 erk Exp $
+// $Id: ObjectClass.cc,v 3.60 2008/11/08 01:11:24 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include  "Object.hh"
@@ -1772,7 +1772,7 @@
 void
 ObjectClass::addSubclass(ObjectClass *c)
 {
-    subClasses->addClass(c);
+    subClasses->addClass(c,NULL);
 }
 
 // ----------------------------------------------------------------------------
@@ -1818,4 +1818,4 @@
 
 } // namespace certi
 
-// $Id: ObjectClass.cc,v 3.59 2008/11/02 00:26:41 erk Exp $
+// $Id: ObjectClass.cc,v 3.60 2008/11/08 01:11:24 erk Exp $




reply via email to

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