![]() |
MAK RTIspy API Documentation for HLA 1.3
|
00001 /********************************************************************* 00002 ** Copyright (c) 2006 MaK Technologies, Inc. 00003 ** All rights reserved. 00004 *********************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: pubSubXmlBlock.h,v $ $Revision: 1.7 $ $State: Exp $ 00007 *******************************************************************************/ 00008 #ifndef DtPubSubXmlBlock_H_ 00009 #define DtPubSubXmlBlock_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( DtPubSubXmlTag ); 00025 DtDECLARE_SPY_XML_TAG( DtPubSubObjectXmlTag ); 00026 DtDECLARE_SPY_XML_TAG( DtPubSubObjectClassHandleXmlTag ); 00027 DtDECLARE_SPY_XML_TAG( DtPubSubObjectSubsXmlTag ); 00028 DtDECLARE_SPY_XML_TAG( DtPubSubObjectPubsXmlTag ); 00029 DtDECLARE_SPY_XML_TAG( DtPubSubInteractionsXmlTag ); 00030 DtDECLARE_SPY_XML_TAG( DtPubSubInteractionSubsXmlTag ); 00031 DtDECLARE_SPY_XML_TAG( DtPubSubInteractionPubsXmlTag ); 00032 00033 class DtFomClassMgr; 00034 class DtObjectClassInfo; 00035 class DtInteractionClassInfo; 00036 class DtPubSubXmlBlock; 00037 class DtPubSubObjectsXmlBlock; 00038 class DtPubSubInteractionsXmlBlock; 00039 typedef DtBoost::shared_ptr<DtPubSubXmlBlock> DtPubSubXmlBlockSP; 00040 typedef DtBoost::weak_ptr<DtPubSubXmlBlock> DtPubSubXmlBlockWP; 00041 typedef DtBoost::shared_ptr<DtPubSubObjectsXmlBlock> DtPubSubObjectsXmlBlockSP; 00042 typedef DtBoost::weak_ptr<DtPubSubObjectsXmlBlock> DtPubSubObjectsXmlBlockWP; 00043 typedef DtBoost::shared_ptr<DtPubSubInteractionsXmlBlock> DtPubSubInteractionsXmlBlockSP; 00044 typedef DtBoost::weak_ptr<DtPubSubInteractionsXmlBlock> DtPubSubInteractionsXmlBlockWP; 00045 00046 00047 00048 // The DtPubSubObjectsXmlBlock holds an object class handle and lists of sub'd and 00049 // pub'd attributes 00050 // Sub and Pub handle sets are stored in JSON string format for compactness: 00051 // ex. mySubs = DtString( "{[handle1, handle2, ..., handleN]}" ); 00052 class DT_DLL_WWW DtPubSubObjectsXmlBlock : public DtSpyXmlBlock 00053 { 00054 public: 00055 00056 static DtSpyXmlBlockSP create( DtNodeAndParentPair xmlNodeAndParent ); 00057 00058 public: 00059 DtPubSubObjectsXmlBlock( DtEnvValueSP existingNode, DtEnvValueSP root ); 00060 DtPubSubObjectsXmlBlock( unsigned long handle, const DtString& subAttrSet, 00061 const DtString& pubAttrSet, DtEnvValueSP root ); 00062 virtual ~DtPubSubObjectsXmlBlock(); 00063 00064 // Object clas handle 00065 inline unsigned long handle() const; 00066 00067 // Subscription Attr set in JSON format 00068 virtual void setSubs( const DtString& subs ); 00069 inline DtString subs() const; 00070 00071 // Publication Attr set in JSON format 00072 virtual void setPubs( const DtString& pubs ); 00073 inline DtString pubs() const; 00074 00075 protected: 00076 00077 DtSpyXmlBlockElement< unsigned long, true > myHandle; 00078 00079 DtSpyXmlBlockElement< DtString, true > mySubscriptions; 00080 DtSpyXmlBlockElement< DtString, true > myPublications; 00081 }; 00082 00083 // The DtPubSubInteractionsXmlBlock holds a list of pub'd and sub'd interaction classes 00084 // 00085 // Sub and Pub handle sets are stored in JSON string format for compactness: 00086 // ex. mySubs = DtString( "{[handle1, handle2, ..., handleN]}" ); 00087 class DT_DLL_WWW DtPubSubInteractionsXmlBlock : public DtSpyXmlBlock 00088 { 00089 public: 00090 00091 static DtSpyXmlBlockSP create( DtNodeAndParentPair xmlNodeAndParent ); 00092 00093 public: 00094 DtPubSubInteractionsXmlBlock( DtEnvValueSP existingNode, DtEnvValueSP root ); 00095 DtPubSubInteractionsXmlBlock( const DtString& subAttrSet, 00096 const DtString& pubAttrSet, DtEnvValueSP root ); 00097 virtual ~DtPubSubInteractionsXmlBlock(); 00098 00099 // Subscription Handle set in JSON format 00100 virtual void setSubs( const DtString& subs ); 00101 inline DtString subs() const; 00102 00103 // Publication Handle set in JSON format 00104 virtual void setPubs( const DtString& pubs ); 00105 inline DtString pubs() const; 00106 00107 protected: 00108 00109 DtSpyXmlBlockElement< DtString, true > mySubscriptions; 00110 DtSpyXmlBlockElement< DtString, true > myPublications; 00111 }; 00112 00113 00114 // The DtPubSubXmlBlock holds a complete WWW request message 00115 class DT_DLL_WWW DtPubSubXmlBlock : public DtSpyXmlBlock 00116 { 00117 public: 00118 typedef std::set< DtPubSubObjectsXmlBlockSP > PubSubObjectXmlBlockSet; 00119 00120 static DtSpyXmlBlockSP create( DtNodeAndParentPair xmlNodeAndParent ); 00121 00122 public: 00123 DtPubSubXmlBlock( DtEnvValueSP existingNode, DtEnvValueSP root ); 00124 DtPubSubXmlBlock( DtEnvValueSP root ); 00125 virtual ~DtPubSubXmlBlock(); 00126 00127 // Build list of pubs and subs from the FOM manager state 00128 virtual void updatePubsAndSubs( const DtFomClassMgr& fom ); 00129 00130 // Add and Remove objects from the list 00131 // If added object exists, addObject replaces existing 00132 virtual DtPubSubObjectsXmlBlockSP addObject( unsigned long handle, const DtString& pubs, const DtString& subs ); 00133 virtual DtPubSubObjectsXmlBlockSP removeObject( unsigned long handle ); 00134 virtual void removeObject( DtPubSubObjectsXmlBlockSP objectSP ); 00135 00136 // List the sub'd and pub'd object classes 00137 virtual PubSubObjectXmlBlockSet objects(); 00138 00139 // Set the list of pub'd and sub'd Interaction Classes (overwrites existing) 00140 // (this is different than objects which are sub'd and pub'd on a per class per attribute basis) 00141 virtual DtPubSubInteractionsXmlBlockSP setInteractions( const DtString& pubs, const DtString& subs ); 00142 00143 // List the sub'd and pub'd interaction classes 00144 virtual DtPubSubInteractionsXmlBlockSP interactions(); 00145 00146 protected: 00147 00148 // Get the object sub and pub data 00149 void updateObjectPubsAndSubs( DtObjectClassInfo* obj ); 00150 00151 // Get per-attribute sub and pub data 00152 void getAttrSubsAndPubs( DtObjectClassInfo* obj ); 00153 00154 // Get the interaction sub and pub data 00155 void updateInteractionPubsAndSubs( DtInteractionClassInfo* inter, 00156 DtString& interSubs, DtString& interPubs, bool& addCommaToSubs, bool& addCommaToPubs ); 00157 00158 protected: 00159 00160 // Local cached pointers to children for faster lookups 00161 typedef std::map< unsigned long, DtPubSubObjectsXmlBlockSP > HandleToObjectSpMap; 00162 HandleToObjectSpMap myObjectsByHandle; 00163 DtPubSubInteractionsXmlBlockSP myInteractions; 00164 }; 00165 00166 unsigned long DtPubSubObjectsXmlBlock::handle() const { return myHandle; } 00167 inline DtString DtPubSubObjectsXmlBlock::subs() const { return mySubscriptions; } 00168 inline DtString DtPubSubObjectsXmlBlock::pubs() const { return myPublications; } 00169 inline DtString DtPubSubInteractionsXmlBlock::subs() const { return mySubscriptions; } 00170 inline DtString DtPubSubInteractionsXmlBlock::pubs() const { return myPublications; } 00171 00172 #endif // DtPubSubXmlBlock_H_ 00173