[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[certi-cvs] certi/libCERTI ObjectClass.hh ObjectClassSet.hh...
From: |
certi-cvs |
Subject: |
[certi-cvs] certi/libCERTI ObjectClass.hh ObjectClassSet.hh... |
Date: |
Sun, 02 Nov 2008 00:02:45 +0000 |
CVSROOT: /sources/certi
Module name: certi
Changes by: Eric NOULARD <erk> 08/11/02 00:02:45
Modified files:
libCERTI : ObjectClass.hh ObjectClassSet.hh
ObjectClassSet.cc ObjectClass.cc
Log message:
Make ObjectClass set inherit from the new template class
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClass.hh?cvsroot=certi&r1=3.40&r2=3.41
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClassSet.hh?cvsroot=certi&r1=3.32&r2=3.33
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClassSet.cc?cvsroot=certi&r1=3.41&r2=3.42
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectClass.cc?cvsroot=certi&r1=3.57&r2=3.58
Patches:
Index: ObjectClass.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClass.hh,v
retrieving revision 3.40
retrieving revision 3.41
diff -u -b -r3.40 -r3.41
--- ObjectClass.hh 1 Nov 2008 19:19:34 -0000 3.40
+++ ObjectClass.hh 2 Nov 2008 00:02:45 -0000 3.41
@@ -19,7 +19,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
//
-// $Id: ObjectClass.hh,v 3.40 2008/11/01 19:19:34 erk Exp $
+// $Id: ObjectClass.hh,v 3.41 2008/11/02 00:02:45 erk Exp $
// ----------------------------------------------------------------------------
#ifndef _CERTI_OBJECT_CLASS_HH
@@ -68,6 +68,16 @@
class CERTI_EXPORT ObjectClass : public Named {
public:
+
+ /**
+ * The type of the handle of this class.
+ */
+ typedef ObjectClassHandle handle_t;
+ /**
+ * The type of the exception to when such object is not found
+ */
+ typedef ObjectClassNotDefined ObjectNotDefinedException;
+
/**
* Create an objectClass.
* @param[in] name the object class name
@@ -308,4 +318,4 @@
#endif // _CERTI_OBJECT_CLASS_HH
-// $Id: ObjectClass.hh,v 3.40 2008/11/01 19:19:34 erk Exp $
+// $Id: ObjectClass.hh,v 3.41 2008/11/02 00:02:45 erk Exp $
Index: ObjectClassSet.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClassSet.hh,v
retrieving revision 3.32
retrieving revision 3.33
diff -u -b -r3.32 -r3.33
--- ObjectClassSet.hh 1 Nov 2008 19:19:34 -0000 3.32
+++ ObjectClassSet.hh 2 Nov 2008 00:02:45 -0000 3.33
@@ -19,7 +19,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
//
-// $Id: ObjectClassSet.hh,v 3.32 2008/11/01 19:19:34 erk Exp $
+// $Id: ObjectClassSet.hh,v 3.33 2008/11/02 00:02:45 erk Exp $
// ----------------------------------------------------------------------------
#ifndef _CERTI_OBJECT_CLASS_SET_HH
@@ -28,12 +28,15 @@
// forward declaration
namespace certi {
class Object;
-class ObjectClass;
class SecurityServer;
} // namespace certi
// CERTI headers
#include "certi.hh"
+#include "ObjectClass.hh"
+#include "TreeNamedAndHandledSet.hh"
+
+// System headers
#include <list>
#include <string>
#include <map>
@@ -43,7 +46,7 @@
/**
* This class represents a set of object classes.
*/
-class CERTI_EXPORT ObjectClassSet
+class CERTI_EXPORT ObjectClassSet : public TreeNamedAndHandledSet<ObjectClass>
{
public:
@@ -56,15 +59,6 @@
*/
void addClass(ObjectClass *theClass) 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(ObjectClass *child, ObjectClass *parent);
-
void display() const ;
// RTI Support Services
@@ -188,26 +182,7 @@
Object *getObject(ObjectHandle) const throw (ObjectNotKnown);
-
- typedef
std::map<ObjectClassHandle,ObjectClass*,std::less<ObjectClassHandle> >
Handle2ObjectClassMap_t;
- typedef std::map<std::string,ObjectClass*,std::less<std::string> >
Name2ObjectClassMap_t;
- typedef Handle2ObjectClassMap_t::const_iterator
handledOC_const_iterator;
- typedef Name2ObjectClassMap_t::const_iterator namedOC_const_iterator;
-
- namedOC_const_iterator NamedBegin() const {
- return OCFromName.begin();
- }
-
- namedOC_const_iterator NamedEnd() const {
- return OCFromName.end();
- }
-
- const size_t size() {return OCFromName.size();}
-
private:
- Handle2ObjectClassMap_t OCFromHandle;
- Name2ObjectClassMap_t OCFromName;
- bool isRootClassSet;
/**
* This object will help to find the TCPLink associated with a Federate.
@@ -223,4 +198,4 @@
#endif // _CERTI_OBJECT_CLASS_SET_HH
-// $Id: ObjectClassSet.hh,v 3.32 2008/11/01 19:19:34 erk Exp $
+// $Id: ObjectClassSet.hh,v 3.33 2008/11/02 00:02:45 erk Exp $
Index: ObjectClassSet.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClassSet.cc,v
retrieving revision 3.41
retrieving revision 3.42
diff -u -b -r3.41 -r3.42
--- ObjectClassSet.cc 1 Nov 2008 19:19:35 -0000 3.41
+++ ObjectClassSet.cc 2 Nov 2008 00:02:45 -0000 3.42
@@ -19,7 +19,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
//
-// $Id: ObjectClassSet.cc,v 3.41 2008/11/01 19:19:35 erk Exp $
+// $Id: ObjectClassSet.cc,v 3.42 2008/11/02 00:02:45 erk Exp $
// ----------------------------------------------------------------------------
// Project
@@ -47,85 +47,28 @@
static PrettyDebug G("GENDOC",__FILE__) ;
ObjectClassSet::ObjectClassSet(SecurityServer *theSecurityServer, bool
isRootClassSet)
-
+ : TreeNamedAndHandledSet<ObjectClass>(isRootClassSet)
{
// It can be NULL on the RTIA.
server = theSecurityServer ;
- this->isRootClassSet = isRootClassSet;
}
// ----------------------------------------------------------------------------
//! Destructor.
ObjectClassSet::~ObjectClassSet()
{
- /* clear name map */
- OCFromName.clear();
- /*
- * If we are Root ClassSet (the class set owned by RootObject)
- * 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
- * really maintain a tree of ObjectClass in order
- * to support flat object class name
- * ("Boule" instead of "Bille.Boule")
- * We may get rid of this as soon as we want to support
- * same name for object class in different branch of the tree.
- */
- if (isRootClassSet) {
- while (!OCFromHandle.empty()) {
- delete (OCFromHandle.begin()->second);
- OCFromHandle.erase(OCFromHandle.begin());
- }
- }
- else {
- OCFromHandle.clear();
- }
+
} /* end of ~ObjectClassSet */
-// ----------------------------------------------------------------------------
-//! The class is not allocated, only the pointer is memorized.
void
ObjectClassSet::addClass(ObjectClass *newClass) throw (RTIinternalError)
{
- Name2ObjectClassMap_t::iterator findit;
- std::stringstream msg;
-
D.Out(pdInit, "Adding new object class %d.", newClass->getHandle());
-
/* link to server */
newClass->server = server ;
- /*
- * 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 = OCFromName.find(newClass->getName());
- if (findit != OCFromName.end()) {
- msg << "Name collision another object class named <"
- << newClass->getName()
- << "> with handle <"
- << findit->second->getHandle()
- << "> was found when trying to add identically named object class
with handle <"
- << newClass->getHandle();
- throw RTIinternalError(msg.str().c_str());
- }
- /* store ref to new class in ObjectClass from Handle Map */
- OCFromHandle[newClass->getHandle()] = newClass;
- /* store ref to new class in ObjectClass from Name Map */
- OCFromName[newClass->getName()] = newClass;
-} /* end of addClass */
+ add(newClass);
-void
-ObjectClassSet::buildParentRelation(ObjectClass *subclass,
- ObjectClass *superclass)
-{
- subclass->setSuperclass(superclass->getHandle());
- subclass->setSecurityLevelId(superclass->getSecurityLevelId());
- superclass->addSubclass(subclass);
- superclass->addAttributesToChild(subclass);
-}
+} /* end of addClass */
// ----------------------------------------------------------------------------
//! deleteObject with time.
@@ -221,8 +164,8 @@
{
cout << " ObjectClasses :" << endl ;
- handledOC_const_iterator i;
- for (i = OCFromHandle.begin(); i != OCFromHandle.end(); ++i) {
+ handled_const_iterator i;
+ for (i = fromHandle.begin(); i != fromHandle.end(); ++i) {
i->second->display();
}
} /* end of display */
@@ -290,8 +233,8 @@
{
std::stringstream msg;
- handledOC_const_iterator i ;
- for (i = OCFromHandle.begin(); i != OCFromHandle.end(); ++i) {
+ handled_const_iterator i ;
+ for (i = fromHandle.begin(); i != fromHandle.end(); ++i) {
if (i->second->isInstanceInClass(theObjectHandle) == true)
return (i->second);
}
@@ -309,9 +252,9 @@
throw (ObjectNotKnown)
{
- handledOC_const_iterator i ;
+ handled_const_iterator i ;
- for (i = OCFromHandle.begin(); i != OCFromHandle.end(); ++i) {
+ for (i = fromHandle.begin(); i != fromHandle.end(); ++i) {
try {
Object *object = i->second->getInstanceWithID(h);
return object ;
@@ -326,58 +269,9 @@
//! getObjectClassHandle.
ObjectClassHandle
ObjectClassSet::getObjectClassHandle(std::string class_name) const
- throw (NameNotFound)
-{
- G.Out(pdGendoc,"enter ObjectClassSet::getObjectClassHandle");
-
- std::string currentName;
- std::string remainingName;
- ObjectClassHandle currentHandle;
- ObjectClass* currentClass;
- ObjectClassSet const* currentClassSet;
- namedOC_const_iterator iter;
-
- currentClassSet = this;
- remainingName = class_name;
- /*
- * 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)) {
- /*
- * The first current should be the name of
- * of a subclass of the current ObjectClassSet
- */
- currentName = Named::getNextClassName(remainingName);
- /*
- * Get the handle of the subclass
- * 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 =
currentClassSet->getObjectClassHandle(currentName);
- /* Get the corresponding class object */
- currentClass = currentClassSet->getWithHandle(currentHandle);
- /* now update currentClassSet */
- currentClassSet = currentClass->getSubClasses();
- }
-
- /*
- * Now the current classClassSet should be a leaf
- * so that we can search in the
- */
- iter = currentClassSet->OCFromName.find(remainingName);
+ throw (NameNotFound){
- if (iter != currentClassSet->OCFromName.end()) {
- G.Out(pdGendoc,"exit ObjectClassSet::getObjectClassHandle");
- return iter->second->getHandle();
- } else {
- G.Out(pdGendoc,"exit ObjectClassSet::getObjectClassHandle on
NameNotFound");
- throw NameNotFound(class_name.c_str());
- }
+ return getHandleFromName(class_name);
} /* end of getObjectClassHandle */
// ----------------------------------------------------------------------------
@@ -387,8 +281,7 @@
throw (ObjectClassNotDefined)
{
D.Out(pdRequest, "Looking for class %u...", the_handle);
-
- return getWithHandle(the_handle)->getName();
+ return getNameFromHandle(the_handle);
}
// ----------------------------------------------------------------------------
@@ -397,19 +290,7 @@
ObjectClassSet::getWithHandle(ObjectClassHandle theHandle) const
throw (ObjectClassNotDefined)
{
- std::stringstream msg;
-
- handledOC_const_iterator iter;
-
- iter = OCFromHandle.find(theHandle);
-
- if (iter != OCFromHandle.end()) {
- return iter->second;
- } else {
- msg << "Unknown Object Class Handle <" << theHandle << ">";
- D.Out(pdExcept, "Unknown Object Class Handle %d .", theHandle);
- throw ObjectClassNotDefined(msg.str().c_str());
- }
+ return getObjectFromHandle(theHandle);
} /* end of getWithHandle */
// ----------------------------------------------------------------------------
@@ -420,9 +301,9 @@
ObjectClassBroadcastList *ocbList = NULL ;
ObjectClassHandle currentClass = 0 ;
- Handle2ObjectClassMap_t::iterator i;
+ handled_iterator i;
- for (i = OCFromHandle.begin(); i != OCFromHandle.end(); ++i) {
+ for (i = fromHandle.begin(); i != fromHandle.end(); ++i) {
// Call KillFederate on that class until it returns NULL.
do {
D.Out(pdExcept, "Kill Federate Handle %d .", theFederate);
@@ -838,4 +719,4 @@
} // namespace certi
-// $Id: ObjectClassSet.cc,v 3.41 2008/11/01 19:19:35 erk Exp $
+// $Id: ObjectClassSet.cc,v 3.42 2008/11/02 00:02:45 erk Exp $
Index: ObjectClass.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectClass.cc,v
retrieving revision 3.57
retrieving revision 3.58
diff -u -b -r3.57 -r3.58
--- ObjectClass.cc 1 Nov 2008 21:47:58 -0000 3.57
+++ ObjectClass.cc 2 Nov 2008 00:02:45 -0000 3.58
@@ -19,7 +19,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
//
-// $Id: ObjectClass.cc,v 3.57 2008/11/01 21:47:58 erk Exp $
+// $Id: ObjectClass.cc,v 3.58 2008/11/02 00:02:45 erk Exp $
// ----------------------------------------------------------------------------
#include "Object.hh"
@@ -459,8 +459,8 @@
cout << " Security Level: " << securityLevelId << endl ;
cout << " " << subClasses->size() << " Child(s):" << endl ;
cout << " Subclasses handles:" ;
- ObjectClassSet::namedOC_const_iterator i ;
- for (i = subClasses->NamedBegin(); i != subClasses->NamedEnd(); ++i) {
+ ObjectClassSet::const_iterator i ;
+ for (i = subClasses->begin(); i != subClasses->end(); ++i) {
cout << " " << i->second->getHandle() << endl;
}
@@ -1791,8 +1791,8 @@
bool go_deeper = sendDiscoverMessages(federate, subscription);
if (go_deeper) {
- ObjectClassSet::namedOC_const_iterator i ;
- for (i = subClasses->NamedBegin(); i != subClasses->NamedEnd(); ++i) {
+ ObjectClassSet::const_iterator i ;
+ for (i = subClasses->begin(); i != subClasses->end(); ++i) {
i->second->recursiveDiscovering(federate, subscription);
}
}
@@ -1818,4 +1818,4 @@
} // namespace certi
-// $Id: ObjectClass.cc,v 3.57 2008/11/01 21:47:58 erk Exp $
+// $Id: ObjectClass.cc,v 3.58 2008/11/02 00:02:45 erk Exp $
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [certi-cvs] certi/libCERTI ObjectClass.hh ObjectClassSet.hh...,
certi-cvs <=