VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtFileCache.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 #include <vrvCore/vrvCore.h>
13 #include <vrvUtil/signalslib.h>
14 #include <boost/unordered_set.hpp>
15 #include <string>
16 #include <deque>
17 #include <map>
18 #include <tbb/task.h>
20 
21 namespace makArchives
22 {
23  class DtCacheSettingsRecord;
24 }
25 
26 namespace makVrv
27 {
28  class DtDe;
29  class DtRecordSettingsBackupInterface;
30  class DtFileCache;
31  class DtTextureInterface;
32 
38  {
39  public:
40 
42  typedef boost::unordered_set<std::string> ExcludedExtensions;
43  typedef std::deque<std::string> FilePathList;
44 
46  {
48  unsigned int myCacheHint;
49 
50  std::multimap<std::string,std::string> customOptionStrings;
51  std::multimap<std::string, void*> customPluginData;
52 
53  std::string myCacheDir;
54  std::string myOriginalPath;
57 
63 
68  };
69 
72  friend class DtFileCacheCreator;
73 
75  friend class DtDeSharedState;
76 
78  virtual ~DtFileCache();
79 
81  virtual void init();
82 
85  virtual void initSingletonDependencies();
86 
88  LoadFileOptions defaultOptions() const;
89 
92  virtual bool getCachedNodeFile(const std::string& filePathIn,
93  const FilePathList& paths, std::string& cachedFilePathOut,
94  bool emitError );
95 
98  virtual bool getCachedImageFile(const std::string& filePathIn,
99  const FilePathList& paths, std::string& cachedFilePathOut,
100  bool emitError);
101 
103  virtual void setCachingEnabled(bool flag);
104 
106  virtual bool acceleratedCachingEnabled() const;
107 
112  virtual void setCompressTextures(bool compress);
113 
115  virtual bool compressTexturesEnabled() const;
116 
118  virtual void releaseResources();
119 
121  virtual void clearAccelerationCache();
122 
124  virtual void setInstancingEnabled(bool enabled);
125 
127  virtual bool instancingEnabled() const;
128 
130  bool clearInstancesOnNewScene() const;
131 
133  void setClearInstancesOnNewScene(bool clearInstances);
134 
136  void clearInstancingCache();
137 
143  void flushInstanceCache(bool multipass,bool flushNodes,
144  bool flushTextures, bool flushImages);
145 
148  unsigned int flushCycleCount();
149 
151  virtual void ts_clearInstancingCache();
152 
154  virtual void setFromRecord(const makArchives::DtCacheSettingsRecord& rec);
155 
157  virtual void getRecord(makArchives::DtCacheSettingsRecord& rec) const;
158 
161  virtual void getSplitRecord(std::vector<makArchives::DtCacheSettingsRecord>& rec,
162  std::vector<std::string>& fileNames) {};
163 
167  makArchives::DtCacheSettingsRecord& combinedRec) {};
168 
170  void loadDefaults(bool loadOnlyFactorySettings = false);
171 
173  void saveAsDefaults();
174 
176  void exportSettings(const std::string& fileName);
177 
179  void importSettings(const std::string& fileName);
180 
182  virtual ExcludedExtensions& excludedExtensions();
183 
185  inline bool isExcludedExtension(const std::string& ext) const
186  {
187  return ts_isExcludedExtension(ext);
188  }
189 
191  {
192  return mySettingsBackup;
193  }
194 
196  {
197  return mySettingsBackup;
198  }
199 
201  {
202  return myDe;
203  }
204 
207  boost::signalslib::signal<void ()> signal_clearInstanceCache;
208 
210  virtual void ts_flushInstancingCache(bool multiPass,
211  bool flushNodes, bool flushTextures, bool flushImages);
212 
218  virtual bool getOrLoadTexture( DtTextureInterface* textureWrapper, const std::string& filename,
219  const DtFileCache::LoadFileOptions& loadFileOptions );
220 
221  protected:
222 
224  virtual void autoSaveDefaultsIfNeeded();
225 
227  virtual bool ts_isExcludedExtension(const std::string& ext) const;
228 
231  virtual void addExcludedExtension(const std::string &ext);
232 
235  virtual void removeExcludedExtension(const std::string &ext);
236 
240  DtFileCache(DtDe& de);
241 
244  virtual bool save(const std::string& origFilename,
245  const std::string& cachedFilename, bool optimize);
246 
247 
248  protected:
249 
255  unsigned int myFlushCycleCount;
256 
258 
260 
262  };
263 
267  {
268 
269  public:
270 
273  static DtFileCacheCreator& instance(DtDe& theIG);
274 
276  static void registerInstance(DtDe& de, DtFileCacheCreator* instance);
277 
279  virtual DtFileCache* create(DtDe& de);
280 
281  };
282 
283 }
DtDe & myDe
Definition: DtFileCache.h:250
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
unsigned int myCacheHint
Definition: DtFileCache.h:48
std::deque< std::string > FilePathList
Definition: DtFileCache.h:43
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
bool myFlipDDSTexturesFlag
Definition: DtFileCache.h:66
bool myCachingEnabled
Definition: DtFileCache.h:251
bool myUseMemoryImageCacheFlag
Definition: DtFileCache.h:59
boost::unordered_set< std::string > ExcludedExtensions
A set of extensions excluded from the cache.
Definition: DtFileCache.h:42
std::string myCacheDir
Definition: DtFileCache.h:53
bool myInstancingEnabled
Definition: DtFileCache.h:254
bool myCompressTexturesFlag
Definition: DtFileCache.h:61
bool myInstanceTexturesFlag
Definition: DtFileCache.h:60
std::multimap< std::string, void * > customPluginData
Definition: DtFileCache.h:51
bool myUseAccelerationCacheFlag
Definition: DtFileCache.h:56
The abstract creator for the abstract DtFileCache class.
Definition: DtFileCache.h:266
ExcludedExtensions myExcludedExtensionMap
Definition: DtFileCache.h:259
bool myCompressTextureFlag
Definition: DtFileCache.h:252
Interface for a texture. Used to pass in a texture to vrvGraphics.
Definition: DtTextureInterface.h:24
virtual void addRecords(makArchives::DtCacheSettingsRecord &recs, makArchives::DtCacheSettingsRecord &combinedRec)
To support writing element definitions in folders as multiple files not implemented for DtFileCache...
Definition: DtFileCache.h:166
bool myHasNoOptions
Definition: DtFileCache.h:55
bool myCDBSource
Definition: DtFileCache.h:67
bool myOptimizeDataFlag
Definition: DtFileCache.h:64
bool myUnloadImageDataFlag
Definition: DtFileCache.h:62
std::string myOriginalPath
Definition: DtFileCache.h:54
Contains makVrv::DtVirtualBaseClass class.
DtRecordSettingsBackupInterface * mySettingsBackup
Definition: DtFileCache.h:261
The DtDeSharedState represents all the data that is shared between the master and its slaves...
Definition: DtDeSharedState.h:45
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
DtDe & getDe()
Definition: DtFileCache.h:200
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
std::multimap< std::string, std::string > customOptionStrings
Definition: DtFileCache.h:50
DtRecordSettingsBackupInterface * settingsBackup()
Definition: DtFileCache.h:195
Definition: DtFileCache.h:45
int myOptimizeFileLevel
Definition: DtFileCache.h:65
Record for the settings associated with the VRV caching.
Definition: DtCacheSettingsRecord.h:17
bool myInstanceNodesFlag
Definition: DtFileCache.h:58
bool myClearInstancesOnNewSceneFlag
Definition: DtFileCache.h:253
Base class to provide boost signal/slot management.
bool isExcludedExtension(const std::string &ext) const
Check if the extension is in the list of excluded file types.
Definition: DtFileCache.h:185
DtSignalConnectionManager myConnectionManager
Definition: DtFileCache.h:257
virtual void getSplitRecord(std::vector< makArchives::DtCacheSettingsRecord > &rec, std::vector< std::string > &fileNames)
To support writing element definitions in folders as multiple files not implemented for DtFileCache...
Definition: DtFileCache.h:161
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:72
const DtRecordSettingsBackupInterface * settingsBackup() const
Definition: DtFileCache.h:190
The makVrv::DtRecordSettingsBackupInterface provides an interface to record-based backups...
Definition: DtRecordSettingsBackup.h:24
FilePathList myDatabasePaths
Definition: DtFileCache.h:47
Handles the caching of files. Includes functions for excluding files with certain extensions from bei...
Definition: DtFileCache.h:37
unsigned int myFlushCycleCount
Definition: DtFileCache.h:255
boost::signalslib::signal< void()> signal_clearInstanceCache
Signal emmitted when clearCache is called, used to allow other caches to be cleared.
Definition: DtFileCache.h:207
Contains DLL export macros.

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)