// File: MDataStd_NamedDataRetrievalDriver.cxx // Created: Wed Jun 27 18:37:45 2007 // Author: Sergey ZARITCHNY // // Copyright: Open CASCADE SA 2007 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //======================================================================= //function : MDataStd_NamedDataRetrievalDriver //purpose : //======================================================================= MDataStd_NamedDataRetrievalDriver::MDataStd_NamedDataRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver) { } //======================================================================= //function : VersionNumber //purpose : //======================================================================= Standard_Integer MDataStd_NamedDataRetrievalDriver::VersionNumber() const { return 0; } //======================================================================= //function : SourceType //purpose : //======================================================================= Handle(Standard_Type) MDataStd_NamedDataRetrievalDriver::SourceType() const { static Handle(Standard_Type) sourceType = STANDARD_TYPE(PDataStd_NamedData); return sourceType; } //======================================================================= //function : NewEmpty //purpose : //======================================================================= Handle(TDF_Attribute) MDataStd_NamedDataRetrievalDriver::NewEmpty () const { return new TDataStd_NamedData(); } //======================================================================= //function : Paste //purpose : //======================================================================= void MDataStd_NamedDataRetrievalDriver::Paste(const Handle(PDF_Attribute)& Source, const Handle(TDF_Attribute)& Target, const Handle(MDF_RRelocationTable)& ) const { Handle(PDataStd_NamedData) S = Handle(PDataStd_NamedData)::DownCast (Source); Handle(TDataStd_NamedData) T = Handle(TDataStd_NamedData)::DownCast (Target); if(S.IsNull() || T.IsNull()) return; Standard_Integer i; #ifdef MDTV_DEB cout << "Start: " <LowerI() << " " <UpperI()<<"\t"<LowerR() << " " <UpperR(); cout << "\t"<LowerS() << " " <UpperS()<< "\t"<LowerB() << " " <UpperB(); cout << "\t"<LowerAI() << " " <UpperAI()<<"\t"<LowerAR() << " " <UpperAR()<HasIntegers()) { TColStd_DataMapOfStringInteger aMap; for(i=S->LowerI();i<=S->UpperI();i++) { Handle(PCollection_HExtendedString) aPKey; Standard_Integer aValue = S->IntDataItemValue(i, aPKey); const TCollection_ExtendedString& aKey = aPKey->Convert(); aMap.Bind(aKey, aValue); } T->ChangeIntegers(aMap); } if(S->HasReals()) { TDataStd_DataMapOfStringReal aMap; for(i=S->LowerR();i<=S->UpperR();i++) { Handle(PCollection_HExtendedString) aPKey; Standard_Real aValue = S->RealDataItemValue(i, aPKey); const TCollection_ExtendedString& aKey = aPKey->Convert(); aMap.Bind(aKey, aValue); } T->ChangeReals(aMap); } if(S->HasStrings()) { TDataStd_DataMapOfStringString aMap; for(i=S->LowerS();i<=S->UpperS();i++) { Handle(PCollection_HExtendedString) aPKey; const Handle(PCollection_HExtendedString)& aPValue = S->StrDataItemValue(i, aPKey); const TCollection_ExtendedString& aKey = aPKey->Convert(); const TCollection_ExtendedString& aValue = aPValue->Convert(); aMap.Bind(aKey, aValue); } T->ChangeStrings(aMap); } if(S->HasBytes()) { TDataStd_DataMapOfStringByte aMap; for(i=S->LowerB();i<=S->UpperB();i++) { Handle(PCollection_HExtendedString) aPKey; Standard_Byte aValue = S->ByteDataItemValue(i, aPKey); const TCollection_ExtendedString& aKey = aPKey->Convert(); aMap.Bind(aKey, aValue); } T->ChangeBytes(aMap); } if(S->HasArraysOfIntegers()) { TDataStd_DataMapOfStringHArray1OfInteger aMap; for(i=S->LowerAI();i<=S->UpperAI();i++) { Handle(PCollection_HExtendedString) aPKey; Handle(PColStd_HArray1OfInteger) aPValue = S->ArrIntDataItemValue(i, aPKey); const TCollection_ExtendedString& aKey = aPKey->Convert(); Handle(TColStd_HArray1OfInteger) anAr; if (aPValue.IsNull()) continue; Standard_Integer lower = aPValue->Lower(), upper = aPValue->Upper(); anAr = new TColStd_HArray1OfInteger(lower, upper); for (Standard_Integer j = lower; j <= upper; j++) anAr->SetValue(j, aPValue->Value(j)); aMap.Bind(aKey, anAr); } T->ChangeArraysOfIntegers(aMap); } if(S->HasArraysOfReals()) { TDataStd_DataMapOfStringHArray1OfReal aMap; for(i=S->LowerAR();i<=S->UpperAR();i++) { Handle(PCollection_HExtendedString) aPKey; Handle(PColStd_HArray1OfReal) aPValue = S->ArrRealDataItemValue(i, aPKey); const TCollection_ExtendedString& aKey = aPKey->Convert(); Handle(TColStd_HArray1OfReal) anAr; if (aPValue.IsNull()) continue; Standard_Integer lower = aPValue->Lower(), upper = aPValue->Upper(); anAr = new TColStd_HArray1OfReal(lower, upper); for (Standard_Integer j = lower; j <= upper; j++) anAr->SetValue(j, aPValue->Value(j)); aMap.Bind(aKey, anAr); } T->ChangeArraysOfReals(aMap); } }