0024830: Remove redundant keyword 'mutable' in CDL declarations
[occt.git] / src / IFSelect / IFSelect_BasicDumper.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #include <IFSelect_BasicDumper.ixx>
15 #include <IFSelect_IntParam.hxx>
16 #include <IFSelect_WorkSession.hxx>
17 #include <IFSelect_ShareOut.hxx>
18
19 #include <IFSelect_SelectModelRoots.hxx>
20 #include <IFSelect_SelectModelEntities.hxx>
21 #include <IFSelect_SelectEntityNumber.hxx>
22 #include <IFSelect_SelectPointed.hxx>
23 #include <IFSelect_SelectUnion.hxx>
24 #include <IFSelect_SelectIntersection.hxx>
25 #include <IFSelect_SelectDiff.hxx>
26 #include <IFSelect_SelectUnknownEntities.hxx>
27 #include <IFSelect_SelectErrorEntities.hxx>
28 #include <IFSelect_SelectIncorrectEntities.hxx>
29 #include <IFSelect_SelectRoots.hxx>
30 #include <IFSelect_SelectRootComps.hxx>
31 #include <IFSelect_SelectRange.hxx>
32 //#include <IFSelect_SelectTextType.hxx>
33 #include <IFSelect_SelectShared.hxx>
34 #include <IFSelect_SelectSharing.hxx>
35 #include <IFSelect_DispPerOne.hxx>
36 #include <IFSelect_DispGlobal.hxx>
37 #include <IFSelect_DispPerCount.hxx>
38 #include <IFSelect_TransformStandard.hxx>
39
40 #include <Interface_Macros.hxx>
41
42 #define FIRSTCHAR 1
43 // Param litteral "own" sous la forme  :"<val>" -> first = 3
44 // A present, forme simplifiee         : <val>  directement -> first = 1
45
46
47
48 IFSelect_BasicDumper::IFSelect_BasicDumper ()  {  }
49
50     Standard_Boolean  IFSelect_BasicDumper::WriteOwn
51   (IFSelect_SessionFile& file, const Handle(Standard_Transient)& item) const
52 {
53   Handle(Standard_Type) type = item->DynamicType();
54   if (type == STANDARD_TYPE(IFSelect_SelectModelRoots))      return Standard_True;
55   if (type == STANDARD_TYPE(IFSelect_SelectModelEntities))   return Standard_True;
56   if (type == STANDARD_TYPE(IFSelect_SelectEntityNumber)) {
57     DeclareAndCast(IFSelect_SelectEntityNumber,sen,item);
58     file.SendItem(sen->Number());
59     return Standard_True;
60   }
61   if (type == STANDARD_TYPE(IFSelect_SelectPointed))         return Standard_True;
62   if (type == STANDARD_TYPE(IFSelect_SelectUnion))           return Standard_True;
63   if (type == STANDARD_TYPE(IFSelect_SelectIntersection))    return Standard_True;
64   if (type == STANDARD_TYPE(IFSelect_SelectDiff))            return Standard_True;
65   if (type == STANDARD_TYPE(IFSelect_SelectUnknownEntities)) return Standard_True;
66   if (type == STANDARD_TYPE(IFSelect_SelectErrorEntities))   return Standard_True;
67   if (type == STANDARD_TYPE(IFSelect_SelectIncorrectEntities)) return Standard_True;
68   if (type == STANDARD_TYPE(IFSelect_SelectRoots))           return Standard_True;
69   if (type == STANDARD_TYPE(IFSelect_SelectRootComps))       return Standard_True;
70   if (type == STANDARD_TYPE(IFSelect_SelectRange)) {
71     DeclareAndCast(IFSelect_SelectRange,sra,item);
72     file.SendItem(sra->Lower());
73     file.SendItem(sra->Upper());
74     return Standard_True;
75   }
76 /*  if (type == STANDARD_TYPE(IFSelect_SelectTextType)) {
77     DeclareAndCast(IFSelect_SelectTextType,sty,item);
78     if (sty->IsExact()) file.SendText("exact");
79     else                file.SendText("contains");
80     file.SendText(sty->SignatureText().ToCString());
81     return Standard_True;
82   } */
83   if (type == STANDARD_TYPE(IFSelect_SelectShared))          return Standard_True;
84   if (type == STANDARD_TYPE(IFSelect_SelectSharing))         return Standard_True;
85
86   if (type == STANDARD_TYPE(IFSelect_DispPerOne))            return Standard_True;
87   if (type == STANDARD_TYPE(IFSelect_DispGlobal))            return Standard_True;
88   if (type == STANDARD_TYPE(IFSelect_DispPerCount)) {
89     DeclareAndCast(IFSelect_DispPerCount,dpc,item);
90     file.SendItem(dpc->Count());
91     return Standard_True;
92   }
93
94   if (type == STANDARD_TYPE(IFSelect_TransformStandard)) {
95     DeclareAndCast(IFSelect_TransformStandard,trs,item);
96     if (trs->CopyOption()) file.SendText("copy");
97     else                   file.SendText("onthespot");
98     Standard_Integer nbm = trs->NbModifiers();
99     for (Standard_Integer i = 1; i <= nbm; i ++)
100       file.SendItem(trs->Modifier(i));
101   }
102
103   return Standard_False;
104 }
105
106     Standard_Boolean  IFSelect_BasicDumper::ReadOwn
107   (IFSelect_SessionFile& file, const TCollection_AsciiString& type,
108    Handle(Standard_Transient)& item) const
109 {
110   if (type.IsEqual("IFSelect_SelectModelRoots"))
111     {  item = new IFSelect_SelectModelRoots ();     return Standard_True;  }
112   if (type.IsEqual("IFSelect_SelectModelEntities"))
113     {  item = new IFSelect_SelectModelEntities ();  return Standard_True;  }
114   if (type.IsEqual("IFSelect_SelectEntityNumber")) {
115     Handle(IFSelect_SelectEntityNumber) sen =
116       new IFSelect_SelectEntityNumber ();
117     sen->SetNumber (GetCasted(IFSelect_IntParam,file.ItemValue(1)));
118     item = sen;
119     return Standard_True;
120   }
121   if (type.IsEqual("IFSelect_SelectPointed"))
122     {  item = new IFSelect_SelectPointed;  return Standard_True;  }
123   if (type.IsEqual("IFSelect_SelectUnion"))
124     {  item = new IFSelect_SelectUnion;  return Standard_True;  }
125   if (type.IsEqual("IFSelect_SelectIntersection"))
126     {  item = new IFSelect_SelectIntersection;  return Standard_True;  }
127   if (type.IsEqual("IFSelect_SelectDiff"))
128     {  item = new IFSelect_SelectDiff;  return Standard_True;  }
129   if (type.IsEqual("IFSelect_SelectUnknownEntities"))
130     {  item = new IFSelect_SelectUnknownEntities;  return Standard_True;  }
131   if (type.IsEqual("IFSelect_SelectErrorEntities"))
132     {  item = new IFSelect_SelectErrorEntities;  return Standard_True;  }
133   if (type.IsEqual("IFSelect_SelectIncorrectEntities"))
134     {  item = new IFSelect_SelectIncorrectEntities;  return Standard_True;  }
135   if (type.IsEqual("IFSelect_SelectRoots"))
136     {  item = new IFSelect_SelectRoots;  return Standard_True;  }
137   if (type.IsEqual("IFSelect_SelectRootComps"))
138     {  item = new IFSelect_SelectRootComps;  return Standard_True;  }
139   if (type.IsEqual("IFSelect_SelectRange")) {
140     Handle(IFSelect_SelectRange) sra = new IFSelect_SelectRange;
141     sra->SetRange (GetCasted(IFSelect_IntParam,file.ItemValue(1)),
142                    GetCasted(IFSelect_IntParam,file.ItemValue(2)) );
143     item = sra;
144     return Standard_True;
145   }
146   if (type.IsEqual("IFSelect_SelectTextType")) {
147     const TCollection_AsciiString exname = file.ParamValue(1);
148     if (exname.Length() < FIRSTCHAR) return Standard_False;
149     if      (exname.Value(FIRSTCHAR) == 'e') {}
150     else if (exname.Value(FIRSTCHAR) == 'c') {}
151     else  return Standard_False;
152 //    item = new IFSelect_SelectTextType (file.TextValue(2).ToCString(),exact);
153 //    return Standard_True;
154   }
155   if (type.IsEqual("IFSelect_SelectShared"))
156     {  item = new IFSelect_SelectShared;  return Standard_True;  }
157   if (type.IsEqual("IFSelect_SelectSharing"))
158     {  item = new IFSelect_SelectSharing;  return Standard_True;  }
159
160   if (type.IsEqual("IFSelect_DispPerOne"))
161     {  item = new IFSelect_DispPerOne;  return Standard_True;  }
162   if (type.IsEqual("IFSelect_DispGlobal"))
163     {  item = new IFSelect_DispGlobal;  return Standard_True;  }
164   if (type.IsEqual("IFSelect_DispPerCount")) {
165     Handle(IFSelect_DispPerCount) dpc = new IFSelect_DispPerCount;
166     dpc->SetCount (GetCasted(IFSelect_IntParam,file.ItemValue(1)) );
167     item = dpc;
168     return Standard_True;
169   }
170
171   if (type.IsEqual("IFSelect_TransformStandard")) {
172     Standard_Boolean copyoption;
173     const TCollection_AsciiString copyname = file.ParamValue(1);
174     if (copyname.Length() < FIRSTCHAR) return Standard_False;
175     if      (copyname.Value(FIRSTCHAR) == 'c') copyoption = Standard_True;
176     else if (copyname.Value(FIRSTCHAR) == 'o') copyoption = Standard_False;
177     else  return Standard_False;
178     Handle(IFSelect_TransformStandard) trs = new IFSelect_TransformStandard;
179     trs->SetCopyOption(copyoption);
180     Standard_Integer nbp = file.NbParams();
181     for (Standard_Integer i = 2; i <= nbp; i ++) {
182       DeclareAndCast(IFSelect_Modifier,modif,file.ItemValue(i));
183       if (!modif.IsNull()) trs->AddModifier(modif);
184     }
185     item = trs;
186     return Standard_True;
187   }
188
189   return Standard_False;
190 }