void PropertyOwner::deserialize(IvwDeserializer& d) { // This is for finding renamed composites, and moving old properties to new composites. NodeVersionConverter tvc(this, &PropertyOwner::findPropsForComposites); d.convertVersion(&tvc); std::vector<std::string> identifers; for (Property* p : properties_) identifers.push_back(p->getIdentifier()); StandardIdentifier<Property> propertyIdentifier; d.deserialize("Properties", properties_, "Property", propertyIdentifier); for (size_t i = 0; i < properties_.size(); ++i) { Property* p = properties_[i]; auto it = std::find_if(identifers.begin(), identifers.end(), [&p](const std::string& id) -> bool { return id == p->getIdentifier(); }); // Property is created in the de-serialization, assume ownership if (it == identifers.end()) { notifyObserversWillAddProperty(p, i); p->setOwner(this); if (dynamic_cast<EventProperty*>(p)) { eventProperties_.push_back(static_cast<EventProperty*>(p)); } if (dynamic_cast<CompositeProperty*>(p)) { compositeProperties_.push_back(static_cast<CompositeProperty*>(p)); } ownedProperties_.emplace_back(p); notifyObserversDidAddProperty(p, i); } } }
void PropertyOwner::deserialize(Deserializer& d) { // This is for finding renamed composites, and moving old properties to new composites. NodeVersionConverter tvc(this, &PropertyOwner::findPropsForComposites); d.convertVersion(&tvc); std::vector<std::string> ownedIdentifiers; d.deserialize("OwnedPropertyIdentifiers", ownedIdentifiers, "PropertyIdentifier"); auto des = util::IdentifiedDeserializer<std::string, Property*>("Properties", "Property") .setGetId([](Property* const& p) { return p->getIdentifier(); }) .setMakeNew([]() { return nullptr; }) .setNewFilter([&](const std::string& id, size_t ind) { return util::contains(ownedIdentifiers, id); }) .onNew([&](Property*& p) { addProperty(p, true); }) .onRemove([&](const std::string& id) { if (util::contains_if(ownedProperties_, [&](std::unique_ptr<Property>& op) { return op->getIdentifier() == id; })) { delete removeProperty(id); } }); des(d, properties_); }
void LightingRaycaster::deserialize(Deserializer& d) { NodeVersionConverter tvc([](TxElement* node) { TxElement* p = util::xmlGetElement( node, "Properties/Property&type=OptionPropertyString&identifier=shadingMode"); if (p) p->SetAttribute("type", "OptionPropertyInt"); return true; }); d.convertVersion(&tvc); Processor::deserialize(d); }