本文整理汇总了C++中ArchivePtr::inheritSharedInfoFrom方法的典型用法代码示例。如果您正苦于以下问题:C++ ArchivePtr::inheritSharedInfoFrom方法的具体用法?C++ ArchivePtr::inheritSharedInfoFrom怎么用?C++ ArchivePtr::inheritSharedInfoFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArchivePtr
的用法示例。
在下文中一共展示了ArchivePtr::inheritSharedInfoFrom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: storeIter
ArchivePtr ItemTreeArchiver::storeIter(ArchivePtr& parentArchive, Item* item)
{
string pluginName;
string className;
if(!ItemManager::getClassIdentifier(item, pluginName, className)) {
messageView->putln(format(_("\"%1%\" cannot be stored. Its type is not registered.")) % item->name());
return 0;
}
ArchivePtr archive = new Archive();
archive->inheritSharedInfoFrom(parentArchive);
messageView->putln(format(_("Storing %1% \"%2%\"")) % className % item->name());
messageView->flush();
ArchivePtr dataArchive = new Archive();
dataArchive->inheritSharedInfoFrom(parentArchive);
if(!item->store(*dataArchive)) {
messageView->putln(format(_("\"%1%\" cannot be stored.")) % item->name());
return 0;
}
archive->registerItemId(item, itemIdCounter);
archive->write("id", itemIdCounter);
itemIdCounter++;
archive->write("name", item->name(), YAML_DOUBLE_QUOTED);
archive->write("plugin", pluginName);
archive->write("class", className);
if(!dataArchive->empty()) {
archive->insert("data", dataArchive);
}
YamlSequencePtr children = new YamlSequence();
for(Item* childItem = item->childItem(); childItem; childItem = childItem->nextItem()) {
if(childItem->isSubItem()) {
continue;
}
ArchivePtr childArchive = storeIter(archive, childItem);
if(childArchive) {
children->append(childArchive);
}
}
if(!children->empty()) {
archive->insert("children", children);
}
return archive;
}
示例2: storeAllViewAreaLayouts
void ViewArea::storeAllViewAreaLayouts(ArchivePtr archive)
{
ListingPtr layouts = new Listing();
for(size_t i=0; i < viewAreas.size(); ++i){
ArchivePtr layout = new Archive();
layout->inheritSharedInfoFrom(*archive);
viewAreas[i]->storeLayout(layout);
layouts->append(layout);
}
if(!layouts->empty()){
archive->insert("viewAreas", layouts);
}
}
示例3: restoreViews
void ViewManager::restoreViews(ArchivePtr archive, const std::string& key, ViewManager::ViewStateInfo& out_viewStateInfo)
{
MessageView* mv = MessageView::instance();
typedef map<ViewInfo*, vector<View*> > ViewsMap;
ViewsMap remainingViewsMap;
Listing* viewList = archive->findListing(key);
if(viewList->isValid() && !viewList->empty()){
vector<ViewState>* viewsToRestoreState = new vector<ViewState>();
out_viewStateInfo.data = viewsToRestoreState;
int id;
string moduleName;
string className;
string instanceName;
for(int i=0; i < viewList->size(); ++i){
Archive* viewArchive = dynamic_cast<Archive*>(viewList->at(i)->toMapping());
if(viewArchive){
bool isHeaderValid =
viewArchive->read("id", id) &&
viewArchive->read("plugin", moduleName) &&
viewArchive->read("class", className);
if(isHeaderValid){
View* view = 0;
if(!viewArchive->read("name", instanceName)){
view = getOrCreateView(moduleName, className);
} else {
// get one of the view instances having the instance name, or create a new instance.
// Different instances are assigned even if there are instances with the same name in the archive
ViewInfo* info = findViewInfo(moduleName, className);
if(info){
vector<View*>* remainingViews;
ViewsMap::iterator p = remainingViewsMap.find(info);
if(p != remainingViewsMap.end()){
remainingViews = &p->second;
} else {
remainingViews = &remainingViewsMap[info];
InstanceInfoList& instances = info->instances;
remainingViews->reserve(instances.size());
InstanceInfoList::iterator q = instances.begin();
if(info->hasDefaultInstance() && q != instances.end()){
++q;
}
while(q != instances.end()){
remainingViews->push_back((*q++)->view);
}
}
for(vector<View*>::iterator q = remainingViews->begin(); q != remainingViews->end(); ++q){
if((*q)->name() == instanceName){
view = *q;
remainingViews->erase(q);
break;
}
}
if(!view){
if(!info->isSingleton() || info->instances.empty()){
view = info->createView(instanceName, true);
} else {
mv->putln(MessageView::ERROR,
boost::format(_("A singleton view \"%1%\" of the %2% type cannot be created because its singleton instance has already been created."))
% instanceName % info->className());
}
}
}
}
if(view){
archive->registerViewId(view, id);
ArchivePtr state = viewArchive->findSubArchive("state");
if(state->isValid()){
state->inheritSharedInfoFrom(*archive);
viewsToRestoreState->push_back(ViewState(view, state));
}
if(viewArchive->get("mounted", false)){
mainWindow->viewArea()->addView(view);
}
}
}
}
}
}
}