本文整理汇总了C++中PackageManager::load方法的典型用法代码示例。如果您正苦于以下问题:C++ PackageManager::load方法的具体用法?C++ PackageManager::load怎么用?C++ PackageManager::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PackageManager
的用法示例。
在下文中一共展示了PackageManager::load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addPackage
PackageManager* Project::addPackage(const char* packagePath)
{
// verify that the package's path is our package directory; if not, copy the
// package file to our packages dir first and change the path
String packagesDir(mPath);
packagesDir += "/packages/";
String baseName;
FileSystem::baseName(baseName, packagePath);
String packageDir;
FileSystem::directoryName(packageDir, packagePath);
if (!FileSystem::isSamePath(packagesDir, packageDir)) {
String fileName;
FileSystem::fileName(fileName, packagePath);
String newPackagePath(packagesDir);
newPackagePath.append("/");
newPackagePath.append(fileName);
if (!FileSystem::copyFile(packagePath, newPackagePath)) {
// then what?
return 0;
}
}
PackageManager* pkgMgr = new PackageManager;
pkgMgr->metadata()->setName(baseName);
DeferredObjectResolves deferred;
ObjectIdToObject lut;
if (!pkgMgr->load(packagesDir, deferred, lut)) {
delete pkgMgr;
return 0;
}
mPackageManagers.push_back(pkgMgr);
// then do Phase 2 load (object reference resolution)
for (DeferredObjectResolves::iterator it = deferred.begin(); it != deferred.end(); ++it) {
DeferredResolution& d = *it;
ObjectIdToObject::iterator o = lut.find(d.mUUID);
if (o != lut.end()) {
d.mProp->setData(d.mObject, o->second);
}
}
std::list<Metadata*> metaList;
pkgMgr->getAllMetadata(metaList);
// load all thumbnails in parallel
tbb::task* dummy = new(tbb::task::allocate_root()) DummyTask;
dummy->set_ref_count(metaList.size() + 1);
for (std::list<Metadata*>::iterator it = metaList.begin(); it != metaList.end(); ++it) {
tbb::task* t = new(dummy->allocate_child()) ThumbnailTask(*it);
dummy->spawn(*t);
}
dummy->wait_for_all();
return pkgMgr;
}
示例2: read
bool Project::read(ProgressFeedback* feedback)
{
String pathname(mPath);
pathname += PATHSEP;
pathname += mName;
pathname += ".project";
TiXmlDocument doc;
doc.LoadFile(pathname);
updateFeedback(feedback);
if (doc.Error()) {
return false;
}
// otherwise, read project file
TiXmlElement* root = doc.RootElement();
// TODO: check version compatibility
const char* nPackageAttr = root->Attribute("package_count");
int nPkg = -1;
if (nPackageAttr)
nPkg = atoi(nPackageAttr);
TiXmlElement* package = root->FirstChildElement("package");
// for deferred object-reference resolution
DeferredObjectResolves deferred;
ObjectIdToObject lut;
// for metadata thumbnail loading
std::list<Metadata*> metaList;
int p = 0;
while (package) {
const char* name = package->Attribute("name");
const char* filename = package->Attribute("filename");
std::string pkgInfoText("Loading Package: ");
updateFeedback(feedback, pkgInfoText.c_str());
if (name && filename) {
pkgInfoText.append(name);
PackageManager* pkgMgr = new PackageManager();
pkgMgr->metadata()->setName(name);
String path(mPath);
path += "/packages/";
pkgMgr->load(path, deferred, lut);
// add package metadata to list to post-process
pkgMgr->getAllMetadata(metaList);
mPackageManagers.push_back(pkgMgr);
updateFeedback(feedback, int(float(++p)/float(nPkg)*100.f), pkgInfoText.c_str());
}
package = package->NextSiblingElement("package");
}
// then do Phase 2 load (object reference resolution)
for (DeferredObjectResolves::iterator it = deferred.begin(); it != deferred.end(); ++it) {
DeferredResolution& d = *it;
ObjectIdToObject::iterator o = lut.find(d.mUUID);
if (o != lut.end()) {
d.mProp->setData(d.mObject, o->second);
}
}
// Phase 3 -- initialize all objects in the project
for (PackageManagers::iterator it = mPackageManagers.begin(); it != mPackageManagers.end(); ++it) {
(*it)->initializeAllObjects();
}
// load all thumbnails in parallel
tbb::task* dummy = new(tbb::task::allocate_root()) DummyTask;
dummy->set_ref_count(metaList.size() + 1);
for (std::list<Metadata*>::iterator it = metaList.begin(); it != metaList.end(); ++it) {
tbb::task* t = new(dummy->allocate_child()) ThumbnailTask(*it);
dummy->spawn(*t);
}
dummy->wait_for_all();
return true;
}