MAK RTIspy API Documentation for HLA 1516
asynchronousFileDistributor.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 2007 MaK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: asynchronousFileDistributor.h,v $ $Revision: 1.9 $ $State: Exp $
00007 *********************************************************************/
00008 
00011 
00012 #ifndef DtAsyncFileDistributorRunnable_H_
00013 #define DtAsyncFileDistributorRunnable_H_
00014 
00015 
00016 #include "fileDistributor.h"
00017 #include "distributorThreadEvents.h"
00018 #include <vlutil/vlRunnable.h>
00019 #include <vlutil/vlThread.h>
00020 #include "vlThreadSafeQueue.h"
00021 #include <vlutil/vlThreadSafe.h>
00022 #include "vlThreadedObject.h"
00023 #include "fedex.h"
00024 
00027 class DtAsyncFileDistributorRunnable;
00028 
00029 
00033 class DT_DLL_EXEC DtAsyncFileDistributorRunnable : public DtRunnable, public DtFileDistributor
00034 {
00035 
00036 public:   
00037 
00039    DtAsyncFileDistributorRunnable( DtFedExec* parent );
00040 
00042    virtual ~DtAsyncFileDistributorRunnable();
00043 
00044 
00045    //Event processing.
00046 
00047    virtual std::auto_ptr<DtDistributorThreadEvent> getNextEvent();
00048 
00049    virtual void postCommand( std::auto_ptr<DtFedExecDistribFunctor> cmd);
00050 
00051    virtual void setOnExitHandler( const DtDistributorThreadEvent& fn );
00052 
00053    //Register/ Unregister event calls:
00054    virtual void registerUploadFedFileToExecEvent( const DtDistribFunctor& fn );
00055    virtual void registerFedFileRequestsEvent( const DtDistribFunctor& fn );
00056    virtual void registerRequestedModulesArrivedEvent( const DtDistribFunctor& fn );
00057    virtual void registerTakeFileEvent( const DtDistribFunctor& fn );
00058    virtual void registerPushFedFileToFederatesEvent( const DtDistribFunctor& fn );
00059    virtual void registerPushFedFileToSingleFederateEvent( const DtDistribFunctor& fn );
00060 
00061 
00062 public:
00063 
00065    virtual void run();
00066      
00067    static DtAsyncFileDistributorRunnable* create( DtFedExec* parent );
00068       
00069    virtual void requestFedFileUploadToExec( const unsigned long initiatingFedID,
00070                                                           const std::vector<DtString>* modules);
00071    virtual bool sendFedFile(const std::vector<DtString>& modules, DtFederateHandle recipient);
00072 
00074    virtual void fedFileUploaded(const DtString fileUploaded);
00075 
00076    void processTakeFileCmd(std::map<DtString, DtFileInformation*>);
00077 
00078    void processPushFedFileToAllFederates(DtString name, int size, const char* buff, unsigned long destination);
00079    void processFileRequested( const DtFomModuleRequestMsg& cmd );
00080    void processFileReceived( const DtFomModuleDistributionMsg& cmd );
00081 
00082 
00084    bool requestsPending() const;
00085 
00086 private:
00087    DtAsyncFileDistributorRunnable();
00088    DtAsyncFileDistributorRunnable(const DtAsyncFileDistributorRunnable& orig);
00089    DtAsyncFileDistributorRunnable& operator=(const DtAsyncFileDistributorRunnable& orig);
00090 
00091 
00092 private:
00093 
00094    DtFedExec*        myFedEx;
00095 
00096 protected:
00097 
00098    typedef std::list<DtDistributorThreadEvent*> DtDistributorThreadEventList;
00099 
00100 protected:
00101    void signalFrontEnd() const;
00102    bool executeCommand();
00103    void processInternalCommands();
00104    void changeCallbackEvents( const DtDistribFunctorChangeRequest& fn );
00105    void clearEventList( rtiMsgList& theEventList );
00106    bool myStopped;
00107 
00108 protected:
00109    std::auto_ptr<DtFedExecDistribFunctor> mySignal;
00110    std::auto_ptr<DtDistributorThreadEvent> myOnExitEvent;
00111 
00112    DtThreadSafeQueue<DtDistributorThreadEvent> myPendingCommands;
00113 
00114    DtThreadSafeQueue<DtDistributorThreadEvent> myEventQueue;
00115 
00116    DtThreadSafeQueue<DtDistributorThreadEvent> myInternalCmdQueue;
00117 
00119    DtDistributorThreadEventList myRequestedModuleArrivedEvents;
00120    DtDistributorThreadEventList myTakeFileEvents;
00121    DtDistributorThreadEventList myFedFileRequestedEvents;      
00122    DtDistributorThreadEventList myFedFileReceivedEvents;
00123    DtDistributorThreadEventList myPushFedFileToAllFederatesEvents;
00124    DtDistributorThreadEventList myPushFedFileToSingleFederateEvents;
00125    DtDistributorThreadEventList myUploadRequestEvents;
00126 
00127 
00128    typedef std::pair< DtDistributorThreadEvent*, bool>      DtMsgFunctorIsMomMsgPair;
00129 
00130 
00131 
00132 };
00133 
00134 #endif  //! DtAsyncFileDistributorRunnable_H_

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)