0024157: Parallelization of assembly part of BO
[occt.git] / src / RWStepBasic / RWStepBasic_RWPerson.cxx
1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
2 //
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
7 //
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10 //
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
17
18
19 #include <RWStepBasic_RWPerson.ixx>
20 #include <Interface_HArray1OfHAsciiString.hxx>
21
22
23 RWStepBasic_RWPerson::RWStepBasic_RWPerson () {}
24
25 void RWStepBasic_RWPerson::ReadStep
26         (const Handle(StepData_StepReaderData)& data,
27          const Standard_Integer num,
28          Handle(Interface_Check)& ach,
29          const Handle(StepBasic_Person)& ent) const
30 {
31
32
33         // --- Number of Parameter Control ---
34
35         if (!data->CheckNbParams(num,6,ach,"person")) return;
36
37         // --- own field : id ---
38
39         Handle(TCollection_HAsciiString) aId;
40         //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
41         data->ReadString (num,1,"id",ach,aId);
42
43         // --- own field : lastName ---
44
45         Handle(TCollection_HAsciiString) aLastName;
46         Standard_Boolean hasAlastName = Standard_True;
47         if (data->IsParamDefined(num,2)) {
48           //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
49           data->ReadString (num,2,"last_name",ach,aLastName);
50         }
51         else {
52           hasAlastName = Standard_False;
53           aLastName.Nullify();
54         }
55
56         // --- own field : firstName ---
57
58         Handle(TCollection_HAsciiString) aFirstName;
59         Standard_Boolean hasAfirstName = Standard_True;
60         if (data->IsParamDefined(num,3)) {
61           //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
62           data->ReadString (num,3,"first_name",ach,aFirstName);
63         }
64         else {
65           hasAfirstName = Standard_False;
66           aFirstName.Nullify();
67         }
68
69         // --- own field : middleNames ---
70
71         Handle(Interface_HArray1OfHAsciiString) aMiddleNames;
72         Standard_Boolean hasAmiddleNames = Standard_True;
73         if (data->IsParamDefined(num,4)) {
74           Handle(TCollection_HAsciiString) aMiddleNamesItem;
75           Standard_Integer nsub4;
76           if (data->ReadSubList (num,4,"middle_names",ach,nsub4)) {
77             Standard_Integer nb4 = data->NbParams(nsub4);
78             aMiddleNames = new Interface_HArray1OfHAsciiString (1, nb4);
79             for (Standard_Integer i4 = 1; i4 <= nb4; i4 ++) {
80               //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed
81               if (data->ReadString (nsub4,i4,"middle_names",ach,aMiddleNamesItem))
82                 aMiddleNames->SetValue(i4,aMiddleNamesItem);
83             }
84           }
85         }
86         else {
87           hasAmiddleNames = Standard_False;
88           aMiddleNames.Nullify();
89         }
90
91         // --- own field : prefixTitles ---
92
93         Handle(Interface_HArray1OfHAsciiString) aPrefixTitles;
94         Standard_Boolean hasAprefixTitles = Standard_True;
95         if (data->IsParamDefined(num,5)) {
96           Handle(TCollection_HAsciiString) aPrefixTitlesItem;
97           Standard_Integer nsub5;
98           if (data->ReadSubList (num,5,"prefix_titles",ach,nsub5)) {
99             Standard_Integer nb5 = data->NbParams(nsub5);
100             aPrefixTitles = new Interface_HArray1OfHAsciiString (1, nb5);
101             for (Standard_Integer i5 = 1; i5 <= nb5; i5 ++) {
102               //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed
103               if (data->ReadString (nsub5,i5,"prefix_titles",ach,aPrefixTitlesItem))
104                 aPrefixTitles->SetValue(i5,aPrefixTitlesItem);
105             }
106           }
107         }
108         else {
109           hasAprefixTitles = Standard_False;
110           aPrefixTitles.Nullify();
111         }
112
113         // --- own field : suffixTitles ---
114
115         Handle(Interface_HArray1OfHAsciiString) aSuffixTitles;
116         Standard_Boolean hasAsuffixTitles = Standard_True;
117         if (data->IsParamDefined(num,6)) {
118           Handle(TCollection_HAsciiString) aSuffixTitlesItem;
119           Standard_Integer nsub6;
120           if (data->ReadSubList (num,6,"suffix_titles",ach,nsub6)) {
121             Standard_Integer nb6 = data->NbParams(nsub6);
122             aSuffixTitles = new Interface_HArray1OfHAsciiString (1, nb6);
123             for (Standard_Integer i6 = 1; i6 <= nb6; i6 ++) {
124               //szv#4:S4163:12Mar99 `Standard_Boolean stat6 =` not needed
125               if (data->ReadString (nsub6,i6,"suffix_titles",ach,aSuffixTitlesItem))
126                 aSuffixTitles->SetValue(i6,aSuffixTitlesItem);
127             }
128           }
129         }
130         else {
131           hasAsuffixTitles = Standard_False;
132           aSuffixTitles.Nullify();
133         }
134
135         //--- Initialisation of the read entity ---
136
137
138         ent->Init(aId, hasAlastName, aLastName, hasAfirstName, aFirstName, hasAmiddleNames, aMiddleNames, hasAprefixTitles, aPrefixTitles, hasAsuffixTitles, aSuffixTitles);
139 }
140
141
142 void RWStepBasic_RWPerson::WriteStep
143         (StepData_StepWriter& SW,
144          const Handle(StepBasic_Person)& ent) const
145 {
146
147         // --- own field : id ---
148
149         SW.Send(ent->Id());
150
151         // --- own field : lastName ---
152
153         Standard_Boolean hasAlastName = ent->HasLastName();
154         if (hasAlastName) {
155           SW.Send(ent->LastName());
156         }
157         else {
158           SW.SendUndef();
159         }
160
161         // --- own field : firstName ---
162
163         Standard_Boolean hasAfirstName = ent->HasFirstName();
164         if (hasAfirstName) {
165           SW.Send(ent->FirstName());
166         }
167         else {
168           SW.SendUndef();
169         }
170
171         // --- own field : middleNames ---
172
173         Standard_Boolean hasAmiddleNames = ent->HasMiddleNames();
174         if (hasAmiddleNames) {
175           SW.OpenSub();
176           for (Standard_Integer i4 = 1;  i4 <= ent->NbMiddleNames();  i4 ++) {
177             SW.Send(ent->MiddleNamesValue(i4));
178           }
179           SW.CloseSub();
180         }
181         else {
182           SW.SendUndef();
183         }
184
185         // --- own field : prefixTitles ---
186
187         Standard_Boolean hasAprefixTitles = ent->HasPrefixTitles();
188         if (hasAprefixTitles) {
189           SW.OpenSub();
190           for (Standard_Integer i5 = 1;  i5 <= ent->NbPrefixTitles();  i5 ++) {
191             SW.Send(ent->PrefixTitlesValue(i5));
192           }
193           SW.CloseSub();
194         }
195         else {
196           SW.SendUndef();
197         }
198
199         // --- own field : suffixTitles ---
200
201         Standard_Boolean hasAsuffixTitles = ent->HasSuffixTitles();
202         if (hasAsuffixTitles) {
203           SW.OpenSub();
204           for (Standard_Integer i6 = 1;  i6 <= ent->NbSuffixTitles();  i6 ++) {
205             SW.Send(ent->SuffixTitlesValue(i6));
206           }
207           SW.CloseSub();
208         }
209         else {
210           SW.SendUndef();
211         }
212 }