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_RelationRetrievalDriver.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>
25 //=======================================================================
26 //function : MDataStd_RelationRetrievalDriver
28 //=======================================================================
30 MDataStd_RelationRetrievalDriver::MDataStd_RelationRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
34 //=======================================================================
35 //function : VersionNumber
37 //=======================================================================
39 Standard_Integer MDataStd_RelationRetrievalDriver::VersionNumber() const
42 //=======================================================================
43 //function : SourceType
45 //=======================================================================
47 Handle(Standard_Type) MDataStd_RelationRetrievalDriver::SourceType() const
49 return STANDARD_TYPE(PDataStd_Relation);
52 //=======================================================================
55 //=======================================================================
57 Handle(TDF_Attribute) MDataStd_RelationRetrievalDriver::NewEmpty() const
59 return new TDataStd_Relation ();
62 //=======================================================================
65 //=======================================================================
67 void MDataStd_RelationRetrievalDriver::Paste(const Handle(PDF_Attribute)& Source,
68 const Handle(TDF_Attribute)& Target,
69 const Handle(MDF_RRelocationTable)& RelocTable) const
71 Handle(PDataStd_Relation) S = Handle(PDataStd_Relation)::DownCast (Source);
72 Handle(TDataStd_Relation) T = Handle(TDataStd_Relation)::DownCast (Target);
73 TCollection_ExtendedString Relation = (S->GetName())->Convert ();
74 T->SetRelation (Relation);
76 Handle(PDF_Attribute) PV;
77 Handle(TDF_Attribute) TV;
79 Handle(PDF_HAttributeArray1) PVARS = S->GetVariables ();
80 if (PVARS.IsNull()) return;
81 for (Standard_Integer i = 1; i <= PVARS->Length (); i++) {
82 PV = PVARS->Value (i);
84 if (!RelocTable->HasRelocation (PV, TV)) {
85 Standard_NoSuchObject::Raise("MDataStd_ConstraintRetrievalDriver::Paste");
87 T->GetVariables().Append(TV);