bool SampleGeoref::deserialize(SessionItemDeserializer& deserializer) { if (deserializer.getBlockSizes().empty() == true) { // The plug-in was serialized before execute() was called return true; } XmlReader reader(NULL, false); DOMElement* pRootElement = deserializer.deserialize(reader, "SampleGeoref"); if (pRootElement) { std::string windowId = A(pRootElement->getAttribute(X("rasterId"))); mpRaster = dynamic_cast<RasterElement*>(Service<SessionManager>()->getSessionItem(windowId)); if (mpRaster != NULL) { mXSize = atoi(A(pRootElement->getAttribute(X("xSize")))); mYSize = atoi(A(pRootElement->getAttribute(X("ySize")))); mXScale = atof(A(pRootElement->getAttribute(X("xScale")))); mYScale = atof(A(pRootElement->getAttribute(X("yScale")))); mExtrapolate = StringUtilities::fromXmlString<bool>( A(pRootElement->getAttribute(X("extrapolationAccurate")))); return true; } } return false; }
bool RangeProfilePlotManager::deserialize(SessionItemDeserializer& deserializer) { XmlReader reader(NULL, false); DOMElement* pRootElement = deserializer.deserialize(reader, "RangeProfilePlotManager"); if (pRootElement) { std::string viewId = A(pRootElement->getAttribute(X("viewId"))); mpView = dynamic_cast<PlotView*>(Service<SessionManager>()->getSessionItem(viewId)); mpPlot = Service<DesktopServices>()->createPlotWidget(getName(), CARTESIAN_PLOT); VERIFY(mpPlot); Serializable* pPlotSer = dynamic_cast<Serializable*>(mpPlot); // The imp side is serializable VERIFY(pPlotSer); if (!pPlotSer->fromXml(findChildNode(pRootElement, "plot"), reader.VERSION)) { return false; } mpView = mpPlot->getPlot(); VERIFY(mpView); Serializable* pPlotViewSer = dynamic_cast<Serializable*>(mpView); // The imp side is serializable VERIFY(pPlotViewSer); if (!pPlotViewSer->fromXml(findChildNode(pRootElement, "plotView"), reader.VERSION)) { return false; } std::list<PlotObject*> objects; mpView->getObjects(POINT_SET, objects); FOR_EACH_DOMNODE(pRootElement, pChild) { if (XMLString::equals(pChild->getNodeName(), X("signature"))) { DOMElement* pChldElmnt = static_cast<DOMElement*>(pChild); std::string sigId = A(pChldElmnt->getAttribute(X("sigId"))); std::string pointSetName = A(pChldElmnt->getAttribute(X("pointSetName"))); Signature* pSignature = static_cast<Signature*>(Service<SessionManager>()->getSessionItem(sigId)); if (pSignature == NULL) { return false; } mSigPointSets[pSignature] = pointSetName; pSignature->attach(SIGNAL_NAME(Subject, Deleted), Slot(this, &RangeProfilePlotManager::signatureDeleted)); pSignature->getDataDescriptor()->attach(SIGNAL_NAME(DataDescriptor, Renamed), Slot(this, &RangeProfilePlotManager::signatureRenamed)); } } deserializer.nextBlock(); return DockWindowShell::deserialize(deserializer); } return false; }
bool DataElementImp::deserialize(SessionItemDeserializer &deserializer) { XmlReader reader(NULL, false); DOMDocument* pDoc = deserializer.deserialize(reader); if (pDoc == NULL) { return false; } DOMElement* pRoot = pDoc->getDocumentElement(); VERIFY(pRoot != NULL); if (pRoot->hasAttribute(X("parentId"))) { DataElement* pParent = dynamic_cast<DataElement*>(Service<SessionManager>()->getSessionItem(A(pRoot->getAttribute(X("parentId"))))); if (pParent == NULL) { return false; } Service<ModelServices>()->setElementParent(dynamic_cast<DataElement*>(this), pParent); } Service<ModelServices>()->setElementName(dynamic_cast<DataElement*>(this), A(pRoot->getAttribute(X("name")))); unsigned int formatVersion = 0; stringstream str(A(pRoot->getAttribute(X("version")))); str >> formatVersion; return SessionItemImp::fromXml(pRoot, formatVersion) && fromXml(pRoot, formatVersion); }
bool GcpGeoreference::deserialize(SessionItemDeserializer &deserializer) { XmlReader::StringStreamAssigner<int> toInt; XmlReader::StringStreamAssigner<unsigned short> toUShort; XmlReader reader(NULL, false); DOMElement* pRootElement = deserializer.deserialize(reader, "GcpGeoreference"); if (pRootElement) { string rasterId = A(pRootElement->getAttribute(X("rasterId"))); mpRaster = dynamic_cast<RasterElement*>(Service<SessionManager>()->getSessionItem(rasterId)); if (mpRaster == NULL) { return false; } mOrder = toInt(A(pRootElement->getAttribute(X("order")))); mReverseOrder = toUShort(A(pRootElement->getAttribute(X("reverseOrder")))); mNumRows = toInt(A(pRootElement->getAttribute(X("numRows")))); mNumColumns = toInt(A(pRootElement->getAttribute(X("numCols")))); readContainerElements(pRootElement, "latCoefficients", mLatCoefficients, COEFFS_FOR_ORDER(MAX_ORDER)); readContainerElements(pRootElement, "lonCoefficients", mLonCoefficients, COEFFS_FOR_ORDER(MAX_ORDER)); readContainerElements(pRootElement, "xCoefficients", mXCoefficients, COEFFS_FOR_ORDER(MAX_ORDER)); readContainerElements(pRootElement, "yCoefficients", mYCoefficients, COEFFS_FOR_ORDER(MAX_ORDER)); return true; } return false; }
bool SampleGeoref::deserialize(SessionItemDeserializer &deserializer) { XmlReader reader(NULL, false); DOMElement* pRootElement = deserializer.deserialize(reader, "SampleGeoref"); if (pRootElement) { std::string windowId = A(pRootElement->getAttribute(X("rasterId"))); mpRaster = dynamic_cast<RasterElement*>(Service<SessionManager>()->getSessionItem(windowId)); if (mpRaster != NULL) { mXSize = atoi(A(pRootElement->getAttribute(X("xSize")))); mYSize = atoi(A(pRootElement->getAttribute(X("ySize")))); mXScale = atof(A(pRootElement->getAttribute(X("xScale")))); mYScale = atof(A(pRootElement->getAttribute(X("yScale")))); mFrames = atof(A(pRootElement->getAttribute(X("frames")))); mExtrapolate = StringUtilities::fromXmlString<bool>( A(pRootElement->getAttribute(X("extrapolationAccurate")))); mCurrentFrame = atoi(A(pRootElement->getAttribute(X("currentFrame")))); mRotate = atoi(A(pRootElement->getAttribute(X("rotate")))); std::string animId = A(pRootElement->getAttribute(X("animationId"))); if (animId.empty() == false) { Animation* pAnim = dynamic_cast<Animation*>(Service<SessionManager>()->getSessionItem(animId)); if (pAnim) { mpAnimation.reset(pAnim); } } return true; } } return false; }
bool ModelServicesImp::deserialize(SessionItemDeserializer& deserializer) { XmlReader reader(NULL, false); DOMElement* pRootElement = deserializer.deserialize(reader, "ModelServices"); if (pRootElement) { mElementTypes.clear(); readContainerElements(pRootElement, "elementTypes", back_inserter(mElementTypes)); return true; } return false; }
bool SpectralLibraryManager::deserialize(SessionItemDeserializer& deserializer) { if (isBatch() == true) { setInteractive(); } bool success = execute(NULL, NULL); if (success) { std::vector<Signature*> signatures; Service<SessionManager> pSessionManager; XmlReader reader(NULL, false); DOMElement* pRootElement = deserializer.deserialize(reader, "SpectralLibraryManager"); for (DOMNode* pChild = pRootElement->getFirstChild(); pChild != NULL; pChild = pChild->getNextSibling()) { DOMElement* pElement = static_cast<DOMElement*>(pChild); if (XMLString::equals(pElement->getNodeName(), X("Signature"))) { std::string signatureId = A(pElement->getAttribute(X("signatureId"))); Signature* pSignature = dynamic_cast<Signature*>(pSessionManager->getSessionItem(signatureId)); if (pSignature != NULL) { signatures.push_back(pSignature); } } } clearLibrary(); addSignatures(signatures); } return success; }