1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include <MDataStd_RelationRetrievalDriver.ixx>
19 #include <PDataStd_Relation.hxx>
20 #include <TDataStd_Relation.hxx>
21 #include <TCollection_ExtendedString.hxx>
22 #include <PCollection_HExtendedString.hxx>
23 #include <TDF_ListIteratorOfAttributeList.hxx>
24 #include <PDF_HAttributeArray1.hxx>
25 #include <Standard_NoSuchObject.hxx>
26 #include <CDM_MessageDriver.hxx>
29 //=======================================================================
30 //function : MDataStd_RelationRetrievalDriver
32 //=======================================================================
34 MDataStd_RelationRetrievalDriver::MDataStd_RelationRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
38 //=======================================================================
39 //function : VersionNumber
41 //=======================================================================
43 Standard_Integer MDataStd_RelationRetrievalDriver::VersionNumber() const
46 //=======================================================================
47 //function : SourceType
49 //=======================================================================
51 Handle(Standard_Type) MDataStd_RelationRetrievalDriver::SourceType() const
53 return STANDARD_TYPE(PDataStd_Relation);
56 //=======================================================================
59 //=======================================================================
61 Handle(TDF_Attribute) MDataStd_RelationRetrievalDriver::NewEmpty() const
63 return new TDataStd_Relation ();
66 //=======================================================================
69 //=======================================================================
71 void MDataStd_RelationRetrievalDriver::Paste(const Handle(PDF_Attribute)& Source,
72 const Handle(TDF_Attribute)& Target,
73 const Handle(MDF_RRelocationTable)& RelocTable) const
75 Handle(PDataStd_Relation) S = Handle(PDataStd_Relation)::DownCast (Source);
76 Handle(TDataStd_Relation) T = Handle(TDataStd_Relation)::DownCast (Target);
77 TCollection_ExtendedString Relation = (S->GetName())->Convert ();
78 T->SetRelation (Relation);
80 Handle(PDF_Attribute) PV;
81 Handle(TDF_Attribute) TV;
83 Handle(PDF_HAttributeArray1) PVARS = S->GetVariables ();
84 if (PVARS.IsNull()) return;
85 for (Standard_Integer i = 1; i <= PVARS->Length (); i++) {
86 PV = PVARS->Value (i);
88 if (!RelocTable->HasRelocation (PV, TV)) {
89 Standard_NoSuchObject::Raise("MDataStd_ConstraintRetrievalDriver::Paste");
91 T->GetVariables().Append(TV);