![]() |
MAK RTIspy API Documentation for HLA 1.3
|
00001 /********************************************************************* 00002 ** Copyright (c) 2006 MaK Technologies, Inc. 00003 ** All rights reserved. 00004 *********************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: objOwnershipInfoXmlBlock.h,v $ $Revision: 1.7 $ $State: Exp $ 00007 *******************************************************************************/ 00008 #ifndef DtObjOwnershipInfoXmlBlock_H_ 00009 #define DtObjOwnershipInfoXmlBlock_H_ 00010 00011 #include <rtiMsConfig.h> 00012 #include "spyXmlBlock.h" 00013 #include <mtl/env.h> 00014 #include "webSpyUtils.h" 00015 00016 #include <vlutil/vlString.h> 00017 #include <vlutil/vlFilename.h> 00018 #include <vlutil/vlSmartPointers.h> 00019 00020 #include <iosfwd> 00021 #include <map> 00022 00023 // Define the XML tags used by this block 00024 DtDECLARE_SPY_XML_TAG( DtObjOwnershipInfoXmlTag ); 00025 DtDECLARE_SPY_XML_TAG( DtAttrOwnershipInfoXmlTag ); 00026 DtDECLARE_SPY_XML_TAG( DtAttrOwnershipInfoInstanceHandleXmlTag ); 00027 DtDECLARE_SPY_XML_TAG( DtAttrOwnershipInfoActualHandleXmlTag ); 00028 DtDECLARE_SPY_XML_TAG( DtAttrOwnershipInfoKnownHandleXmlTag ); 00029 DtDECLARE_SPY_XML_TAG( DtAttrOwnershipInfoIsRegXmlTag ); 00030 DtDECLARE_SPY_XML_TAG( DtAttrOwnershipInfoAttrsXmlTag ); 00031 DtDECLARE_SPY_XML_TAG( DtAttrOwnershipInfoPubsXmlTag ); 00032 00033 class DtRtiObject; 00034 class DtObjectClassInfo; 00035 class DtAttrInfo; 00036 class DtObjOwnershipInfoXmlBlock; 00037 class DtAttrOwnershipInfoXmlBlock; 00038 00039 typedef DtBoost::shared_ptr<DtObjOwnershipInfoXmlBlock> DtObjOwnershipInfoXmlBlockSP; 00040 typedef DtBoost::weak_ptr<DtObjOwnershipInfoXmlBlock> DtObjOwnershipInfoXmlBlockWP; 00041 typedef DtBoost::shared_ptr<DtAttrOwnershipInfoXmlBlock> DtAttrOwnershipInfoXmlBlockSP; 00042 typedef DtBoost::weak_ptr<DtAttrOwnershipInfoXmlBlock> DtAttrOwnershipInfoXmlBlockWP; 00043 00044 00045 // The DtAttrOwnershipInfoXmlBlock holds an object instance handle and lists of 00046 // owned attributes 00047 // Owned attr handle sets are stored in JSON string format for compactness: 00048 // ex. myAttrSet = DtString( "{[attrInfo1, attrInfo2, ..., attrInfoN]}" ); 00049 // and 00050 // attrInfo1 = { handle : attrHandle1, adv : updatesOnNotOff, subs : [ subscriber1, ..., subscriberN ]} 00051 class DT_DLL_WWW DtAttrOwnershipInfoXmlBlock : public DtSpyXmlBlock 00052 { 00053 public: 00054 00055 static DtSpyXmlBlockSP create( DtNodeAndParentPair xmlNodeAndParent ); 00056 00057 public: 00058 DtAttrOwnershipInfoXmlBlock( DtEnvValueSP existingNode, DtEnvValueSP root ); 00059 DtAttrOwnershipInfoXmlBlock( const DtString& instanceName, unsigned long handle, unsigned long actualClassHandle, 00060 unsigned long knownClassHandle, const DtString& ownedAttrSet, DtEnvValueSP root ); 00061 virtual ~DtAttrOwnershipInfoXmlBlock(); 00062 00063 // Object instance handle 00064 inline unsigned long handle() const; 00065 00066 // Object class handle 00067 inline unsigned long actual() const; 00068 00069 // Known Object class handle 00070 inline unsigned long known() const; 00071 00072 // Owned Attr set in JSON format 00073 virtual void setAttrs( const DtString& attrs ); 00074 inline DtString attrs() const; 00075 00076 protected: 00077 00078 DtSpyXmlBlockElement< unsigned long, true > myHandle; 00079 DtSpyXmlBlockElement< unsigned long, true > myActualClassHandle; 00080 DtSpyXmlBlockElement< unsigned long, true > myKnownHandle; 00081 00082 DtSpyXmlBlockElement< DtString, true > myAttrSet; 00083 }; 00084 00085 00086 // The DtObjOwnershipInfoXmlBlock holds a complete list of known objects and ownership states 00087 class DT_DLL_WWW DtObjOwnershipInfoXmlBlock : public DtSpyXmlBlock 00088 { 00089 public: 00090 typedef std::set< DtAttrOwnershipInfoXmlBlockSP > AttrOwnershipInfoXmlBlockSet; 00091 00092 static DtSpyXmlBlockSP create( DtNodeAndParentPair xmlNodeAndParent ); 00093 00094 public: 00095 DtObjOwnershipInfoXmlBlock( DtEnvValueSP existingNode, DtEnvValueSP root ); 00096 DtObjOwnershipInfoXmlBlock( DtEnvValueSP root ); 00097 virtual ~DtObjOwnershipInfoXmlBlock(); 00098 00099 // Add and Remove objects from the list 00100 // If added object exists, addObject replaces existing 00101 virtual DtAttrOwnershipInfoXmlBlockSP addObject( const DtRtiObject& obj, 00102 const DtObjectClassInfo& actualClass ); 00103 virtual DtAttrOwnershipInfoXmlBlockSP removeObject( unsigned long handle ); 00104 virtual void removeObject( DtAttrOwnershipInfoXmlBlockSP objectSP ); 00105 00106 // List the known object instances and owned attrs 00107 virtual AttrOwnershipInfoXmlBlockSet objects(); 00108 00109 protected: 00110 00111 // Get a list of owned attributes for an object in JSON Format 00112 DtString getOwnedAttrs( const DtRtiObject& obj, const DtObjectClassInfo& actualClass ); 00113 DtString getAttrInfo( const DtAttrInfo& handle, bool updatesOn ); 00114 00115 protected: 00116 00117 // Local cached pointers to children for faster lookups 00118 typedef std::map< unsigned long, DtAttrOwnershipInfoXmlBlockSP > HandleToObjectSpMap; 00119 HandleToObjectSpMap myObjectsByHandle; 00120 }; 00121 00122 unsigned long DtAttrOwnershipInfoXmlBlock::handle() const { return myHandle; } 00123 unsigned long DtAttrOwnershipInfoXmlBlock::actual() const { return myActualClassHandle; } 00124 unsigned long DtAttrOwnershipInfoXmlBlock::known() const { return myKnownHandle; } 00125 inline DtString DtAttrOwnershipInfoXmlBlock::attrs() const { return myAttrSet; } 00126 00127 #endif // DtObjOwnershipInfoXmlBlock_H_ 00128