973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
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> |
23 | |
24 | //======================================================================= |
25 | //function : MDataStd_RelationStorageDriver |
26 | //purpose : |
27 | //======================================================================= |
28 | |
29 | MDataStd_RelationStorageDriver::MDataStd_RelationStorageDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ASDriver(theMsgDriver) |
30 | { |
31 | } |
32 | |
33 | //======================================================================= |
34 | //function : VersionNumber |
35 | //purpose : |
36 | //======================================================================= |
37 | |
38 | Standard_Integer MDataStd_RelationStorageDriver::VersionNumber() const |
39 | { return 0; } |
40 | |
41 | //======================================================================= |
42 | //function : SourceType |
43 | //purpose : |
44 | //======================================================================= |
45 | |
46 | Handle(Standard_Type) MDataStd_RelationStorageDriver::SourceType() const |
47 | { return STANDARD_TYPE(TDataStd_Relation);} |
48 | |
49 | //======================================================================= |
50 | //function : NewEmpty |
51 | //purpose : |
52 | //======================================================================= |
53 | |
54 | Handle(PDF_Attribute) MDataStd_RelationStorageDriver::NewEmpty() const |
55 | { return new PDataStd_Relation; } |
56 | |
57 | //======================================================================= |
58 | //function : Paste |
59 | //purpose : |
60 | //======================================================================= |
61 | |
62 | void MDataStd_RelationStorageDriver::Paste(const Handle(TDF_Attribute)& Source,const Handle(PDF_Attribute)& Target,const Handle(MDF_SRelocationTable)& RelocTable) const |
63 | { |
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; |
70 | |
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()) { |
77 | index++; |
78 | TV = it.Value(); |
79 | if(!RelocTable->HasRelocation (TV, PV)) { |
80 | Standard_NoSuchObject::Raise("MDataStd_ExpressionStorageDriver::Paste"); |
81 | } |
82 | PVARS->SetValue (index,PV); |
83 | } |
84 | T->SetVariables (PVARS); |
85 | } |
86 | |