VR-Forces 4.0.4 Class Documentation
include/vrvCore/DtFileCache.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2008 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 /******************************************************************************
00006 ** $RCSfile: DtFileCache.h,v $ $Revision: 1.14 $ $State: Exp $
00007 ******************************************************************************/
00008 
00012 
00013 #pragma once
00014 #include <vrvCore/vrvCore.h>
00015 #include <vrvUtil/DtVirtualBaseClass.h>
00016 #include <boost/signals.hpp>
00017 #include <boost/unordered_set.hpp>
00018 #include <string>
00019 #include <deque>
00020 #include <map>
00021 
00022 namespace makArchives 
00023 {
00024    class DtCacheSettingsRecord;
00025 }
00026 
00027 namespace makVrv
00028 {
00029    class DtDe;
00030    class DtRecordSettingsBackupInterface;
00031 
00036    class DT_DLL_VRVCORE DtFileCache
00037    {
00038    public:
00039 
00041       typedef boost::unordered_set<std::string> ExcludedExtensions;
00042       typedef std::deque<std::string> FilePathList;
00043 
00044       struct LoadFileOptions
00045       {         
00046          FilePathList myDatabasePaths;
00047          unsigned int myCacheHint;
00048 
00049          std::multimap<std::string,std::string> customOptionStrings;
00050 
00051          std::string myCacheDir;
00052          std::string myOriginalPath;
00053          bool myHasNoOptions;
00054          bool myUseAccelerationCacheFlag;
00055 
00056          bool myInstanceNodesFlag;
00057          bool myInstanceTexturesFlag;
00058          bool myCompressTexturesFlag;
00059          bool myUnloadImageDataFlag;
00060 
00061          bool myOptimizeDataFlag;
00062          int myOptimizeFileLevel;
00063          bool myFlipDDSTexturesFlag;
00064       };
00065 
00068       friend class DtFileCacheCreator;
00069 
00071       friend class DtDeSharedState;
00072 
00074       virtual ~DtFileCache();
00075 
00077       LoadFileOptions defaultOptions();
00078 
00081       virtual bool getCachedNodeFile(const std::string& filePathIn, 
00082          const FilePathList& paths, std::string& cachedFilePathOut, 
00083          bool emitError );
00084 
00087       virtual bool getCachedImageFile(const std::string& filePathIn,
00088          const FilePathList& paths, std::string& cachedFilePathOut, 
00089          bool emitError);
00090 
00092       virtual void setCachingEnabled(bool flag);
00093 
00095       virtual bool acceleratedCachingEnabled() const;
00096 
00101       virtual void setCompressTextures(bool compress);
00102 
00104       virtual bool compressTexturesEnabled() const;
00105 
00107       virtual void releaseResources();
00108 
00110       virtual void clearAccelerationCache();
00111 
00113       virtual void setInstancingEnabled(bool enabled);
00114 
00116       virtual bool instancingEnabled();
00117 
00119       bool clearInstancesOnNewScene() const;
00120 
00122       void setClearInstancesOnNewScene(bool clearInstances);
00123 
00125       void clearInstancingCache();
00126 
00131       void flushInstanceCache(bool multipass,bool flushNodes, 
00132          bool flushTextures, bool flushImages);
00133 
00136       unsigned int flushCycleCount();
00137 
00139       virtual void ts_clearInstancingCache();
00140 
00142       virtual void setFromRecord(const makArchives::DtCacheSettingsRecord& rec);
00143 
00145       virtual void getRecord(makArchives::DtCacheSettingsRecord& rec);
00146 
00148       void loadDefaults(bool loadOnlyFactorySettings = false);
00149 
00151       void saveAsDefaults();
00152 
00154       void exportSettings(const std::string& fileName);
00155 
00157       void importSettings(const std::string& fileName);
00158 
00160       virtual ExcludedExtensions& excludedExtensions();
00161 
00163       inline bool isExcludedExtension(const std::string& ext) const
00164       {
00165          return ts_isExcludedExtension(ext);
00166       }
00167 
00168       const DtRecordSettingsBackupInterface* settingsBackup() const
00169       {
00170          return mySettingsBackup;
00171       }
00172 
00173       DtRecordSettingsBackupInterface* settingsBackup()
00174       {
00175          return mySettingsBackup;
00176       }
00177 
00180       boost::signal<void ()> signal_clearInstanceCache;
00181 
00182    protected:
00183 
00185       virtual void autoSaveDefaultsIfNeeded();
00186 
00188       virtual bool ts_isExcludedExtension(const std::string& ext) const;
00189 
00191       virtual void ts_flushInstancingCache(bool multiPass,
00192          bool flushNodes, bool flushTextures, bool flushImages);
00193 
00196       virtual void addExcludedExtension(const std::string &ext);
00197 
00200       virtual void removeExcludedExtension(const std::string &ext);
00201 
00203       DtFileCache(DtDe& de);
00204 
00207       virtual bool save(const std::string& origFilename, 
00208          const std::string& cachedFilename);
00209 
00210    protected:
00211 
00212       DtDe& myDe;
00213       bool myCachingEnabled;
00214       bool myCompressTextureFlag;
00215       bool myClearInstancesOnNewSceneFlag;
00216       bool myInstancingEnabled;
00217       unsigned int myFlushCycleCount;
00218 
00219       ExcludedExtensions myExcludedExtensionMap;
00220 
00221       DtRecordSettingsBackupInterface* mySettingsBackup;
00222    };
00223 
00226    class DT_DLL_VRVCORE DtFileCacheCreator : public DtVirtualBaseClass
00227    {
00228 
00229    public:
00230 
00233       static DtFileCacheCreator& instance(DtDe& theIG);
00234 
00236       static void registerInstance(DtDe& de, DtFileCacheCreator* instance);     
00237 
00239       virtual DtFileCache* create(DtDe& de);
00240 
00241    };
00242 
00243 }

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)