MAK RTIspy API Documentation for HLA 1516
netMapForwarderXmlBlock.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  ** Copyright (c) 2006 MaK Technologies, Inc.
00003  ** All rights reserved.
00004  *********************************************************************/
00005 /*******************************************************************************
00006  ** $RCSfile: netMapForwarderXmlBlock.h,v $ $Revision: 1.6 $ $State: Exp $
00007  *******************************************************************************/
00008 #ifndef DtNetMapForwarderXmlBlock_H_
00009 #define DtNetMapForwarderXmlBlock_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 #include <vector>
00023 
00024 // Define the XML tags used by this block
00025 DtDECLARE_SPY_XML_TAG( DtNetMapForwarderXmlTag );
00026 DtDECLARE_SPY_XML_TAG( DtNetMapNodeXmlTag );
00027 DtDECLARE_SPY_XML_TAG( DtNodeTypeXmlTag );
00028 DtDECLARE_SPY_XML_TAG( DtMapNodeConnIdXmlTag );
00029 DtDECLARE_SPY_XML_TAG( DtMapNodeIpXmlTag );
00030 DtDECLARE_SPY_XML_TAG( DtMapNodeHandleXmlTag );
00031 DtDECLARE_SPY_XML_TAG( DtMapNodeFederationNameXmlTag );
00032 DtDECLARE_SPY_XML_TAG( DtMapNodeSiblingsXmlTag );
00033 DtDECLARE_SPY_XML_TAG( DtMapNodeWebServerIpXmlTag );
00034 DtDECLARE_SPY_XML_TAG( DtMapNodeWebServerPortXmlTag );
00035                       
00036 class DtNetMapForwarderXmlBlock;
00037 class DtNetMapNodeXmlBlock;
00038 typedef DtBoost::shared_ptr<DtNetMapForwarderXmlBlock> DtNetMapForwarderXmlBlockSP;
00039 typedef DtBoost::weak_ptr<DtNetMapForwarderXmlBlock>   DtNetMapForwarderXmlBlockWP;
00040 typedef DtBoost::shared_ptr<DtNetMapNodeXmlBlock> DtNetMapNodeXmlBlockSP;
00041 typedef DtBoost::weak_ptr<DtNetMapNodeXmlBlock>   DtNetMapNodeXmlBlockWP;
00042 
00043 
00044 // The DtNetMapNodeXmlBlock holds information about a Network Map leaf node ( ie -
00045 // an RTI Exec or LRC, not a forwarder )
00046 // Helper class to DtNetMapForwarderXmlBlock.
00047 class DT_DLL_WWW DtNetMapNodeXmlBlock : public DtSpyXmlBlock
00048 {
00049 public:
00050    
00051    static DtSpyXmlBlockSP create( DtNodeAndParentPair xmlNodeAndParent );
00052 
00053 public:
00054    DtNetMapNodeXmlBlock( DtEnvValueSP existingNode, DtEnvValueSP root );
00055    DtNetMapNodeXmlBlock( const DtString& name, const DtString& nodeType, unsigned long connId,
00056       const DtString& ip,  unsigned long handle, const DtString& fedexName, 
00057       const DtString& webServerIp, int webServerPort, DtEnvValueSP root );
00058    virtual ~DtNetMapNodeXmlBlock();
00059 
00060    virtual inline void setType( const DtString& type );
00061    virtual inline DtString type() const;
00062    virtual inline void setConnId( unsigned long connId );
00063    virtual inline unsigned long connId() const;
00064    virtual inline void setIp( const DtString& ip );
00065    virtual inline DtString ip() const;
00066    virtual inline void setHandle( unsigned long handle );
00067    virtual inline unsigned long handle() const;
00068    virtual inline void setFederationName( const DtString& fedexName );
00069    virtual inline DtString federationName() const;
00070    virtual inline void setWebServerIp( const DtString& ip );
00071    virtual inline DtString webServerIp() const;
00072    virtual inline void setWebServerPort( int port );
00073    virtual inline int webServerPort() const;
00074    
00075 protected:
00076 
00077    DtSpyXmlBlockElement< DtString, true > myType;    
00078    DtSpyXmlBlockElement< unsigned long, true > myConnId;    
00079    DtSpyXmlBlockElement< DtString, true > myIp;  
00080    DtSpyXmlBlockElement< DtString, true > myWebServerIp;
00081    DtSpyXmlBlockElement< int, true > myWebServerPort;
00082 
00083    // Federation Name and Federate Handle only valid if available for this node type
00084    DtSpyXmlBlockElement< unsigned long, true > myHandle;    
00085    DtSpyXmlBlockElement< DtString, true > myFederationName;
00086 };
00087 
00088 
00089 // The DtNetMapForwarderXmlBlock holds the network map rooted a this forwarder
00090 // - it may have other DtNetMapForwarderXmlBlocks or DtNetMapNodeXmlBlocks as
00091 //   children
00092 class DT_DLL_WWW DtNetMapForwarderXmlBlock : public DtSpyXmlBlock
00093 {
00094 public:
00095    typedef std::set<DtString> SiblingList;
00096    typedef std::set< DtNetMapNodeXmlBlockSP > NetMapNodeXmlBlockSet;
00097    typedef std::set< DtNetMapForwarderXmlBlockSP > NetMapForwarderXmlBlockSet;
00098 
00099    static DtSpyXmlBlockSP create( DtNodeAndParentPair xmlNodeAndParent );
00100 
00101 public:
00102    DtNetMapForwarderXmlBlock( DtEnvValueSP existingNode, DtEnvValueSP root );
00103    DtNetMapForwarderXmlBlock( const DtString& name, unsigned long connId, const DtString& ip, DtEnvValueSP root );
00104    virtual ~DtNetMapForwarderXmlBlock();
00105 
00106    // Add a new forwarder as a child of this forwarder
00107    // (convenience function to avoid creating child node and parenting it manually)
00108    virtual void addChildForwarder( DtNetMapForwarderXmlBlockSP forwarder );
00109    virtual DtNetMapForwarderXmlBlockSP addChildForwarder( const DtString& name, 
00110       unsigned long connId, const DtString& ip );
00111 
00112    // Get the list of child forwarders
00113    virtual NetMapForwarderXmlBlockSet childForwarders() const;
00114 
00115    // Add a new non-Forwarder node as a child of this forwarder
00116    // (convenience function to avoid creating child node and parenting it manually)
00117    virtual void addChildNode( DtNetMapNodeXmlBlockSP node );
00118    virtual DtNetMapNodeXmlBlockSP addChildNode( const DtString& name, 
00119       const DtString& nodeType, unsigned long connId, const DtString& ip,
00120       const DtString& webServerIp = "0", int webServerPort = 0,
00121       unsigned long handle = 0, const DtString& fedexName = "" );
00122 
00123    // Get the list of non-Forwarder children 
00124    virtual NetMapNodeXmlBlockSet childNodes() const;
00125 
00126 
00127    // Add a sibling relationship between this forwarder and the rhs forwarder node
00128    // (Siblings are directly connected, but NOT downstream)
00129    // NOTE: adds this node to sibling's list and adds sibling to this forwarder's list
00130    virtual void addSiblingRelationship( DtNetMapForwarderXmlBlockSP sibling );
00131 
00132    // Add a sibling to this forwarder's sibling list by name
00133    // (Siblings are directly connected, but NOT downstream)
00134    // (Often we may not have a complete DtNetMapForwarderXmlBlockSP for each sibling)
00135    virtual void addSibling( const DtString& siblingName );
00136 
00137 
00138    // Returns the current sibling list in JSON format (this is currently the only format used by clients)
00139    virtual inline DtString siblings() const;
00140    
00141    virtual inline void setConnId( unsigned long connId );
00142    virtual inline unsigned long connId() const;
00143    virtual inline void setIp( const DtString& ip );
00144    virtual inline DtString ip() const;
00145 
00146 protected:
00147 
00148    // Update the list of sibling forwarder names in JSON format
00149    virtual void updateSiblings();
00150 
00151    // List of sibling names in C++ usable form
00152    SiblingList mySiblingNames;
00153 
00154    // Stores the sibling list in JSON form for use by client
00155    DtSpyXmlBlockElement< DtString, true > mySiblings;
00156    
00157    DtSpyXmlBlockElement< unsigned long, true > myConnId;    
00158    DtSpyXmlBlockElement< DtString, true > myIp;
00159 };
00160 
00161 inline DtString DtNetMapForwarderXmlBlock::siblings() const { return mySiblings; }
00162 inline void DtNetMapForwarderXmlBlock::setConnId( unsigned long connId ) { myConnId = connId; }
00163 inline unsigned long DtNetMapForwarderXmlBlock::connId() const { return myConnId; }
00164 inline void DtNetMapForwarderXmlBlock::setIp( const DtString& ip ) { myIp = ip; }
00165 inline DtString DtNetMapForwarderXmlBlock::ip() const { return myIp; }
00166 inline void DtNetMapNodeXmlBlock::setType( const DtString& type ) { myType = type; }
00167 inline DtString DtNetMapNodeXmlBlock::type() const { return myType; }
00168 inline void DtNetMapNodeXmlBlock::setConnId( unsigned long connId ) { myConnId = connId; }
00169 inline unsigned long DtNetMapNodeXmlBlock::connId() const { return myConnId; }
00170 inline void DtNetMapNodeXmlBlock::setIp( const DtString& ip ) { myIp = ip; }
00171 inline DtString DtNetMapNodeXmlBlock::ip() const { return myIp; }
00172 inline void DtNetMapNodeXmlBlock::setHandle( unsigned long handle ) { myHandle = handle; }
00173 inline unsigned long DtNetMapNodeXmlBlock::handle() const { return myHandle; }
00174 inline void DtNetMapNodeXmlBlock::setFederationName( const DtString& fedexName ) { myFederationName = fedexName; }
00175 inline DtString DtNetMapNodeXmlBlock::federationName() const { return myFederationName; }
00176 inline void DtNetMapNodeXmlBlock::setWebServerIp( const DtString& ip ) { myWebServerIp = ip; }
00177 inline DtString DtNetMapNodeXmlBlock::webServerIp() const { return myWebServerIp; }
00178 inline void DtNetMapNodeXmlBlock::setWebServerPort( int port ) { myWebServerPort = port; }
00179 inline int DtNetMapNodeXmlBlock::webServerPort() const { return myWebServerPort; }
00180 
00181 
00182 #endif // DtNetMapForwarderXmlBlock_H_
00183 

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)