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_ExpressionStorageDriver.ixx> |
15 | #include <PDataStd_Expression.hxx> |
16 | #include <TDataStd_Expression.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_ExpressionStorageDriver |
26 | //purpose : |
27 | //======================================================================= |
28 | |
29 | MDataStd_ExpressionStorageDriver::MDataStd_ExpressionStorageDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ASDriver(theMsgDriver) |
30 | { |
31 | } |
32 | |
33 | //======================================================================= |
34 | //function : VersionNumber |
35 | //purpose : |
36 | //======================================================================= |
37 | |
38 | Standard_Integer MDataStd_ExpressionStorageDriver::VersionNumber() const |
39 | { return 0; } |
40 | |
41 | //======================================================================= |
42 | //function : SourceType |
43 | //purpose : |
44 | //======================================================================= |
45 | |
46 | Handle(Standard_Type) MDataStd_ExpressionStorageDriver::SourceType() const |
47 | { return STANDARD_TYPE(TDataStd_Expression);} |
48 | |
49 | //======================================================================= |
50 | //function : NewEmpty |
51 | //purpose : |
52 | //======================================================================= |
53 | |
54 | Handle(PDF_Attribute) MDataStd_ExpressionStorageDriver::NewEmpty() const |
55 | { return new PDataStd_Expression; } |
56 | |
57 | //======================================================================= |
58 | //function : Paste |
59 | //purpose : |
60 | //======================================================================= |
61 | |
62 | void MDataStd_ExpressionStorageDriver::Paste(const Handle(TDF_Attribute)& Source, |
63 | const Handle(PDF_Attribute)& Target, |
64 | const Handle(MDF_SRelocationTable)& RelocTable) const |
65 | { |
66 | Handle(TDataStd_Expression) S = Handle(TDataStd_Expression)::DownCast (Source); |
67 | Handle(PDataStd_Expression) T = Handle(PDataStd_Expression)::DownCast (Target); |
68 | Handle(PCollection_HExtendedString) Expression = new PCollection_HExtendedString (S->Name()); |
69 | T->SetName (Expression); |
70 | |
71 | Handle(TDF_Attribute) TV; |
72 | Handle(PDF_Attribute) PV; |
73 | Standard_Integer nbvar = S->GetVariables().Extent(); |
74 | if (nbvar <= 0) return; |
75 | Handle(PDF_HAttributeArray1) PVARS = new PDF_HAttributeArray1 (1, nbvar); |
76 | TDF_ListIteratorOfAttributeList it; |
77 | Standard_Integer index = 0; |
78 | for (it.Initialize(S->GetVariables());it.More();it.Next()) { |
79 | index++; |
80 | TV = it.Value(); |
81 | if(!RelocTable->HasRelocation (TV, PV)) { |
82 | Standard_NoSuchObject::Raise("MDataStd_ExpressionStorageDriver::Paste"); |
83 | } |
84 | PVARS->SetValue (index,PV); |
85 | } |
86 | T->SetVariables (PVARS); |
87 | } |
88 | |