VR-Forces 4.10 Class Documentation
 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) 2021 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 
34  class DT_DLL_VRVCORE DtFileCacheFlushAsync : public tbb::task
35  {
36  public:
37  DtFileCacheFlushAsync(DtFileCache* cache, bool multipass, bool flushNodes, bool flushTextures, bool flushImages);
38  virtual tbb::task* execute();
39 
40  protected:
46  };
47 
53  {
54  public:
55 
57  typedef boost::unordered_set<std::string> ExcludedExtensions;
58  typedef std::deque<std::string> FilePathList;
59 
61  {
63  unsigned int myCacheHint;
64 
65  std::multimap<std::string,std::string> customOptionStrings;
66  std::multimap<std::string, void*> customPluginData;
67 
68  std::string myCacheDir;
69  std::string myOriginalPath;
72 
78 
83  };
84 
87  friend class DtFileCacheCreator;
88 
90  friend class DtDeSharedState;
91 
93  virtual ~DtFileCache();
94 
96  virtual void init();
97 
100  virtual void initSingletonDependencies();
101 
103  LoadFileOptions defaultOptions() const;
104 
107  virtual bool getCachedNodeFile(const std::string& filePathIn,
108  const FilePathList& paths, std::string& cachedFilePathOut,
109  bool emitError );
110 
113  virtual bool getCachedImageFile(const std::string& filePathIn,
114  const FilePathList& paths, std::string& cachedFilePathOut,
115  bool emitError);
116 
118  virtual void setCachingEnabled(bool flag);
119 
121  virtual bool acceleratedCachingEnabled() const;
122 
127  virtual void setCompressTextures(bool compress);
128 
130  virtual bool compressTexturesEnabled() const;
131 
133  virtual void releaseResources();
134 
136  virtual void clearAccelerationCache();
137 
139  virtual void setInstancingEnabled(bool enabled);
140 
142  virtual bool instancingEnabled() const;
143 
145  bool clearInstancesOnNewScene() const;
146 
148  void setClearInstancesOnNewScene(bool clearInstances);
149 
151  void clearInstancingCache();
152 
158  void flushInstanceCache(bool multipass,bool flushNodes,
159  bool flushTextures, bool flushImages);
160 
163  unsigned int flushCycleCount();
164 
166  virtual void ts_clearInstancingCache();
167 
169  virtual void setFromRecord(const makArchives::DtCacheSettingsRecord& rec);
170 
172  virtual void getRecord(makArchives::DtCacheSettingsRecord& rec);
173 
176  virtual void getSplitRecord(std::vector<makArchives::DtCacheSettingsRecord>& rec,
177  std::vector<std::string>& fileNames) {};
178 
182  makArchives::DtCacheSettingsRecord& combinedRec) {};
183 
185  void loadDefaults(bool loadOnlyFactorySettings = false);
186 
188  void saveAsDefaults();
189 
191  void exportSettings(const std::string& fileName);
192 
194  void importSettings(const std::string& fileName);
195 
197  virtual ExcludedExtensions& excludedExtensions();
198 
200  inline bool isExcludedExtension(const std::string& ext) const
201  {
202  return ts_isExcludedExtension(ext);
203  }
204 
206  {
207  return mySettingsBackup;
208  }
209 
211  {
212  return mySettingsBackup;
213  }
214 
216  {
217  return myDe;
218  }
219 
222  boost::signalslib::signal<void ()> signal_clearInstanceCache;
223 
225  virtual void ts_flushInstancingCache(bool multiPass,
226  bool flushNodes, bool flushTextures, bool flushImages);
227 
228  protected:
229 
231  virtual void autoSaveDefaultsIfNeeded();
232 
234  virtual bool ts_isExcludedExtension(const std::string& ext) const;
235 
238  virtual void addExcludedExtension(const std::string &ext);
239 
242  virtual void removeExcludedExtension(const std::string &ext);
243 
247  DtFileCache(DtDe& de);
248 
251  virtual bool save(const std::string& origFilename,
252  const std::string& cachedFilename, bool optimize);
253 
254 
255  protected:
256 
262  unsigned int myFlushCycleCount;
263 
265 
267 
269  };
270 
274  {
275 
276  public:
277 
280  static DtFileCacheCreator& instance(DtDe& theIG);
281 
283  static void registerInstance(DtDe& de, DtFileCacheCreator* instance);
284 
286  virtual DtFileCache* create(DtDe& de);
287 
288  };
289 
290 }
DtDe & myDe
Definition: DtFileCache.h:257
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
bool myFlushImages
Definition: DtFileCache.h:45
unsigned int myCacheHint
Definition: DtFileCache.h:63
std::deque< std::string > FilePathList
Definition: DtFileCache.h:58
Virtual base class.
Definition: DtVirtualBaseClass.h:19
bool myFlipDDSTexturesFlag
Definition: DtFileCache.h:81
bool myCachingEnabled
Definition: DtFileCache.h:258
bool myUseMemoryImageCacheFlag
Definition: DtFileCache.h:74
boost::unordered_set< std::string > ExcludedExtensions
A set of extensions excluded from the cache.
Definition: DtFileCache.h:57
std::string myCacheDir
Definition: DtFileCache.h:68
bool myInstancingEnabled
Definition: DtFileCache.h:261
bool myCompressTexturesFlag
Definition: DtFileCache.h:76
bool myMultipass
Definition: DtFileCache.h:42
Creates another thread to clear out cache.
Definition: DtFileCache.h:34
bool myInstanceTexturesFlag
Definition: DtFileCache.h:75
std::multimap< std::string, void * > customPluginData
Definition: DtFileCache.h:66
bool myUseAccelerationCacheFlag
Definition: DtFileCache.h:71
bool myFlushNodes
Definition: DtFileCache.h:43
The abstract creator for the abstract DtFileCache class.
Definition: DtFileCache.h:273
ExcludedExtensions myExcludedExtensionMap
Definition: DtFileCache.h:266
bool myCompressTextureFlag
Definition: DtFileCache.h:259
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:181
bool myHasNoOptions
Definition: DtFileCache.h:70
bool myCDBSource
Definition: DtFileCache.h:82
DtFileCache * myCache
Definition: DtFileCache.h:41
bool myOptimizeDataFlag
Definition: DtFileCache.h:79
bool myUnloadImageDataFlag
Definition: DtFileCache.h:77
std::string myOriginalPath
Definition: DtFileCache.h:69
Contains makVrv::DtVirtualBaseClass class.
DtRecordSettingsBackupInterface * mySettingsBackup
Definition: DtFileCache.h:268
The DtDeSharedState represents all the data that is shared between the master and its slaves...
Definition: DtDeSharedState.h:43
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
DtDe & getDe()
Definition: DtFileCache.h:215
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
std::multimap< std::string, std::string > customOptionStrings
Definition: DtFileCache.h:65
DtRecordSettingsBackupInterface * settingsBackup()
Definition: DtFileCache.h:210
Definition: DtFileCache.h:60
int myOptimizeFileLevel
Definition: DtFileCache.h:80
Record for the settings associated with the VRV caching.
Definition: DtCacheSettingsRecord.h:17
bool myInstanceNodesFlag
Definition: DtFileCache.h:73
bool myClearInstancesOnNewSceneFlag
Definition: DtFileCache.h:260
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:200
DtSignalConnectionManager myConnectionManager
Definition: DtFileCache.h:264
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:176
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
const DtRecordSettingsBackupInterface * settingsBackup() const
Definition: DtFileCache.h:205
The makVrv::DtRecordSettingsBackupInterface provides an interface to record-based backups...
Definition: DtRecordSettingsBackup.h:24
bool myFlushTextures
Definition: DtFileCache.h:44
FilePathList myDatabasePaths
Definition: DtFileCache.h:62
Handles the caching of files.
Definition: DtFileCache.h:52
unsigned int myFlushCycleCount
Definition: DtFileCache.h:262
boost::signalslib::signal< void()> signal_clearInstanceCache
Signal emmitted when clearCache is called, used to allow other caches to be cleared.
Definition: DtFileCache.h:222
Contains DLL export macros.

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)