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.
16 #include <BinMDataStd_RelationDriver.ixx>
17 #include <TDataStd_Relation.hxx>
18 #include <TDataStd_Variable.hxx>
19 #include <TDF_ListIteratorOfAttributeList.hxx>
21 //=======================================================================
22 //function : BinMDataStd_RelationDriver
23 //purpose : Constructor
24 //=======================================================================
25 BinMDataStd_RelationDriver::BinMDataStd_RelationDriver
26 (const Handle(CDM_MessageDriver)& theMsgDriver)
27 : BinMDF_ADriver (theMsgDriver, NULL)
30 //=======================================================================
33 //=======================================================================
34 Handle(TDF_Attribute) BinMDataStd_RelationDriver::NewEmpty() const
36 return (new TDataStd_Relation());
39 //=======================================================================
41 //purpose : persistent -> transient (retrieve)
42 //=======================================================================
43 Standard_Boolean BinMDataStd_RelationDriver::Paste
44 (const BinObjMgt_Persistent& theSource,
45 const Handle(TDF_Attribute)& theTarget,
46 BinObjMgt_RRelocationTable& theRelocTable) const
48 Handle(TDataStd_Relation) aC =
49 Handle(TDataStd_Relation)::DownCast(theTarget);
52 Standard_Integer nbvar;
53 if (! (theSource >> nbvar) || nbvar < 0)
54 return Standard_False;
55 TDF_AttributeList& aList = aC->GetVariables();
56 for (; nbvar > 0; nbvar--)
58 Handle(TDF_Attribute) aV;
60 if (! (theSource >> aNb))
61 return Standard_False;
64 if (theRelocTable.IsBound(aNb))
65 aV = Handle(TDataStd_Variable)::DownCast(theRelocTable.Find(aNb));
68 aV = new TDataStd_Variable;
69 theRelocTable.Bind(aNb, aV);
76 TCollection_ExtendedString aString;
77 if (! (theSource >> aString))
78 return Standard_False;
79 aC->SetRelation(aString);
84 //=======================================================================
86 //purpose : transient -> persistent (store)
87 //=======================================================================
88 void BinMDataStd_RelationDriver::Paste
89 (const Handle(TDF_Attribute)& theSource,
90 BinObjMgt_Persistent& theTarget,
91 BinObjMgt_SRelocationTable& theRelocTable) const
93 Handle(TDataStd_Relation) aC =
94 Handle(TDataStd_Relation)::DownCast(theSource);
97 const TDF_AttributeList& aList = aC->GetVariables();
98 Standard_Integer nbvar = aList.Extent();
100 TDF_ListIteratorOfAttributeList it;
101 for (it.Initialize(aList); it.More(); it.Next())
103 const Handle(TDF_Attribute)& TV = it.Value();
104 Standard_Integer aNb;
106 aNb = theRelocTable.Add(TV);
113 TCollection_ExtendedString aName = aC->Name();