1 // Created on: 2001-09-12
2 // Created by: Julia DOROVSKIKH
3 // Copyright (c) 2001-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <BinMDataStd_RelationDriver.hxx>
18 #include <BinObjMgt_Persistent.hxx>
19 #include <CDM_MessageDriver.hxx>
20 #include <Standard_Type.hxx>
21 #include <TDataStd_Relation.hxx>
22 #include <TDataStd_Variable.hxx>
23 #include <TDF_Attribute.hxx>
24 #include <TDF_ListIteratorOfAttributeList.hxx>
26 IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_RelationDriver,BinMDF_ADriver)
28 //=======================================================================
29 //function : BinMDataStd_RelationDriver
30 //purpose : Constructor
31 //=======================================================================
32 BinMDataStd_RelationDriver::BinMDataStd_RelationDriver
33 (const Handle(CDM_MessageDriver)& theMsgDriver)
34 : BinMDF_ADriver (theMsgDriver, NULL)
37 //=======================================================================
40 //=======================================================================
41 Handle(TDF_Attribute) BinMDataStd_RelationDriver::NewEmpty() const
43 return (new TDataStd_Relation());
46 //=======================================================================
48 //purpose : persistent -> transient (retrieve)
49 //=======================================================================
50 Standard_Boolean BinMDataStd_RelationDriver::Paste
51 (const BinObjMgt_Persistent& theSource,
52 const Handle(TDF_Attribute)& theTarget,
53 BinObjMgt_RRelocationTable& theRelocTable) const
55 Handle(TDataStd_Relation) aC =
56 Handle(TDataStd_Relation)::DownCast(theTarget);
59 Standard_Integer nbvar;
60 if (! (theSource >> nbvar) || nbvar < 0)
61 return Standard_False;
62 TDF_AttributeList& aList = aC->GetVariables();
63 for (; nbvar > 0; nbvar--)
65 Handle(TDF_Attribute) aV;
67 if (! (theSource >> aNb))
68 return Standard_False;
71 if (theRelocTable.IsBound(aNb))
72 aV = Handle(TDataStd_Variable)::DownCast(theRelocTable.Find(aNb));
75 aV = new TDataStd_Variable;
76 theRelocTable.Bind(aNb, aV);
83 TCollection_ExtendedString aString;
84 if (! (theSource >> aString))
85 return Standard_False;
86 aC->SetRelation(aString);
91 //=======================================================================
93 //purpose : transient -> persistent (store)
94 //=======================================================================
95 void BinMDataStd_RelationDriver::Paste
96 (const Handle(TDF_Attribute)& theSource,
97 BinObjMgt_Persistent& theTarget,
98 BinObjMgt_SRelocationTable& theRelocTable) const
100 Handle(TDataStd_Relation) aC =
101 Handle(TDataStd_Relation)::DownCast(theSource);
104 const TDF_AttributeList& aList = aC->GetVariables();
105 Standard_Integer nbvar = aList.Extent();
107 TDF_ListIteratorOfAttributeList it;
108 for (it.Initialize(aList); it.More(); it.Next())
110 const Handle(TDF_Attribute)& TV = it.Value();
111 Standard_Integer aNb;
113 aNb = theRelocTable.Add(TV);
120 TCollection_ExtendedString aName = aC->Name();