# ObjectClass.hh

Go to the documentation of this file.

    00001 // ----------------------------------------------------------------------------
    00002 // CERTI - HLA RunTime Infrastructure
    00003 // Copyright (C) 2002-2005  ONERA
    00004 //
    00005 // This file is part of CERTI-libCERTI
    00006 //
    00007 // CERTI-libCERTI is free software ; you can redistribute it and/or
    00008 // modify it under the terms of the GNU Lesser General Public License
    00009 // as published by the Free Software Foundation ; either version 2 of
    00010 // the License, or (at your option) any later version.
    00011 //
    00012 // CERTI-libCERTI is distributed in the hope that it will be useful, but
    00013 // WITHOUT ANY WARRANTY ; without even the implied warranty of
    00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    00015 // Lesser General Public License for more details.
    00016 //
    00017 // You should have received a copy of the GNU Lesser General Public
    00018 // License along with this program ; if not, write to the Free Software
    00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
    00020 // USA
    00021 //
    00022 // $Id: ObjectClass.hh,v 3.45 2008/12/16 07:08:29 approx Exp $
    00023 // ----------------------------------------------------------------------------
    00024
    00025 #ifndef _CERTI_OBJECT_CLASS_HH
    00026 #define _CERTI_OBJECT_CLASS_HH
    00027
    00028 // forward declarations
    00029 namespace certi {
    00030 class    Object;
    00031 class    ObjectAttribute;
    00032 class    ObjectClass;
    00033 class    ObjectClassSet;
    00034 class    ObjectClassAttribute;
    00035 class    ObjectClassBroadcastList;
    00036 }
    00037
    00038 // CERTI headers
    00039 #include "certi.hh"
    00040 #include "SecurityServer.hh"
    00041 #include "Named.hh"
    00042 #include "GAV.hh"
    00043
    00044 // Standard
    00045 #include <list>
    00046 #include <string>
    00047
    00048 namespace certi {
    00049
    00050 class CDiffusion
    00051 {
    00052 public:
    00053     typedef struct {
    00054         FederateHandle federate ;
    00055         AttributeHandle attribute ;
    00056
    00057     } DiffStruct ;
    00058
    00059     std::vector <DiffStruct> DiffArray ;
    00060
    00061     int size ;
    00062
    00063     CDiffusion() { size = 0 ; };
    00064 };
    00065
    00074 class CERTI_EXPORT ObjectClass : public Named {
    00075
    00076 public:
    00077
    00081     typedef ObjectClassHandle handle_t;
    00085     typedef ObjectClassNotDefined ObjectNotDefinedException;
    00086
    00090     typedef std::list<ObjectClassAttribute*> AttributeList_t;
    00091
    00097     ObjectClass(const std::string name, ObjectClassHandle handle);
    00098
    00102     ~ObjectClass();
    00103
    00104     void display() const ;
    00105
    00110     ObjectClassHandle getHandle() const ;
    00111
    00116     ObjectClassHandle getSuperclass() const { return superClass ; };
    00117
    00122     void addSubClass(ObjectClass *child);
    00123
    00129     ObjectClass* getSubClassByName(const std::string subClassName);
    00133     ObjectClassSet* getSubClasses() {return subClasses;};
    00134
    00135     // Security Methods
    00136     void checkFederateAccess(FederateHandle, const char *)
    00137     throw (SecurityError);
    00138
    00139     SecurityLevelID getSecurityLevelId() const { return securityLevelId ; };
    00140
    00141     void setSecurityLevelId(SecurityLevelID newLevelID) throw (SecurityError);
    00142
    00143     AttributeHandle addAttribute(ObjectClassAttribute *the_attribute,
    00144             bool is_inherited = false);
    00145
    00146     // Publication and Subscription
    00147     void publish(FederateHandle theFederateHandle,
    00148             std::vector <AttributeHandle> &theAttributeList,
    00149             UShort theListSize,
    00150             bool PubOrUnpub)
    00151     throw (AttributeNotDefined, RTIinternalError, SecurityError);
    00152
    00153     bool subscribe(FederateHandle, std::vector <AttributeHandle> &, int, const RTIRegion *)
    00154     throw (AttributeNotDefined, RTIinternalError, SecurityError);
    00155
    00156     void unsubscribe(FederateHandle, const RTIRegion *);
    00157     void unsubscribe(FederateHandle);
    00158
    00159     // Ownership Management
    00160     ObjectClassBroadcastList *
    00161     negotiatedAttributeOwnershipDivestiture(FederateHandle theFederateHandle,
    00162             ObjectHandle theObjectHandle,
    00163             std::vector <AttributeHandle> &theAttributeList,
    00164             UShort theListSize,
    00165             const char *theTag)
    00166             throw (ObjectNotKnown, AttributeNotDefined, AttributeNotOwned,
    00167                     AttributeAlreadyBeingDivested, RTIinternalError);
    00168
    00169
    00170     void
    00171     attributeOwnershipAcquisitionIfAvailable(FederateHandle theFederateHandle,
    00172             ObjectHandle theObjectHandle,
    00173             std::vector <AttributeHandle> &theAttributeList,
    00174             UShort theListSize)
    00175     throw (ObjectNotKnown, ObjectClassNotPublished, AttributeNotDefined,
    00176             AttributeNotPublished, FederateOwnsAttributes,
    00177             AttributeAlreadyBeingAcquired, RTIinternalError);
    00178
    00179     ObjectClassBroadcastList *
    00180     unconditionalAttributeOwnershipDivestiture(FederateHandle,
    00181             ObjectHandle theObjectHandle,
    00182             std::vector <AttributeHandle> &,
    00183             UShort theListSize)
    00184             throw (ObjectNotKnown, AttributeNotDefined, AttributeNotOwned,
    00185                     RTIinternalError);
    00186
    00187     void
    00188     attributeOwnershipAcquisition(FederateHandle theFederateHandle,
    00189             ObjectHandle theObjectHandle,
    00190             std::vector <AttributeHandle> &theAttributeList,
    00191             UShort theListSize,
    00192             const char *theTag)
    00193     throw (ObjectNotKnown, ObjectClassNotPublished, AttributeNotDefined,
    00194             AttributeNotPublished, FederateOwnsAttributes, RTIinternalError);
    00195
    00196     AttributeHandleSet *
    00197     attributeOwnershipReleaseResponse(FederateHandle theFederateHandle,
    00198             ObjectHandle theObjectHandle,
    00199             std::vector <AttributeHandle> &theAttributeList,
    00200             UShort theListSize)
    00201             throw (ObjectNotKnown, AttributeNotDefined, AttributeNotOwned,
    00202                     FederateWasNotAskedToReleaseAttribute, RTIinternalError);
    00203
    00204     void cancelAttributeOwnershipAcquisition(FederateHandle theFederateHandle,
    00205             ObjectHandle theObjectHandle,
    00206             std::vector <AttributeHandle> &theAttributeList,
    00207             UShort theListSize)
    00208     throw (ObjectNotKnown, AttributeNotDefined, AttributeAlreadyOwned,
    00209             AttributeAcquisitionWasNotRequested, RTIinternalError);
    00210
    00211     // RTI Support Services
    00212     AttributeHandle getAttributeHandle(const char *theName) const
    00213     throw (NameNotFound, RTIinternalError);
    00214
    00215     const char *getAttributeName(AttributeHandle theHandle) const
    00216     throw (AttributeNotDefined, RTIinternalError);
    00217
    00218     ObjectClassBroadcastList *killFederate(FederateHandle theFederate)
    00219     throw ();
    00220
    00221     ObjectClassAttribute *getAttribute(AttributeHandle the_handle) const
    00222     throw (AttributeNotDefined);
    00223
    00224     // Instance Management
    00225     ObjectClassBroadcastList *deleteInstance(FederateHandle theFederateHandle,
    00226             ObjectHandle theObjectHandle,
    00227             FederationTime theTime,
    00228             std::string theUserTag)
    00229     throw (DeletePrivilegeNotHeld,
    00230             ObjectNotKnown,
    00231             RTIinternalError);
    00232
    00233     ObjectClassBroadcastList *deleteInstance(FederateHandle theFederateHandle,
    00234             ObjectHandle theObjectHandle,
    00235             std::string theUserTag)
    00236     throw (DeletePrivilegeNotHeld,
    00237             ObjectNotKnown,
    00238             RTIinternalError);
    00239
    00240     bool isInstanceInClass(ObjectHandle theID);
    00241
    00242     ObjectClassBroadcastList *
    00243     registerObjectInstance(FederateHandle, Object *, ObjectClassHandle)
    00244     throw (ObjectClassNotPublished, ObjectAlreadyRegistered,
    00245             RTIinternalError);
    00246
    00247     void broadcastClassMessage(ObjectClassBroadcastList *ocb_list,
    00248             const Object * = NULL);
    00249
    00250     ObjectClassBroadcastList *
    00251     updateAttributeValues(FederateHandle, Object *, std::vector <AttributeHandle> &,
    00252             std::vector <AttributeValue_t> &, int, FederationTime, const char *)
    00253             throw (ObjectNotKnown, AttributeNotDefined, AttributeNotOwned,
    00254                     RTIinternalError, InvalidObjectHandle);
    00255
    00256     ObjectClassBroadcastList *
    00257     updateAttributeValues(FederateHandle, Object *, std::vector <AttributeHandle> &,
    00258             std::vector <AttributeValue_t> &, int, const char *)
    00259             throw (ObjectNotKnown, AttributeNotDefined, AttributeNotOwned,
    00260                     RTIinternalError, InvalidObjectHandle);
    00261
    00262     void recursiveDiscovering(FederateHandle, ObjectClassHandle)
    00263     throw (ObjectClassNotDefined);
    00264
    00265     Object *getInstanceWithID(ObjectHandle the_id) const
    00266     throw (ObjectNotKnown);
    00267
    00272     AttributeList_t getAttributeList(void);
    00273
    00275     SecurityServer *server ;
    00276
    00277 private:
    00278     /*
    00279      * private default constructor with no code
    00280      * one should not call it.
    00281      */
    00282     ObjectClass();
    00283
    00284     void addInheritedClassAttributes(ObjectClass *child);
    00285
    00286     void sendToFederate(NetworkMessage *msg, FederateHandle theFederate);
    00287
    00288     void sendToOwners(CDiffusion *diffusionList,
    00289             ObjectHandle theObjectHandle,
    00290             FederateHandle theFederate,
    00291             const char *theTag,
    00292             NetworkMessage::Type type);
    00293
    00294     void sendMessage(NetworkMessage *msg, FederateHandle theDest);
    00295
    00296     bool isFederatePublisher(FederateHandle the_federate) const ;
    00297     bool isSubscribed(FederateHandle) const ;
    00298
    00299     // The second parameter is the Class of whose behalf the message
    00300     // are sent. If SDM is called on the original class, the Federate
    00301     // may be a subscriber of the class without stopping the
    00302     // process(because he has just subscribed)
    00303     //
    00304     // Return RTI_TRUE if the same SendDiscoverMessages method must be called
    00305     // on the child classes of this class.
    00306     // Return RTI_FALSE if no messages were sent because the Federate had
    00307     // already receive DO messages for this class(and all child classes).
    00308     bool sendDiscoverMessages(FederateHandle, ObjectClassHandle);
    00309
    00310     // Attributes
    00311     ObjectClassHandle handle ;
    00312     FederateHandle maxSubscriberHandle ;
    00313
    00317     SecurityLevelID securityLevelId ;
    00318     std::list<ObjectClassAttribute *> attributeSet ;
    00319     std::list<Object *> objectSet ;
    00324     ObjectClassHandle superClass;
    00328     ObjectClassSet*   subClasses;
    00329     /* The message buffer used to send Network messages */
    00330     MessageBuffer NM_msgBufSend;
    00331 };
    00332
    00333 } // namespace certi
    00334
    00335 #endif // _CERTI_OBJECT_CLASS_HH
    00336
    00337 // $Id: ObjectClass.hh,v 3.45 2008/12/16 07:08:29 approx Exp $