VR-Forces 5.0.3 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) 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 
37  {
38  public:
39 
41  typedef boost::unordered_set<std::string> ExcludedExtensions;
42  typedef std::deque<std::string> FilePathList;
43 
45  {
47  unsigned int myCacheHint;
48 
49  std::multimap<std::string,std::string> customOptionStrings;
50  std::multimap<std::string, void*> customPluginData;
51 
52  std::string myCacheDir;
53  std::string myOriginalPath;
56 
62 
67  };
68 
71  friend class DtFileCacheCreator;
72 
74  friend class DtDeSharedState;
75 
77  virtual ~DtFileCache();
78 
80  virtual void init();
81 
84  virtual void initSingletonDependencies();
85 
87  LoadFileOptions defaultOptions() const;
88 
91  virtual bool getCachedNodeFile(const std::string& filePathIn,
92  const FilePathList& paths, std::string& cachedFilePathOut,
93  bool emitError );
94 
97  virtual bool getCachedImageFile(const std::string& filePathIn,
98  const FilePathList& paths, std::string& cachedFilePathOut,
99  bool emitError);
100 
102  virtual void setCachingEnabled(bool flag);
103 
105  virtual bool acceleratedCachingEnabled() const;
106 
111  virtual void setCompressTextures(bool compress);
112 
114  virtual bool compressTexturesEnabled() const;
115 
117  virtual void releaseResources();
118 
120  virtual void clearAccelerationCache();
121 
123  virtual void setInstancingEnabled(bool enabled);
124 
126  virtual bool instancingEnabled() const;
127 
129  bool clearInstancesOnNewScene() const;
130 
132  void setClearInstancesOnNewScene(bool clearInstances);
133 
135  void clearInstancingCache();
136 
142  void flushInstanceCache(bool multipass,bool flushNodes,
143  bool flushTextures, bool flushImages);
144 
147  unsigned int flushCycleCount();
148 
150  virtual void ts_clearInstancingCache();
151 
153  virtual void setFromRecord(const makArchives::DtCacheSettingsRecord& rec);
154 
156  virtual void getRecord(makArchives::DtCacheSettingsRecord& rec);
157 
160  virtual void getSplitRecord(std::vector<makArchives::DtCacheSettingsRecord>& rec,
161  std::vector<std::string>& fileNames) {};
162 
166  makArchives::DtCacheSettingsRecord& combinedRec) {};
167 
169  void loadDefaults(bool loadOnlyFactorySettings = false);
170 
172  void saveAsDefaults();
173 
175  void exportSettings(const std::string& fileName);
176 
178  void importSettings(const std::string& fileName);
179 
181  virtual ExcludedExtensions& excludedExtensions();
182 
184  inline bool isExcludedExtension(const std::string& ext) const
185  {
186  return ts_isExcludedExtension(ext);
187  }
188 
190  {
191  return mySettingsBackup;
192  }
193 
195  {
196  return mySettingsBackup;
197  }
198 
200  {
201  return myDe;
202  }
203 
206  boost::signalslib::signal<void ()> signal_clearInstanceCache;
207 
209  virtual void ts_flushInstancingCache(bool multiPass,
210  bool flushNodes, bool flushTextures, bool flushImages);
211 
212  protected:
213 
215  virtual void autoSaveDefaultsIfNeeded();
216 
218  virtual bool ts_isExcludedExtension(const std::string& ext) const;
219 
222  virtual void addExcludedExtension(const std::string &ext);
223 
226  virtual void removeExcludedExtension(const std::string &ext);
227 
231  DtFileCache(DtDe& de);
232 
235  virtual bool save(const std::string& origFilename,
236  const std::string& cachedFilename, bool optimize);
237 
238 
239  protected:
240 
246  unsigned int myFlushCycleCount;
247 
249 
251 
253  };
254 
258  {
259 
260  public:
261 
264  static DtFileCacheCreator& instance(DtDe& theIG);
265 
267  static void registerInstance(DtDe& de, DtFileCacheCreator* instance);
268 
270  virtual DtFileCache* create(DtDe& de);
271 
272  };
273 
274 }
DtDe & myDe
Definition: DtFileCache.h:241
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
unsigned int myCacheHint
Definition: DtFileCache.h:47
std::deque< std::string > FilePathList
Definition: DtFileCache.h:42
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:65
bool myCachingEnabled
Definition: DtFileCache.h:242
bool myUseMemoryImageCacheFlag
Definition: DtFileCache.h:58
boost::unordered_set< std::string > ExcludedExtensions
A set of extensions excluded from the cache.
Definition: DtFileCache.h:41
std::string myCacheDir
Definition: DtFileCache.h:52
bool myInstancingEnabled
Definition: DtFileCache.h:245
bool myCompressTexturesFlag
Definition: DtFileCache.h:60
bool myInstanceTexturesFlag
Definition: DtFileCache.h:59
std::multimap< std::string, void * > customPluginData
Definition: DtFileCache.h:50
bool myUseAccelerationCacheFlag
Definition: DtFileCache.h:55
The abstract creator for the abstract DtFileCache class.
Definition: DtFileCache.h:257
ExcludedExtensions myExcludedExtensionMap
Definition: DtFileCache.h:250
bool myCompressTextureFlag
Definition: DtFileCache.h:243
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:165
bool myHasNoOptions
Definition: DtFileCache.h:54
bool myCDBSource
Definition: DtFileCache.h:66
bool myOptimizeDataFlag
Definition: DtFileCache.h:63
bool myUnloadImageDataFlag
Definition: DtFileCache.h:61
std::string myOriginalPath
Definition: DtFileCache.h:53
Contains makVrv::DtVirtualBaseClass class.
DtRecordSettingsBackupInterface * mySettingsBackup
Definition: DtFileCache.h:252
The DtDeSharedState represents all the data that is shared between the master and its slaves...
Definition: DtDeSharedState.h:44
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
DtDe & getDe()
Definition: DtFileCache.h:199
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
std::multimap< std::string, std::string > customOptionStrings
Definition: DtFileCache.h:49
DtRecordSettingsBackupInterface * settingsBackup()
Definition: DtFileCache.h:194
Definition: DtFileCache.h:44
int myOptimizeFileLevel
Definition: DtFileCache.h:64
Record for the settings associated with the VRV caching.
Definition: DtCacheSettingsRecord.h:17
bool myInstanceNodesFlag
Definition: DtFileCache.h:57
bool myClearInstancesOnNewSceneFlag
Definition: DtFileCache.h:244
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:184
DtSignalConnectionManager myConnectionManager
Definition: DtFileCache.h:248
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:160
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:70
const DtRecordSettingsBackupInterface * settingsBackup() const
Definition: DtFileCache.h:189
The makVrv::DtRecordSettingsBackupInterface provides an interface to record-based backups...
Definition: DtRecordSettingsBackup.h:24
FilePathList myDatabasePaths
Definition: DtFileCache.h:46
Handles the caching of files. Includes functions for excluding files with certain extensions from bei...
Definition: DtFileCache.h:36
unsigned int myFlushCycleCount
Definition: DtFileCache.h:246
boost::signalslib::signal< void()> signal_clearInstanceCache
Signal emmitted when clearCache is called, used to allow other caches to be cleared.
Definition: DtFileCache.h:206
Contains DLL export macros.

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)