1 #include <RWHeaderSection_ReadWriteModule.ixx>
2 #include <Interface_ReaderLib.hxx>
3 #include <StepData_WriterLib.hxx>
4 #include <HeaderSection_Protocol.hxx>
5 #include <Interface_Macros.hxx>
6 #include <Interface_ParamType.hxx>
9 #include <HeaderSection_FileName.hxx>
10 #include <HeaderSection_FileDescription.hxx>
11 #include <HeaderSection_FileSchema.hxx>
13 #include <StepData_UndefinedEntity.hxx>
16 #include <RWHeaderSection_RWFileName.hxx>
17 #include <RWHeaderSection_RWFileDescription.hxx>
18 #include <RWHeaderSection_RWFileSchema.hxx>
20 // -- General Declarations (Recognize, StepType) ---
22 static TCollection_AsciiString PasReco(""); // neutralise StartEntity de SW
23 static TCollection_AsciiString Reco_FileName ("FILE_NAME");
24 static TCollection_AsciiString Reco_FileDescription ("FILE_DESCRIPTION");
25 static TCollection_AsciiString Reco_FileSchema ("FILE_SCHEMA");
27 // -- Definition of the libraries --
29 RWHeaderSection_ReadWriteModule::RWHeaderSection_ReadWriteModule ()
31 Handle(HeaderSection_Protocol) protocol = new HeaderSection_Protocol;
32 StepData_WriterLib::SetGlobal(this,protocol);
33 Interface_ReaderLib::SetGlobal(this,protocol);
36 // --- Case Recognition ---
38 Standard_Integer RWHeaderSection_ReadWriteModule::CaseStep
39 (const TCollection_AsciiString& key) const
41 if (key.IsEqual(Reco_FileName)) return 1;
42 if (key.IsEqual(Reco_FileDescription)) return 2;
43 if (key.IsEqual(Reco_FileSchema)) return 3;
47 // --- External Mapping Case Recognition ---
49 Standard_Integer RWHeaderSection_ReadWriteModule::CaseStep
50 (const TColStd_SequenceOfAsciiString& types) const
53 Standard_Integer NbComp = types.Length();
56 cout << "Plex Instance illegal " << endl;
63 // --- External Mapping Recognition ---
65 Standard_Boolean RWHeaderSection_ReadWriteModule::IsComplex
66 (const Standard_Integer CN) const
68 return Standard_False;
73 const TCollection_AsciiString& RWHeaderSection_ReadWriteModule::StepType
74 (const Standard_Integer CN) const
77 case 1 : return Reco_FileName;
78 case 2 : return Reco_FileDescription;
79 case 3 : return Reco_FileSchema;
80 default : return PasReco;
84 // -- Reading of a file --
86 void RWHeaderSection_ReadWriteModule::ReadStep
87 (const Standard_Integer CN,
88 const Handle(StepData_StepReaderData)& data,
89 const Standard_Integer num,
90 Handle(Interface_Check)& ach,
91 const Handle(Standard_Transient)&ent) const
97 DeclareAndCast(HeaderSection_FileName, anent, ent);
98 RWHeaderSection_RWFileName tool;
99 if (anent.IsNull()) ach->AddFail("Type Mismatch on FileName");
100 else tool.ReadStep (data,num,ach,anent);
106 DeclareAndCast(HeaderSection_FileDescription, anent, ent);
107 RWHeaderSection_RWFileDescription tool;
108 if (anent.IsNull()) ach->AddFail("Type Mismatch on FileDescription");
109 else tool.ReadStep (data,num,ach,anent);
115 DeclareAndCast(HeaderSection_FileSchema, anent, ent);
116 RWHeaderSection_RWFileSchema tool;
117 if (anent.IsNull()) ach->AddFail("Type Mismatch on FileSchema");
118 else tool.ReadStep (data,num,ach,anent);
124 DeclareAndCast(StepData_UndefinedEntity,und,ent);
125 if (und.IsNull()) ach->AddFail
126 ("# Entity neither Recognized nor set as UndefinedEntity from StepData #");
127 else und->ReadRecord(data,num,ach);
131 default : ach->AddFail("Type Mismatch when reading - Entity");
136 // -- Writing of a file --
138 void RWHeaderSection_ReadWriteModule::WriteStep
139 (const Standard_Integer CN,
140 StepData_StepWriter& SW,
141 const Handle(Standard_Transient)&ent) const
147 DeclareAndCast(HeaderSection_FileName, anent, ent);
148 RWHeaderSection_RWFileName tool;
149 if (anent.IsNull()) return;
150 else tool.WriteStep (SW,anent);
156 DeclareAndCast(HeaderSection_FileDescription, anent, ent);
157 RWHeaderSection_RWFileDescription tool;
158 if (anent.IsNull()) return;
159 else tool.WriteStep (SW,anent);
165 DeclareAndCast(HeaderSection_FileSchema, anent, ent);
166 RWHeaderSection_RWFileSchema tool;
167 if (anent.IsNull()) return;
168 else tool.WriteStep (SW,anent);
174 DeclareAndCast(StepData_UndefinedEntity,und,ent);
175 if (und.IsNull()) break;
176 // Parentheses gerees par StepWriter lui-meme
177 // car en recevant le type PasReco, StepWriter ne l'affiche pas,
178 // mais il gere les parentheses comme si de rien n etait
179 if (und->IsComplex()) SW.StartComplex();
180 und->WriteParams(SW);
181 if (und->IsComplex()) SW.EndComplex();