1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <MDataStd_RelationStorageDriver.ixx>
15 #include <PDataStd_Relation.hxx>
16 #include <TDataStd_Relation.hxx>
17 #include <TCollection_ExtendedString.hxx>
18 #include <PCollection_HExtendedString.hxx>
19 #include <TDF_ListIteratorOfAttributeList.hxx>
20 #include <PDF_HAttributeArray1.hxx>
21 #include <Standard_NoSuchObject.hxx>
22 #include <CDM_MessageDriver.hxx>
24 //=======================================================================
25 //function : MDataStd_RelationStorageDriver
27 //=======================================================================
29 MDataStd_RelationStorageDriver::MDataStd_RelationStorageDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ASDriver(theMsgDriver)
33 //=======================================================================
34 //function : VersionNumber
36 //=======================================================================
38 Standard_Integer MDataStd_RelationStorageDriver::VersionNumber() const
41 //=======================================================================
42 //function : SourceType
44 //=======================================================================
46 Handle(Standard_Type) MDataStd_RelationStorageDriver::SourceType() const
47 { return STANDARD_TYPE(TDataStd_Relation);}
49 //=======================================================================
52 //=======================================================================
54 Handle(PDF_Attribute) MDataStd_RelationStorageDriver::NewEmpty() const
55 { return new PDataStd_Relation; }
57 //=======================================================================
60 //=======================================================================
62 void MDataStd_RelationStorageDriver::Paste(const Handle(TDF_Attribute)& Source,const Handle(PDF_Attribute)& Target,const Handle(MDF_SRelocationTable)& RelocTable) const
64 Handle(TDataStd_Relation) S = Handle(TDataStd_Relation)::DownCast (Source);
65 Handle(PDataStd_Relation) T = Handle(PDataStd_Relation)::DownCast (Target);
66 Handle(PCollection_HExtendedString) Relation = new PCollection_HExtendedString (S->Name());
67 T->SetName (Relation);
68 Handle(TDF_Attribute) TV;
69 Handle(PDF_Attribute) PV;
71 Standard_Integer nbvar = S->GetVariables().Extent();
72 if (nbvar <= 0) return;
73 Handle(PDF_HAttributeArray1) PVARS = new PDF_HAttributeArray1 (1, nbvar);
74 TDF_ListIteratorOfAttributeList it;
75 Standard_Integer index = 0;
76 for (it.Initialize(S->GetVariables());it.More();it.Next()) {
79 if(!RelocTable->HasRelocation (TV, PV)) {
80 Standard_NoSuchObject::Raise("MDataStd_ExpressionStorageDriver::Paste");
82 PVARS->SetValue (index,PV);
84 T->SetVariables (PVARS);