0022627: Change OCCT memory management defaults
[occt.git] / src / MDF / MDF.cxx
1 // File:        MDF.cxx
2 //              ---------
3 // Author:      DAUTRY Philippe
4 //              <fid@fox.paris1.matra-dtv.fr>
5 // Copyright:   Matra Datavision 1997
6
7 // Version:     0.0
8 // History:     Version Date            Purpose
9 //              0.0     Mar 13 1997     Creation
10
11
12
13 #include <MDF.ixx>
14
15 #include <TDF_Attribute.hxx>
16 #include <TDF_Label.hxx>
17 #include <TDF_Tool.hxx>
18
19 #include <MDF_RRelocationTable.hxx>
20 #include <MDF_SRelocationTable.hxx>
21 #include <MDF_Tool.hxx>
22 #include <MDF_TypeARDriverMap.hxx>
23 #include <MDF_TypeASDriverMap.hxx>
24
25 #include <PDF_Attribute.hxx>
26 #include <PDF_HAttributeArray1.hxx>
27
28 #include <PColStd_HArray1OfInteger.hxx>
29
30 #include <PTColStd_TransientPersistentMap.hxx>
31
32 #include <MDF_TagSourceStorageDriver.hxx>
33 #include <MDF_TagSourceRetrievalDriver.hxx>
34 #include <MDF_ReferenceStorageDriver.hxx>
35 #include <MDF_ReferenceRetrievalDriver.hxx>
36 #include <CDM_MessageDriver.hxx>
37
38 //=======================================================================
39 //function : FromTo
40 //purpose  : From TRANSIENT to PERSISTENT.
41 //=======================================================================
42
43 void MDF::FromTo
44 (const Handle(TDF_Data)& aSource,
45  Handle(PDF_Data)& aTarget,
46  const Handle(MDF_ASDriverTable)& aDriverTable,
47  const Handle(MDF_SRelocationTable)& aReloc,
48  const Standard_Integer aVersion) 
49 {
50   // Into Data.
51   aTarget = new PDF_Data(aVersion);
52
53   // Extraction of the driver subset.
54   const MDF_TypeASDriverMap& driverMap =
55     aDriverTable->GetDrivers(aVersion);
56
57   // Translation.
58   MDF_Tool::WriteLabels(aSource, aTarget, driverMap, aReloc);
59   MDF_Tool::WriteAttributes(driverMap, aReloc);
60 }
61
62
63 //=======================================================================
64 //function : FromTo
65 //purpose  : From PERSISTENT to TRANSIENT.
66 //=======================================================================
67
68 void MDF::FromTo
69 (const Handle(PDF_Data)& aSource,
70  Handle(TDF_Data)& aTarget,
71  const Handle(MDF_ARDriverTable)& aDriverTable,
72  const Handle(MDF_RRelocationTable)& aReloc) 
73 {
74   // Version number.
75   Standard_Integer version = aSource->VersionNumber();
76
77   // Extraction of the driver subset.
78   const MDF_TypeARDriverMap& driverMap =
79     aDriverTable->GetDrivers(version);
80
81   // Translation.
82   MDF_Tool::ReadLabels(aSource, aTarget, driverMap, aReloc);
83   MDF_Tool::ReadAttributes(driverMap, aReloc);
84 }
85
86 //=======================================================================
87 //function : AddStorageDriver
88 //purpose  : 
89 //=======================================================================
90
91 void MDF::AddStorageDrivers
92 (const Handle(MDF_ASDriverHSequence)& theDriverSeq,const Handle(CDM_MessageDriver)& theMsgDriver)
93 {
94   theDriverSeq->Append(new MDF_TagSourceStorageDriver(theMsgDriver)); 
95   theDriverSeq->Append(new MDF_ReferenceStorageDriver(theMsgDriver));
96 }
97
98
99 //=======================================================================
100 //function : AddRetrievalDriver
101 //purpose  : 
102 //=======================================================================
103
104 void MDF::AddRetrievalDrivers
105 (const Handle(MDF_ARDriverHSequence)& theDriverSeq, const Handle(CDM_MessageDriver)& theMsgDriver)
106 {
107   theDriverSeq->Append(new MDF_TagSourceRetrievalDriver(theMsgDriver)); 
108   theDriverSeq->Append(new MDF_ReferenceRetrievalDriver(theMsgDriver));
109 }
110