VR-Forces 4.0.4 Class Documentation
include/vrfobjcore/orgManager.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 ** Copyright (c) 2002 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *******************************************************************************/
00005 /*******************************************************************************
00006 ** $RCSfile: orgManager.h,v $ $Revision: 1.18 $ $State: Exp $
00007 *******************************************************************************/
00008 #ifndef orgManager_H_
00009 #define orgManager_H_
00010 
00013 
00014 #include <vlutil/vlConfig.h> 
00015 #include <vector>
00016 #include "vrfobjcore/orgView.h"
00017 #include "vrfutil/callbackList.h"
00018 #include "vrfmsgs/ifObjectIndexData.h"
00019 
00020 #include "vrfobjcore/vrfobjcoreDefines.h"
00021 
00022 class DtOrganizationChangeSet;
00023 class DtSimInterfaceMessage;
00024 class DtPrintPendingOpsCommand;
00025 class DtDeletePendingOpsCommand;
00026 
00027 typedef void (*DtOrganizationManagerCallbackFcn)(void* usr);
00028 
00030 struct DtOrganizationManagerReadyCallbackInfo
00031 {
00032    bool myReady;
00033 };
00034 
00036 typedef DtCallbackList<const DtOrganizationManagerReadyCallbackInfo&>::DtCallbackFunctionType
00037    DtOrganizationManagerReadyCallbackFcn;
00038 
00047 class DT_DLL_vrfobjcore DtOrganizationManager : public DtOrganizationView
00048 {
00049 private:
00051    DtOrganizationManager();
00053    DtOrganizationManager(const DtOrganizationManager& orig);
00055    DtOrganizationManager& operator=(const DtOrganizationManager& orig);
00056 
00057 public:
00058    typedef DtCallbackList<const DtOrganizationManagerReadyCallbackInfo&> DtOrganizationReadyCallbackList;
00059 
00060 public:
00061 
00063    DtOrganizationManager(DtVrfObjectManager *objMgr);
00065    virtual ~DtOrganizationManager();
00066 
00067    virtual bool init();
00068 
00072 
00074    virtual DtOrganizationManagerNode* addEntity(DtVrfObject *vrfObject);
00075 
00077    virtual void removeEntity(DtVrfObject *vrfObject);
00078 
00080    virtual void updateAggregate(DtVrfObject *vrfObject);
00081 
00083    virtual void updateEntity(DtVrfObject *vrfObject);
00084 
00089    virtual void setSuperior(const DtEntityIdentifier& subordinateId,
00090       const DtEntityIdentifier& superiorId, int designator = 0,
00091       bool localOnly = false);
00092   
00097    virtual void setSuperiorToForce(const DtEntityIdentifier& subordinateId,
00098       int designator = 0, bool localOnly = false);
00099 
00107    virtual void queueSetSuperior(const DtString& subordinateName, 
00108       const DtString& superiorName, int designator = 0,
00109       DtOrganizationManagerCallbackFcn completionCallback = 0, void* usrData = 0);
00110 
00118    virtual void queueSetSuperiorToForce(const DtString& subordinateName, 
00119       int designator = 0, DtOrganizationManagerCallbackFcn completionCallback = 0, void* usrData = 0);
00120 
00125    virtual void queueChangeSet(const DtOrganizationChangeSet& changeSet, int& changeSetRequestId,
00126       DtOrganizationManagerCallbackFcn completionCallback = 0, void* usrData = 0);
00127 
00128    virtual void removeChangeSetCallback(int changeSetRequestId,
00129       DtOrganizationManagerCallbackFcn completionCallback, void* usrData = 0);
00130 
00134    virtual void detatchFromSuperior(const DtEntityIdentifier& subordinateId,
00135       bool localOnly = false);
00136 
00139    virtual void setSubordinateOrder(const DtEntityIdentifier& superiorId,
00140       const std::vector<DtEntityIdentifier>& orderedSubordinateList, 
00141       bool localOnly = false);
00142 
00143    static void addToOrganizationCallback(DtSimMessage* msg, void* usr);
00144    static void removeFromOrganizationCallback(DtSimMessage* msg, void* usr);
00145 
00149    static void objectAboutToBeRemovedCallback(DtVrfObject* vrfObject, 
00150       void* usr);
00151    virtual void processObjectAboutToBeRemoved();
00152 
00156    virtual bool allLocalOrgChangesComplete() const;
00157 
00159    virtual bool hasPendingOperations() const;
00160 
00162    virtual void addOrganizationManagerReadyCallback(
00163       DtOrganizationManagerReadyCallbackFcn fcn, void* usrData);
00164 
00166    virtual void removeOrganizationManagerReadyCallback(
00167       DtOrganizationManagerReadyCallbackFcn fcn, void* usrData);
00168 
00170    virtual void runPendingOperations();
00171    
00172    virtual void printPendingOperations() const;
00173 
00174    virtual void deletePendingOperations();
00175 
00176    virtual void deletePendingOperationsFor(DtString objectName);
00177 
00178    virtual void updateObjectIndex();
00179 
00183    virtual bool objectExistsInIndexByName(const DtString& name, 
00184       DtString& simAddress, DtString& objectId);
00185 
00189    virtual bool objectExistsInIndexByGlobalId(const DtString& globalId, DtString& simAddress);
00190 
00193 
00194    static void objectIndexMessageCallback(DtSimMessage* msg, void* usr);
00195    virtual void processObjectIndexMessage(DtSimInterfaceMessage* msg);
00197 
00198 protected:
00200    virtual void invokeOrganizationManagerReadyCallbacks();
00201 
00202    virtual void processAddToOrganization(DtSimMessage* msg);
00203    virtual void processRemoveFromOrganization(DtSimMessage* msg);
00204 
00207    virtual bool setSuperiorIsLocal(const DtEntityIdentifier& subordinateId,
00208       const DtEntityIdentifier& superiorId);
00209 
00212    virtual bool setSuperiorToForceIsLocal(const DtEntityIdentifier& subordinateId);
00213 
00215    virtual bool detatchFromSuperiorIsLocal(const DtEntityIdentifier& subordinateId);
00216 
00218    virtual bool setSubordinateOrderIsLocal(const DtEntityIdentifier& superiorId) const;
00219 
00222    virtual void addOperationToQueue(DtOrgManagerOperation* operation);
00223 
00226    virtual unsigned int newPendingOperationId();
00227 
00228    virtual void clearPendingOperationId(unsigned int id);
00229 
00230    static void pendingOperationCompleteCallback(void* usr);
00231 
00232    static int nextId();
00233 
00234 protected:
00236    typedef std::pair<DtOrganizationManager*, unsigned int> DtPendingOperationCompletionCallbackData;
00237 
00239    DtList myPendingOperationList;
00240 
00242    bool myOperationsRunning;
00243 
00244    std::list<unsigned int> myPendingOperationIdList;
00245    unsigned int myNextPendingOperationId;
00246 
00247    DtOrganizationReadyCallbackList myOrganizationManagerReadyCallbackList;
00248 
00251    std::map<DtString, DtNameToObjectIdMap> myReflectedObjectNames;
00252 
00254    std::map<DtString, DtStringSet> myReflectedObjectGlobalIds;
00255 
00256    double myLastObjectIndexSentTime;
00257    double myObjectIndexHeartbeatThreshold;
00258    bool myForceObjectIndexUpdate;
00259 
00260    DtPrintPendingOpsCommand* myPrintPendingOpsCommand;
00261    DtDeletePendingOpsCommand* myDeletePendingOpsCommand;
00262 
00263    static int theNextId;
00264 
00265 };
00266 
00267 #endif
00268 

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)