0024927: Getting rid of "Persistent" functionality -- Code
[occt.git] / src / MDataStd / MDataStd.cxx
1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //              ------------
17 // modified     Sergey Zaritchny
18
19 // Version:     0.0
20 //Version       Date            Purpose
21 //              0.0     Aug  4 1997     Creation
22
23
24
25 #include <MDataStd.ixx>
26 #include <MDF_ASDriverTable.hxx>
27 #include <MDF_ARDriverTable.hxx>
28 #include <CDM_MessageDriver.hxx>
29 // Storage
30 #include <MDataStd_DirectoryStorageDriver.hxx>
31 #include <MDataStd_UAttributeStorageDriver.hxx>
32 #include <MDataStd_IntegerArrayStorageDriver.hxx>
33 #include <MDataStd_RealArrayStorageDriver.hxx>
34 #include <MDataStd_ExtStringArrayStorageDriver.hxx>
35 #include <MDataStd_NameStorageDriver.hxx>
36 #include <MDataStd_CommentStorageDriver.hxx>
37 #include <MDataStd_IntegerStorageDriver.hxx>
38 #include <MDataStd_RealStorageDriver.hxx>
39 #include <MDataStd_VariableStorageDriver.hxx>
40 #include <MDataStd_ExpressionStorageDriver.hxx>
41 #include <MDataStd_RelationStorageDriver.hxx>
42 #include <MDataStd_NoteBookStorageDriver.hxx>
43 #include <MDataStd_TreeNodeStorageDriver.hxx>
44
45 #include <MDataStd_TickStorageDriver.hxx>
46 #include <MDataStd_IntegerListStorageDriver.hxx>
47 #include <MDataStd_RealListStorageDriver.hxx>
48 #include <MDataStd_ExtStringListStorageDriver.hxx>
49 #include <MDataStd_BooleanListStorageDriver.hxx>
50 #include <MDataStd_ReferenceListStorageDriver.hxx>
51 #include <MDataStd_BooleanArrayStorageDriver.hxx>
52 #include <MDataStd_ReferenceArrayStorageDriver.hxx>
53 #include <MDataStd_ByteArrayStorageDriver.hxx>
54 #include <MDataStd_NamedDataStorageDriver.hxx>
55 #include <MDataStd_AsciiStringStorageDriver.hxx>
56 #include <MDataStd_IntPackedMapStorageDriver.hxx>
57 // Retrieval
58 #include <MDataStd_DirectoryRetrievalDriver.hxx>
59 #include <MDataStd_RealArrayRetrievalDriver.hxx>
60 #include <MDataStd_ExtStringArrayRetrievalDriver.hxx>
61 #include <MDataStd_UAttributeRetrievalDriver.hxx>
62 #include <MDataStd_IntegerArrayRetrievalDriver.hxx>
63 #include <MDataStd_NameRetrievalDriver.hxx>
64 #include <MDataStd_CommentRetrievalDriver.hxx>
65 #include <MDataStd_IntegerRetrievalDriver.hxx>
66 #include <MDataStd_RealRetrievalDriver.hxx>
67 #include <MDataStd_VariableRetrievalDriver.hxx>
68 #include <MDataStd_ExpressionRetrievalDriver.hxx>
69 #include <MDataStd_RelationRetrievalDriver.hxx>
70 #include <MDataStd_NoteBookRetrievalDriver.hxx>
71 #include <MDataStd_TreeNodeRetrievalDriver.hxx>
72
73 #include <MDataStd_TickRetrievalDriver.hxx>
74 #include <MDataStd_IntegerListRetrievalDriver.hxx>
75 #include <MDataStd_RealListRetrievalDriver.hxx>
76 #include <MDataStd_ExtStringListRetrievalDriver.hxx>
77 #include <MDataStd_BooleanListRetrievalDriver.hxx>
78 #include <MDataStd_ReferenceListRetrievalDriver.hxx>
79 #include <MDataStd_BooleanArrayRetrievalDriver.hxx>
80 #include <MDataStd_ReferenceArrayRetrievalDriver.hxx>
81 #include <MDataStd_ByteArrayRetrievalDriver.hxx>
82 #include <MDataStd_NamedDataRetrievalDriver.hxx>
83 #include <MDataStd_AsciiStringRetrievalDriver.hxx>
84 #include <MDataStd_IntPackedMapRetrievalDriver.hxx>
85 #include <MDataStd_ByteArrayRetrievalDriver_1.hxx>
86 #include <MDataStd_IntegerArrayRetrievalDriver_1.hxx>
87 #include <MDataStd_RealArrayRetrievalDriver_1.hxx>
88 #include <MDataStd_ExtStringArrayRetrievalDriver_1.hxx>
89 #include <MDataStd_IntPackedMapRetrievalDriver_1.hxx>
90
91 // enums
92 #include <TDataStd_RealEnum.hxx>
93 #include <Standard_DomainError.hxx>
94
95 //=======================================================================
96 //function : AddStorageDriver
97 //purpose  : 
98 //=======================================================================
99
100 void MDataStd::AddStorageDrivers
101 (const Handle(MDF_ASDriverHSequence)& aDriverSeq, const Handle(CDM_MessageDriver)& theMsgDriver)
102 {
103   aDriverSeq->Append(new MDataStd_DirectoryStorageDriver(theMsgDriver));
104   aDriverSeq->Append(new MDataStd_IntegerArrayStorageDriver(theMsgDriver));
105   aDriverSeq->Append(new MDataStd_RealArrayStorageDriver(theMsgDriver));
106   aDriverSeq->Append(new MDataStd_UAttributeStorageDriver(theMsgDriver)); 
107   aDriverSeq->Append(new MDataStd_NameStorageDriver(theMsgDriver)); 
108   aDriverSeq->Append(new MDataStd_CommentStorageDriver(theMsgDriver));
109   aDriverSeq->Append(new MDataStd_IntegerStorageDriver(theMsgDriver));
110   aDriverSeq->Append(new MDataStd_RealStorageDriver(theMsgDriver));
111
112   aDriverSeq->Append(new MDataStd_VariableStorageDriver(theMsgDriver)); 
113   aDriverSeq->Append(new MDataStd_ExpressionStorageDriver(theMsgDriver)); 
114   aDriverSeq->Append(new MDataStd_RelationStorageDriver(theMsgDriver));  
115   aDriverSeq->Append(new MDataStd_NoteBookStorageDriver(theMsgDriver));  
116   aDriverSeq->Append(new MDataStd_TreeNodeStorageDriver(theMsgDriver));
117   aDriverSeq->Append(new MDataStd_ExtStringArrayStorageDriver(theMsgDriver));
118
119   aDriverSeq->Append(new MDataStd_TickStorageDriver(theMsgDriver));
120   aDriverSeq->Append(new MDataStd_IntegerListStorageDriver(theMsgDriver));
121   aDriverSeq->Append(new MDataStd_RealListStorageDriver(theMsgDriver));
122   aDriverSeq->Append(new MDataStd_ExtStringListStorageDriver(theMsgDriver));
123   aDriverSeq->Append(new MDataStd_BooleanListStorageDriver(theMsgDriver));
124   aDriverSeq->Append(new MDataStd_ReferenceListStorageDriver(theMsgDriver));
125   aDriverSeq->Append(new MDataStd_BooleanArrayStorageDriver(theMsgDriver));
126   aDriverSeq->Append(new MDataStd_ReferenceArrayStorageDriver(theMsgDriver));
127   aDriverSeq->Append(new MDataStd_ByteArrayStorageDriver(theMsgDriver));
128   aDriverSeq->Append(new MDataStd_NamedDataStorageDriver(theMsgDriver));
129   aDriverSeq->Append(new MDataStd_AsciiStringStorageDriver(theMsgDriver));
130   aDriverSeq->Append(new MDataStd_IntPackedMapStorageDriver(theMsgDriver));
131 }
132
133
134 //=======================================================================
135 //function : AddRetrievalDriver
136 //purpose  : 
137 //=======================================================================
138
139 void MDataStd::AddRetrievalDrivers
140 (const Handle(MDF_ARDriverHSequence)& aDriverSeq,const Handle(CDM_MessageDriver)& theMsgDriver)
141 {
142   aDriverSeq->Append(new MDataStd_DirectoryRetrievalDriver(theMsgDriver)); 
143   aDriverSeq->Append(new MDataStd_IntegerArrayRetrievalDriver(theMsgDriver));
144   aDriverSeq->Append(new MDataStd_RealArrayRetrievalDriver(theMsgDriver));
145   aDriverSeq->Append(new MDataStd_UAttributeRetrievalDriver(theMsgDriver)); 
146   aDriverSeq->Append(new MDataStd_NameRetrievalDriver(theMsgDriver)); 
147   aDriverSeq->Append(new MDataStd_CommentRetrievalDriver(theMsgDriver));
148   aDriverSeq->Append(new MDataStd_IntegerRetrievalDriver(theMsgDriver));
149   aDriverSeq->Append(new MDataStd_RealRetrievalDriver(theMsgDriver));
150
151   aDriverSeq->Append(new MDataStd_VariableRetrievalDriver(theMsgDriver));  
152   aDriverSeq->Append(new MDataStd_ExpressionRetrievalDriver(theMsgDriver));  
153   aDriverSeq->Append(new MDataStd_RelationRetrievalDriver(theMsgDriver)); 
154   aDriverSeq->Append(new MDataStd_NoteBookRetrievalDriver(theMsgDriver));  
155   aDriverSeq->Append(new MDataStd_TreeNodeRetrievalDriver(theMsgDriver));
156   aDriverSeq->Append(new MDataStd_ExtStringArrayRetrievalDriver(theMsgDriver));
157
158   aDriverSeq->Append(new MDataStd_TickRetrievalDriver(theMsgDriver));
159   aDriverSeq->Append(new MDataStd_IntegerListRetrievalDriver(theMsgDriver));
160   aDriverSeq->Append(new MDataStd_RealListRetrievalDriver(theMsgDriver));
161   aDriverSeq->Append(new MDataStd_ExtStringListRetrievalDriver(theMsgDriver));
162   aDriverSeq->Append(new MDataStd_BooleanListRetrievalDriver(theMsgDriver));
163   aDriverSeq->Append(new MDataStd_ReferenceListRetrievalDriver(theMsgDriver));
164   aDriverSeq->Append(new MDataStd_BooleanArrayRetrievalDriver(theMsgDriver));
165   aDriverSeq->Append(new MDataStd_ReferenceArrayRetrievalDriver(theMsgDriver));
166   aDriverSeq->Append(new MDataStd_ByteArrayRetrievalDriver(theMsgDriver));
167   aDriverSeq->Append(new MDataStd_NamedDataRetrievalDriver(theMsgDriver));
168   aDriverSeq->Append(new MDataStd_AsciiStringRetrievalDriver(theMsgDriver));
169   aDriverSeq->Append(new MDataStd_IntPackedMapRetrievalDriver(theMsgDriver));
170   aDriverSeq->Append(new MDataStd_ByteArrayRetrievalDriver_1(theMsgDriver));
171   aDriverSeq->Append(new MDataStd_IntegerArrayRetrievalDriver_1(theMsgDriver));
172   aDriverSeq->Append(new MDataStd_RealArrayRetrievalDriver_1(theMsgDriver));
173   aDriverSeq->Append(new MDataStd_ExtStringArrayRetrievalDriver_1(theMsgDriver));
174   aDriverSeq->Append(new MDataStd_IntPackedMapRetrievalDriver_1(theMsgDriver));
175 }
176
177
178 //=======================================================================
179 //function : RealDimensionToInteger
180 //purpose  : 
181 //=======================================================================
182
183 Standard_Integer MDataStd::RealDimensionToInteger(const TDataStd_RealEnum e) 
184 {
185   switch (e) {
186   case TDataStd_SCALAR  : return  0;
187   case TDataStd_LENGTH  : return  1;
188   case TDataStd_ANGULAR : return  2;
189     
190   default:
191     Standard_DomainError::Raise("TDataStd_RealEnum; enum term unknown");
192   }
193   return 0;
194 }
195
196 //=======================================================================
197 //function : IntegerToRealDimension
198 //purpose  : 
199 //=======================================================================
200
201 TDataStd_RealEnum MDataStd::IntegerToRealDimension(const Standard_Integer i) 
202 {
203   switch(i)
204     {
205       // planar constraints
206     case  0 : return TDataStd_SCALAR;
207     case  1 : return TDataStd_LENGTH;
208     case  2 : return TDataStd_ANGULAR;
209       default :
210         Standard_DomainError::Raise("TDataStd_RealEnum; enum term unknown ");
211     }
212   return TDataStd_SCALAR;
213 }