MCPcopy Create free account
hub / github.com/Illation/ETEngine / Merge

Method Merge

Engine/source/EtCore/Content/AssetDatabase.cpp:284–363  ·  view source on GitHub ↗

--------------------------------- AssetDatabase::Merge Merge another asset database into this one.

Source from the content-addressed store, hash-verified

282// Merge another asset database into this one.
283//
284void AssetDatabase::Merge(AssetDatabase const& other)
285{
286 // add packages
287 for (PackageDescriptor const& desc : other.packages)
288 {
289 auto packageIt = std::find_if(packages.cbegin(), packages.cend(), [&desc](PackageDescriptor const& lhs)
290 {
291 return lhs.GetId() == desc.GetId();
292 });
293
294 // if the other DB contains a package that this DB doesn't know of, add it
295 if (packageIt == packages.cend())
296 {
297 packages.emplace_back(desc);
298 }
299 else
300 {
301 // if both have the same package, ensure they agree on its details
302 ET_ASSERT(packageIt->GetPath() == desc.GetPath(),
303 "DBs disagree on paths for package '%s'! this: '%s' - other: '%s'",
304 desc.GetName().c_str(),
305 packageIt->GetPath().c_str(),
306 desc.GetPath().c_str());
307 }
308 }
309
310 // add caches
311 for (AssetCache const& rhCache : other.caches)
312 {
313 auto cacheIt = std::find_if(caches.begin(), caches.end(), [&rhCache](AssetCache const& lhCache)
314 {
315 return lhCache.GetType() == rhCache.GetType();
316 });
317
318 if (cacheIt == caches.cend())
319 {
320 caches.emplace_back(rhCache);
321 }
322 else
323 {
324 AssetCache& lhCache = *cacheIt;
325
326 // insert assets
327 for (I_Asset* const rhAsset : rhCache.cache)
328 {
329 // Ensure the asset doesn't already exist
330 auto assetIt = std::find_if(lhCache.cache.cbegin(), lhCache.cache.cend(), [rhAsset](I_Asset const* const lhAsset)
331 {
332 return lhAsset->GetId() == rhAsset->GetId();
333 });
334
335 // if the to merge asset is unique add it
336 if (assetIt == lhCache.cache.cend())
337 {
338 // check we have a package descriptor for the new asset
339 ET_ASSERT(std::find_if(packages.cbegin(), packages.cend(), [rhAsset](PackageDescriptor const& lhPackage)
340 {
341 return lhPackage.GetId() == rhAsset->GetPackageId();

Callers 1

CookCompiledPackageFunction · 0.45

Calls 7

GetPathMethod · 0.80
GetNameMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
ToStringDbgMethod · 0.80
GetIdMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected