VR-Forces 4.0.4 Class Documentation
include/vrfGuiCore/DtVrfStateViewCollectionManager.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2009 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 
00008 
00010 
00011 #pragma once
00012 
00013 #pragma warning (disable:4715)
00014 
00015 #include <vlutil/vlExceptions.h>
00016 
00017 #include <vrfGuiCore/vrfGuiCore.h>
00018 #include <vrfGuiCore/DtVrfObjectDataState.h>
00019 #include <vrfGuiCore/DtEnvironmentState.h>
00020 #include <vrfGuiCore/DtSpotReportState.h>
00021 #include <vrfGuiCore/DtIffStateData.h>
00022 #include <vrfGuiCore/DtAggregateState.h>
00023 #include <vrfGuiCore/DtExtendedStateData.h>
00024 #include <vrfGuiCore/DtVrfSpotReportDataHandler.h>
00025 #include <vrfGuiCore/DtObjectDataInterface.h>
00026 #include <vrvUtil/DtVirtualBaseClass.h>
00027 
00028 #include <vrvCore/DtSimData.h>
00029 #include <vrvCore/DtElementEntry.h>
00030 #include <vrvCore/DtStateViewCollection.h>
00031 #include <vrvCore/DtEntityState.h>
00032 #include <vrvCore/DtElementData.h>
00033 
00034 namespace makVrv
00035 {
00036    class DtDe;
00037 }
00038 
00039 namespace makVrf
00040 {
00042    class DT_DLL_VRFGUICORE DtVrfSimulatedEntityStateViewCollection
00043    : public makVrv::DtStateViewCollection<makVrv::DtVrlinkSimulatedEntityState>
00044    {
00045    public:
00046       DtVrfSimulatedEntityStateViewCollection(makVrv::DtDe& de) 
00047       : makVrv::DtStateViewCollection<makVrv::DtVrlinkSimulatedEntityState>(
00048          de, makVrv::DtSimEntryUpdater::NoUpdates)
00049       {
00050       }
00051    };
00052 
00056    class DT_DLL_VRFGUICORE DtVrlinkSimulatedBaseStateViewCollection
00057    : public makVrv::DtStateViewCollection<makVrv::DtVrlinkSimulatedBaseState>
00058    {
00059    public:
00060       DtVrlinkSimulatedBaseStateViewCollection(makVrv::DtDe& de) :
00061          makVrv::DtStateViewCollection<makVrv::DtVrlinkSimulatedBaseState>(de, makVrv::DtSimEntryUpdater::NoUpdates)
00062       {
00063       }
00064 
00065       bool isCompatible(makVrv::DtSimObjectEntry& entry)
00066       {
00067          return makVrv::DtStateViewCollection<makVrv::DtVrlinkSimulatedBaseState>::isCompatible(entry);
00068       }
00069    };
00070 
00073    class DT_DLL_VRFGUICORE DtVrfObjectDataStateViewCollection : public makVrv::DtStateViewCollection<DtVrfObjectDataState>
00074    {
00075    public:
00076       DtVrfObjectDataStateViewCollection(makVrv::DtDe& de) :
00077          makVrv::DtStateViewCollection<DtVrfObjectDataState>(de, makVrv::DtSimEntryUpdater::NoUpdates)
00078       {
00079       }
00080    };
00081 
00083    class DT_DLL_VRFGUICORE DtIffStateDataViewCollection : public makVrv::DtStateViewCollection<DtIffStateData>
00084    {
00085    public:
00086       DtIffStateDataViewCollection(makVrv::DtDe& de) :
00087          makVrv::DtStateViewCollection<DtIffStateData>(de, makVrv::DtSimEntryUpdater::NoUpdates)
00088       {
00089       }
00090    };
00091 
00093    class DT_DLL_VRFGUICORE DtEnvironmentStateViewCollection : public makVrv::DtStateViewCollection<DtVrlinkSimulatedEnvironmentProcess>
00094    {
00095    public:
00096       DtEnvironmentStateViewCollection(makVrv::DtDe& de) :
00097          makVrv::DtStateViewCollection<DtVrlinkSimulatedEnvironmentProcess>(de, makVrv::DtSimEntryUpdater::NoUpdates)
00098       {
00099       }
00100    };
00101 
00103    class DT_DLL_VRFGUICORE DtExtendedStateDataViewCollection : public makVrv::DtStateViewCollection<DtExtendedStateData>
00104    {
00105    public:
00106       DtExtendedStateDataViewCollection(makVrv::DtDe& de) :
00107          makVrv::DtStateViewCollection<DtExtendedStateData>(de, makVrv::DtSimEntryUpdater::NoUpdates)
00108       {
00109       }
00110    };
00111 
00113    class DT_DLL_VRFGUICORE DtAggregateStateViewCollection : public makVrv::DtStateViewCollection<DtVrlinkSimulatedAggregateState>
00114    {
00115    public:
00116       DtAggregateStateViewCollection(makVrv::DtDe& de) :
00117          makVrv::DtStateViewCollection<DtVrlinkSimulatedAggregateState>(de, makVrv::DtSimEntryUpdater::NoUpdates)
00118       {
00119       }
00120    };
00121 
00123    class DT_DLL_VRFGUICORE DtSpotReportStateViewCollection : public makVrv::DtStateViewCollection<DtSpotReportState>
00124    {
00125    public:
00126       DtSpotReportStateViewCollection(makVrv::DtDe& de) :
00127          makVrv::DtStateViewCollection<DtSpotReportState>(de, makVrv::DtSimEntryUpdater::AnyUpdates)
00128       {
00129       }
00130    };
00131 
00132    
00147    class DT_DLL_VRFGUICORE DtVrfStateViewCollectionManager : public makVrv::DtVirtualBaseClass
00148    {
00149    public:
00150 
00151       DtVrfStateViewCollectionManager(makVrv::DtDe&);
00152       virtual ~DtVrfStateViewCollectionManager();
00153 
00154       static DtVrfStateViewCollectionManager& instance(makVrv::DtDe& de);
00155       
00167 
00168 
00171       virtual DtBoost::shared_ptr<DtObjectDataInterface> lookupObjectData(const makVrv::DtUniqueID& id);
00172 
00175       virtual DtBoost::shared_ptr<DtObjectDataInterface> lookupSpotReportData(const makVrv::DtUniqueID& id);
00176 
00179       virtual DtBoost::shared_ptr<DtObjectDataInterface> lookupObjectData(const std::string& name);
00180 
00183       virtual DtBoost::shared_ptr<DtObjectDataInterface> lookupSpotReportData(const std::string& name);
00184 
00188       template<typename T_ObjectDataInterfaceType>
00189       DtBoost::shared_ptr<T_ObjectDataInterfaceType> lookupAndCastObjectData(const makVrv::DtUniqueID& id)
00190       {
00191          return DtObjectDataInterface::cast<T_ObjectDataInterfaceType>(lookupObjectData(id));
00192       }
00193 
00197       template<typename T_ObjectDataInterfaceType>
00198       DtBoost::shared_ptr<T_ObjectDataInterfaceType> lookupAndCastSpotReportData(const makVrv::DtUniqueID& id)
00199       {
00200          return DtObjectDataInterface::cast<T_ObjectDataInterfaceType>(lookupSpotReportData(id));
00201       }
00202 
00206       template<typename T_ObjectDataInterfaceType>
00207       DtBoost::shared_ptr<T_ObjectDataInterfaceType> lookupAndCastObjectData(const std::string& name)
00208       {
00209          return DtObjectDataInterface::cast<T_ObjectDataInterfaceType>(lookupObjectData(name));
00210       }
00211 
00215       template<typename T_ObjectDataInterfaceType>
00216       DtBoost::shared_ptr<T_ObjectDataInterfaceType> lookupAndCastSpotReportData(const std::string& name)
00217       {
00218          return DtObjectDataInterface::cast<T_ObjectDataInterfaceType>(lookupSpotReportData(name));
00219       }
00220 
00223       virtual DtBoost::shared_ptr<DtObjectDataInterface> lookupObjectData(makVrv::DtStateView<makVrv::DtSimState>* stateView);
00225 
00227       makVrv::DtStateView<makVrv::DtVrlinkSimulatedBaseState>* findStateView(const std::string& markingText);
00228 
00230       makVrv::DtStateView<DtSpotReportState>* findSpotReportStateView(const std::string& markingText);
00231 
00234       makVrv::DtStateView<makVrv::DtVrlinkSimulatedBaseState>* findStateView(const makVrv::DtUniqueID& id)
00235       {
00236          if (!mySimulatedBaseStateViewCollection->hasStateView(id))
00237          {
00238             return 0;
00239          }
00240 
00241          return const_cast<makVrv::DtStateView<makVrv::DtVrlinkSimulatedBaseState>*>
00242             (mySimulatedBaseStateViewCollection->findStateView(id));
00243       }
00244 
00247       makVrv::DtStateView<DtSpotReportState>* findSpotReportStateView(const makVrv::DtUniqueID& id)
00248       {
00249          if (!mySpotReportStateViewCollection->hasStateView(id))
00250          {
00251             return 0;
00252          }
00253 
00254          return const_cast<makVrv::DtStateView<DtSpotReportState>*>
00255             (mySpotReportStateViewCollection->findStateView(id));
00256       }
00257 
00261       DtVrfSimulatedEntityStateViewCollection* simulatedEntityStateViewCollection()
00262       {
00263          return mySimulatedEntityStateView;
00264       }
00265 
00266       DtVrlinkSimulatedBaseStateViewCollection* simulatedBaseStateViewCollection()
00267       {
00268          return mySimulatedBaseStateViewCollection;
00269       }
00270 
00271       DtVrfObjectDataStateViewCollection* objectDataStateViewCollection()
00272       {
00273          return myObjectDataStateViewCollection;
00274       }
00275       
00276       DtEnvironmentStateViewCollection* environmentStateViewCollection()
00277       {
00278          return myEnvironmentStateViewCollection;
00279       }
00280       
00281       DtExtendedStateDataViewCollection* extendedStateDataViewCollection()
00282       {
00283          return myExtendedStateDataViewCollection;
00284       }
00285       
00286       DtIffStateDataViewCollection* iffStateDataViewCollection()
00287       {
00288          return myIffStateDataViewCollection;
00289       }
00290       
00291       DtSpotReportStateViewCollection* spotReportStateViewCollection()
00292       {
00293          return mySpotReportStateViewCollection;
00294       }
00295       
00296       DtAggregateStateViewCollection* aggregateStateViewCollection()
00297       {
00298          return myAggregateStateViewCollection;
00299       }
00301 
00304       makVrv::DtUniqueID parentId(const makVrv::DtUniqueID&) const;
00305 
00306       makVrv::DtUniqueID displayIdFromSimId(const makVrv::DtUniqueID& id, int modelSet = -1) const;
00307       makVrv::DtElementData::SceneObjectIdList displayIdsFromSimId(const makVrv::DtUniqueID& id, int modelSet = -1) const;
00308 
00310       makVrv::DtUniqueID simIdFromDisplayId(const makVrv::DtUniqueID& id) const;
00311 
00313       virtual std::string entityName(const makVrv::DtUniqueID simId) const;
00314 
00316       virtual std::string overlayName(const makVrv::DtUniqueID simId) const;
00317 
00319       virtual makVrv::DtElementEntry::ElementType elementType(const makVrv::DtElementID&) const;
00320 
00322       virtual makVrv::DtSimEntryUpdater::UpdateRate updateRateFor(const makVrv::DtBaseStateView* state) const;
00323 
00324       typedef std::vector<makVrv::DtSimEntryUpdater::UpdateRate> UpdateRates;
00325       virtual makVrv::DtSimEntryUpdater::UpdateRate minimumRate(const UpdateRates&) const;
00326       virtual makVrv::DtSimEntryUpdater::UpdateRate maximumRate(const UpdateRates&) const;
00327 
00331       virtual void setUpdateRate(makVrv::DtSimEntry*, makVrv::DtSimEntryUpdater::UpdateRate, 
00332          makVrv::DtBaseStateView* state);
00333 
00334    protected:
00335       DtVrfSimulatedEntityStateViewCollection*  mySimulatedEntityStateView;
00336       DtVrlinkSimulatedBaseStateViewCollection* mySimulatedBaseStateViewCollection;
00337       DtVrfObjectDataStateViewCollection*       myObjectDataStateViewCollection;
00338       DtEnvironmentStateViewCollection*         myEnvironmentStateViewCollection;
00339       DtSpotReportStateViewCollection*          mySpotReportStateViewCollection;
00340       DtAggregateStateViewCollection*           myAggregateStateViewCollection;
00341       DtExtendedStateDataViewCollection*        myExtendedStateDataViewCollection;
00342       DtIffStateDataViewCollection*             myIffStateDataViewCollection;
00343       makVrv::DtDe&                             myDe;
00344 
00345       typedef boost::unordered_map<makVrv::DtBaseStateView*, UpdateRates> UpdateRateMap;
00346 
00347       UpdateRateMap myUpdateRateMap;
00348    };
00349 
00350    template<typename T> T findStateFor(makVrv::DtSimEntry* entry)
00351    {
00352       makVrv::DtSimEntry::SimStateVector::const_iterator pos    = entry->simStates().begin();
00353       makVrv::DtSimEntry::SimStateVector::const_iterator endPos = entry->simStates().end();
00354       for(; pos != endPos; ++pos)
00355       {
00356          T tState = dynamic_cast<T>(*pos);
00357          if(tState)
00358          {
00359             return tState;
00360          }
00361       }
00362 
00363       return 0;
00364    }
00365 }

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)