AssetDatabase.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include <Poco/MD5Engine.h>
  23. #include <Atomic/IO/Log.h>
  24. #include <Atomic/IO/File.h>
  25. #include <Atomic/IO/FileSystem.h>
  26. #include <Atomic/Math/Random.h>
  27. #include <Atomic/Resource/ResourceEvents.h>
  28. #include <Atomic/Resource/ResourceCache.h>
  29. #include "../Import/ImportConfig.h"
  30. #include "../ToolEvents.h"
  31. #include "../ToolSystem.h"
  32. #include "../Project/Project.h"
  33. #include "../Project/ProjectEvents.h"
  34. #include "AssetEvents.h"
  35. #include "AssetDatabase.h"
  36. namespace ToolCore
  37. {
  38. AssetDatabase::AssetDatabase(Context* context) : Object(context),
  39. assetScanDepth_(0),
  40. assetScanImport_(false),
  41. cacheEnabled_(true)
  42. {
  43. SubscribeToEvent(E_LOADFAILED, ATOMIC_HANDLER(AssetDatabase, HandleResourceLoadFailed));
  44. SubscribeToEvent(E_PROJECTLOADED, ATOMIC_HANDLER(AssetDatabase, HandleProjectLoaded));
  45. SubscribeToEvent(E_PROJECTUNLOADED, ATOMIC_HANDLER(AssetDatabase, HandleProjectUnloaded));
  46. }
  47. AssetDatabase::~AssetDatabase()
  48. {
  49. }
  50. String AssetDatabase::GetCachePath()
  51. {
  52. if (project_.Null())
  53. return String::EMPTY;
  54. return project_->GetProjectPath() + "Cache/";
  55. }
  56. String AssetDatabase::GenerateAssetGUID()
  57. {
  58. Time* time = GetSubsystem<Time>();
  59. while (true)
  60. {
  61. Poco::MD5Engine md5;
  62. PODVector<unsigned> data;
  63. for (unsigned i = 0; i < 16; i++)
  64. {
  65. data.Push(time->GetTimeSinceEpoch() + Rand());
  66. }
  67. md5.update(&data[0], data.Size() * sizeof(unsigned));
  68. String guid = Poco::MD5Engine::digestToHex(md5.digest()).c_str();
  69. if (!usedGUID_.Contains(guid))
  70. {
  71. RegisterGUID(guid);
  72. return guid;
  73. }
  74. }
  75. assert(0);
  76. return "";
  77. }
  78. void AssetDatabase::RegisterGUID(const String& guid)
  79. {
  80. if (usedGUID_.Contains(guid))
  81. {
  82. assert(0);
  83. }
  84. usedGUID_.Push(guid);
  85. }
  86. void AssetDatabase::ReadImportConfig()
  87. {
  88. ImportConfig::Clear();
  89. ToolSystem* tsystem = GetSubsystem<ToolSystem>();
  90. Project* project = tsystem->GetProject();
  91. String projectPath = project->GetProjectPath();
  92. String filename = projectPath + "Settings/Import.json";
  93. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  94. if (!fileSystem->FileExists(filename))
  95. return;
  96. ImportConfig::LoadFromFile(context_, filename);
  97. }
  98. void AssetDatabase::Import(const String& path)
  99. {
  100. FileSystem* fs = GetSubsystem<FileSystem>();
  101. // nothing for now
  102. if (fs->DirExists(path))
  103. return;
  104. }
  105. Asset* AssetDatabase::GetAssetByCachePath(const String& cachePath)
  106. {
  107. List<SharedPtr<Asset>>::ConstIterator itr = assets_.Begin();
  108. // This is the GUID
  109. String cacheFilename = GetFileName(cachePath).ToLower();
  110. while (itr != assets_.End())
  111. {
  112. if ((*itr)->GetGUID().ToLower() == cacheFilename)
  113. return *itr;
  114. itr++;
  115. }
  116. return 0;
  117. }
  118. Asset* AssetDatabase::GetAssetByGUID(const String& guid)
  119. {
  120. List<SharedPtr<Asset>>::ConstIterator itr = assets_.Begin();
  121. while (itr != assets_.End())
  122. {
  123. if (guid == (*itr)->GetGUID())
  124. return *itr;
  125. itr++;
  126. }
  127. return 0;
  128. }
  129. Asset* AssetDatabase::GetAssetByPath(const String& path)
  130. {
  131. List<SharedPtr<Asset>>::ConstIterator itr = assets_.Begin();
  132. while (itr != assets_.End())
  133. {
  134. if (path == (*itr)->GetPath())
  135. return *itr;
  136. itr++;
  137. }
  138. return 0;
  139. }
  140. void AssetDatabase::PruneOrphanedDotAssetFiles()
  141. {
  142. if (project_.Null())
  143. {
  144. ATOMIC_LOGDEBUG("AssetDatabase::PruneOrphanedDotAssetFiles - called without project loaded");
  145. return;
  146. }
  147. FileSystem* fs = GetSubsystem<FileSystem>();
  148. const String& resourcePath = project_->GetResourcePath();
  149. Vector<String> allResults;
  150. fs->ScanDir(allResults, resourcePath, "*.asset", SCAN_FILES, true);
  151. for (unsigned i = 0; i < allResults.Size(); i++)
  152. {
  153. String dotAssetFilename = resourcePath + allResults[i];
  154. String assetFilename = ReplaceExtension(dotAssetFilename, "");
  155. // remove orphaned asset files
  156. if (!fs->FileExists(assetFilename) && !fs->DirExists(assetFilename))
  157. {
  158. ATOMIC_LOGINFOF("Removing orphaned asset file: %s", dotAssetFilename.CString());
  159. fs->Delete(dotAssetFilename);
  160. }
  161. }
  162. }
  163. String AssetDatabase::GetDotAssetFilename(const String& path)
  164. {
  165. FileSystem* fs = GetSubsystem<FileSystem>();
  166. String assetFilename = path + ".asset";
  167. if (fs->DirExists(path)) {
  168. assetFilename = RemoveTrailingSlash(path) + ".asset";
  169. }
  170. return assetFilename;
  171. }
  172. void AssetDatabase::AddAsset(SharedPtr<Asset>& asset, bool newAsset)
  173. {
  174. assert(asset->GetGUID().Length());
  175. assert(!GetAssetByGUID(asset->GetGUID()));
  176. assets_.Push(asset);
  177. // set to the current timestamp
  178. asset->UpdateFileTimestamp();
  179. VariantMap eventData;
  180. if (newAsset)
  181. {
  182. eventData[AssetNew::P_GUID] = asset->GetGUID();
  183. SendEvent(E_ASSETNEW, eventData);
  184. }
  185. eventData[ResourceAdded::P_GUID] = asset->GetGUID();
  186. SendEvent(E_RESOURCEADDED, eventData);
  187. }
  188. void AssetDatabase::DeleteAsset(Asset* asset)
  189. {
  190. SharedPtr<Asset> assetPtr(asset);
  191. List<SharedPtr<Asset>>::Iterator itr = assets_.Find(assetPtr);
  192. if (itr == assets_.End())
  193. return;
  194. assets_.Erase(itr);
  195. const String& resourcePath = asset->GetPath();
  196. FileSystem* fs = GetSubsystem<FileSystem>();
  197. if (fs->DirExists(resourcePath))
  198. {
  199. fs->RemoveDir(resourcePath, true);
  200. }
  201. else if (fs->FileExists(resourcePath))
  202. {
  203. fs->Delete(resourcePath);
  204. }
  205. String dotAsset = resourcePath + ".asset";
  206. if (fs->FileExists(dotAsset))
  207. {
  208. fs->Delete(dotAsset);
  209. }
  210. VariantMap eventData;
  211. eventData[ResourceRemoved::P_GUID] = asset->GetGUID();
  212. SendEvent(E_RESOURCEREMOVED, eventData);
  213. }
  214. bool AssetDatabase::ImportDirtyAssets()
  215. {
  216. PODVector<Asset*> assets;
  217. GetDirtyAssets(assets);
  218. for (unsigned i = 0; i < assets.Size(); i++)
  219. {
  220. assetScanImport_ = true;
  221. assets[i]->Import();
  222. assets[i]->Save();
  223. assets[i]->dirty_ = false;
  224. assets[i]->UpdateFileTimestamp();
  225. }
  226. return assets.Size() != 0;
  227. }
  228. void AssetDatabase::PreloadAssets()
  229. {
  230. List<SharedPtr<Asset>>::ConstIterator itr = assets_.Begin();
  231. while (itr != assets_.End())
  232. {
  233. (*itr)->Preload();
  234. itr++;
  235. }
  236. }
  237. void AssetDatabase::UpdateAssetCacheMap()
  238. {
  239. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  240. if (project_.Null())
  241. return;
  242. bool gen = assetScanImport_;
  243. assetScanImport_ = false;
  244. String cachepath = project_->GetProjectPath() + "Cache/__atomic_ResourceCacheMap.json";
  245. if (!gen && !fileSystem->FileExists(cachepath))
  246. gen = true;
  247. if (!gen)
  248. return;
  249. List<SharedPtr<Asset>>::ConstIterator itr = assets_.Begin();
  250. HashMap<String, String> assetMap;
  251. JSONValue jAssetMap;
  252. while (itr != assets_.End())
  253. {
  254. assetMap.Clear();
  255. (*itr)->GetAssetCacheMap(assetMap);
  256. HashMap<String, String>::ConstIterator amitr = assetMap.Begin();
  257. while (amitr != assetMap.End())
  258. {
  259. jAssetMap.Set(amitr->first_, amitr->second_);
  260. amitr++;
  261. }
  262. itr++;
  263. }
  264. SharedPtr<File> file(new File(context_, cachepath, FILE_WRITE));
  265. if (!file->IsOpen())
  266. {
  267. ATOMIC_LOGERRORF("Unable to update ResourceCacheMap: %s", cachepath.CString());
  268. return;
  269. }
  270. SharedPtr<JSONFile> jsonFile(new JSONFile(context_));
  271. jsonFile->GetRoot().Set("assetMap", jAssetMap);
  272. jsonFile->Save(*file);
  273. }
  274. void AssetDatabase::Scan()
  275. {
  276. if (!assetScanDepth_)
  277. {
  278. assert(!assetScanImport_);
  279. SendEvent(E_ASSETSCANBEGIN);
  280. }
  281. assetScanDepth_++;
  282. PruneOrphanedDotAssetFiles();
  283. FileSystem* fs = GetSubsystem<FileSystem>();
  284. const String& resourcePath = project_->GetResourcePath();
  285. Vector<String> allResults;
  286. fs->ScanDir(allResults, resourcePath, "", SCAN_FILES | SCAN_DIRS, true);
  287. Vector<String> filteredResults;
  288. filteredResults.Push(RemoveTrailingSlash(resourcePath));
  289. for (unsigned i = 0; i < allResults.Size(); i++)
  290. {
  291. allResults[i] = resourcePath + allResults[i];
  292. const String& path = allResults[i];
  293. if (path.StartsWith(".") || path.EndsWith("."))
  294. continue;
  295. String ext = GetExtension(path);
  296. if (ext == ".asset")
  297. continue;
  298. filteredResults.Push(path);
  299. }
  300. for (unsigned i = 0; i < filteredResults.Size(); i++)
  301. {
  302. const String& path = filteredResults[i];
  303. String dotAssetFilename = GetDotAssetFilename(path);
  304. if (!fs->FileExists(dotAssetFilename))
  305. {
  306. // new asset
  307. SharedPtr<Asset> asset(new Asset(context_));
  308. if (asset->SetPath(path))
  309. {
  310. AddAsset(asset, true);
  311. }
  312. }
  313. else
  314. {
  315. SharedPtr<File> file(new File(context_, dotAssetFilename));
  316. SharedPtr<JSONFile> json(new JSONFile(context_));
  317. json->Load(*file);
  318. file->Close();
  319. JSONValue& root = json->GetRoot();
  320. assert(root.Get("version").GetInt() == ASSET_VERSION);
  321. String guid = root.Get("guid").GetString();
  322. if (!GetAssetByGUID(guid))
  323. {
  324. SharedPtr<Asset> asset(new Asset(context_));
  325. asset->SetPath(path);
  326. AddAsset(asset);
  327. }
  328. }
  329. }
  330. PreloadAssets();
  331. if (ImportDirtyAssets())
  332. Scan();
  333. assetScanDepth_--;
  334. if (!assetScanDepth_)
  335. {
  336. UpdateAssetCacheMap();
  337. SendEvent(E_ASSETSCANEND);
  338. }
  339. }
  340. void AssetDatabase::GetFolderAssets(String folder, PODVector<Asset*>& assets) const
  341. {
  342. if (project_.Null())
  343. return;
  344. List<SharedPtr<Asset>>::ConstIterator itr = assets_.Begin();
  345. if (!folder.Length())
  346. {
  347. folder = project_->GetResourcePath();
  348. }
  349. folder = AddTrailingSlash(folder);
  350. while (itr != assets_.End())
  351. {
  352. String path = GetPath((*itr)->GetPath());
  353. if (path == folder)
  354. assets.Push(*itr);
  355. itr++;
  356. }
  357. }
  358. void AssetDatabase::GetAssetsByImporterType(StringHash type, const String &resourceType, PODVector<Asset*>& assets) const
  359. {
  360. assets.Clear();
  361. List<SharedPtr<Asset>>::ConstIterator itr = assets_.Begin();
  362. while (itr != assets_.End())
  363. {
  364. Asset* asset = *itr;
  365. if (asset->GetImporterType() == type)
  366. assets.Push(asset);
  367. itr++;
  368. }
  369. }
  370. void AssetDatabase::GetDirtyAssets(PODVector<Asset*>& assets)
  371. {
  372. assets.Clear();
  373. List<SharedPtr<Asset>>::ConstIterator itr = assets_.Begin();
  374. while (itr != assets_.End())
  375. {
  376. if ((*itr)->IsDirty())
  377. assets.Push(*itr);
  378. itr++;
  379. }
  380. }
  381. void AssetDatabase::HandleProjectLoaded(StringHash eventType, VariantMap& eventData)
  382. {
  383. project_ = GetSubsystem<ToolSystem>()->GetProject();
  384. ReadImportConfig();
  385. if (cacheEnabled_)
  386. {
  387. InitCache();
  388. }
  389. SubscribeToEvent(E_FILECHANGED, ATOMIC_HANDLER(AssetDatabase, HandleFileChanged));
  390. }
  391. void AssetDatabase::HandleProjectUnloaded(StringHash eventType, VariantMap& eventData)
  392. {
  393. ResourceCache* cache = GetSubsystem<ResourceCache>();
  394. cache->RemoveResourceDir(GetCachePath());
  395. assets_.Clear();
  396. usedGUID_.Clear();
  397. assetImportErrorTimes_.Clear();
  398. project_ = 0;
  399. UnsubscribeFromEvent(E_FILECHANGED);
  400. }
  401. void AssetDatabase::HandleResourceLoadFailed(StringHash eventType, VariantMap& eventData)
  402. {
  403. if (project_.Null())
  404. return;
  405. String path = eventData[LoadFailed::P_RESOURCENAME].GetString();
  406. Asset* asset = GetAssetByPath(path);
  407. if (!asset)
  408. asset = GetAssetByPath(project_->GetResourcePath() + path);
  409. if (!asset)
  410. return;
  411. Time* time = GetSubsystem<Time>();
  412. unsigned ctime = time->GetSystemTime();
  413. // if less than 5 seconds since last report, stifle report
  414. if (assetImportErrorTimes_.Contains(asset->guid_))
  415. if (ctime - assetImportErrorTimes_[asset->guid_] < 5000)
  416. return;
  417. assetImportErrorTimes_[asset->guid_] = ctime;
  418. VariantMap evData;
  419. evData[AssetImportError::P_PATH] = asset->path_;
  420. evData[AssetImportError::P_GUID] = asset->guid_;
  421. evData[AssetImportError::P_ERROR] = ToString("Asset %s Failed to Load", asset->path_.CString());
  422. SendEvent(E_ASSETIMPORTERROR, evData);
  423. }
  424. void AssetDatabase::HandleFileChanged(StringHash eventType, VariantMap& eventData)
  425. {
  426. using namespace FileChanged;
  427. const String& fullPath = eventData[P_FILENAME].GetString();
  428. FileSystem* fs = GetSubsystem<FileSystem>();
  429. String pathName, fileName, ext;
  430. SplitPath(fullPath, pathName, fileName, ext);
  431. // ignore changes in the Cache resource dir
  432. if (fullPath == GetCachePath() || pathName.StartsWith(GetCachePath()))
  433. return;
  434. // don't care about directories and asset file changes
  435. if (fs->DirExists(fullPath) || ext == ".asset")
  436. return;
  437. Asset* asset = GetAssetByPath(fullPath);
  438. if (!asset && fs->FileExists(fullPath))
  439. {
  440. Scan();
  441. return;
  442. }
  443. if (asset)
  444. {
  445. if(!fs->Exists(fullPath))
  446. {
  447. DeleteAsset(asset);
  448. }
  449. else
  450. {
  451. if (asset->GetFileTimestamp() != fs->GetLastModifiedTime(asset->GetPath()))
  452. {
  453. asset->SetDirty(true);
  454. Scan();
  455. }
  456. }
  457. }
  458. }
  459. String AssetDatabase::GetResourceImporterName(const String& resourceTypeName)
  460. {
  461. // TODO: have resource type register themselves
  462. if (resourceTypeToImporterType_.Empty())
  463. {
  464. resourceTypeToImporterType_["Sound"] = "AudioImporter";
  465. resourceTypeToImporterType_["Model"] = "ModelImporter";
  466. resourceTypeToImporterType_["Material"] = "MaterialImporter";
  467. resourceTypeToImporterType_["Texture2D"] = "TextureImporter";
  468. resourceTypeToImporterType_["Sprite2D"] = "TextureImporter";
  469. resourceTypeToImporterType_["Image"] = "TextureImporter";
  470. resourceTypeToImporterType_["AnimatedSprite2D"] = "SpriterImporter";
  471. resourceTypeToImporterType_["JSComponentFile"] = "JavascriptImporter";
  472. resourceTypeToImporterType_["JSONFile"] = "JSONImporter";
  473. resourceTypeToImporterType_["ParticleEffect2D"] = "PEXImporter";
  474. resourceTypeToImporterType_["ParticleEffect"] = "ParticleEffectImporter";
  475. resourceTypeToImporterType_["Animation"] = "ModelImporter";
  476. resourceTypeToImporterType_["CSComponentAssembly"] = "NETAssemblyImporter";
  477. resourceTypeToImporterType_["TmxFile2D"] = "TMXImporter";
  478. }
  479. if (!resourceTypeToImporterType_.Contains(resourceTypeName))
  480. return String::EMPTY;
  481. return resourceTypeToImporterType_[resourceTypeName];
  482. }
  483. void AssetDatabase::ReimportAllAssets()
  484. {
  485. List<SharedPtr<Asset>>::ConstIterator itr = assets_.Begin();
  486. while (itr != assets_.End())
  487. {
  488. (*itr)->SetDirty(true);
  489. itr++;
  490. }
  491. Scan();
  492. }
  493. void AssetDatabase::ReimportAllAssetsInDirectory(const String& directoryPath)
  494. {
  495. List<SharedPtr<Asset>>::ConstIterator itr = assets_.Begin();
  496. while (itr != assets_.End())
  497. {
  498. if ((*itr)->GetPath().StartsWith(directoryPath))
  499. {
  500. (*itr)->SetDirty(true);
  501. }
  502. itr++;
  503. }
  504. Scan();
  505. }
  506. bool AssetDatabase::InitCache()
  507. {
  508. FileSystem* fs = GetSubsystem<FileSystem>();
  509. if (!fs->DirExists(GetCachePath()))
  510. fs->CreateDir(GetCachePath());
  511. ResourceCache* cache = GetSubsystem<ResourceCache>();
  512. cache->AddResourceDir(GetCachePath());
  513. Scan();
  514. return true;
  515. }
  516. bool AssetDatabase::CleanCache()
  517. {
  518. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  519. String cachePath = GetCachePath();
  520. if (fileSystem->DirExists(cachePath))
  521. {
  522. ATOMIC_LOGINFOF("Cleaning cache directory %s", cachePath.CString());
  523. fileSystem->RemoveDir(cachePath, true);
  524. if (fileSystem->DirExists(cachePath))
  525. {
  526. ATOMIC_LOGERRORF("Unable to remove cache directory %s", cachePath.CString());
  527. return false;
  528. }
  529. }
  530. fileSystem->CreateDir(cachePath);
  531. if (!fileSystem->DirExists(cachePath))
  532. {
  533. ATOMIC_LOGERRORF("Unable to create cache directory %s", cachePath.CString());
  534. return false;
  535. }
  536. return true;
  537. }
  538. bool AssetDatabase::GenerateCache(bool clean)
  539. {
  540. ATOMIC_LOGINFO("Generating cache... hold on");
  541. if (clean)
  542. {
  543. if (!CleanCache())
  544. return false;
  545. }
  546. else
  547. {
  548. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  549. String cachePath = GetCachePath();
  550. if (!fileSystem->DirExists(cachePath))
  551. {
  552. fileSystem->CreateDir(cachePath);
  553. }
  554. }
  555. ReimportAllAssets();
  556. ATOMIC_LOGINFO("Cache generated");
  557. return true;
  558. }
  559. void AssetDatabase::SetCacheEnabled(bool cacheEnabled)
  560. {
  561. cacheEnabled_ = cacheEnabled;
  562. }
  563. }