0022627: Change OCCT memory management defaults
[occt.git] / src / RWStepBasic / RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource.cxx
1
2 #include <RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource.ixx>
3 #include <StepBasic_Source.hxx>
4 #include <StepBasic_Product.hxx>
5
6
7 #include <Interface_EntityIterator.hxx>
8
9
10 #include <StepBasic_ProductDefinitionFormationWithSpecifiedSource.hxx>
11
12 #include <TCollection_AsciiString.hxx>
13
14
15         // --- Enum : Source ---
16 static TCollection_AsciiString sBought(".BOUGHT.");
17 static TCollection_AsciiString sNotKnown(".NOT_KNOWN.");
18 static TCollection_AsciiString sMade(".MADE.");
19
20 RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource () {}
21
22 void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::ReadStep
23         (const Handle(StepData_StepReaderData)& data,
24          const Standard_Integer num,
25          Handle(Interface_Check)& ach,
26          const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent) const
27 {
28
29
30         // --- Number of Parameter Control ---
31
32         if (!data->CheckNbParams(num,4,ach,"product_definition_formation_with_specified_source")) return;
33
34         // --- inherited field : id ---
35
36         Handle(TCollection_HAsciiString) aId;
37         //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
38         data->ReadString (num,1,"id",ach,aId);
39
40         // --- inherited field : description ---
41
42         Handle(TCollection_HAsciiString) aDescription;
43         //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
44         data->ReadString (num,2,"description",ach,aDescription);
45
46         // --- inherited field : ofProduct ---
47
48         Handle(StepBasic_Product) aOfProduct;
49         //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
50         data->ReadEntity(num, 3,"of_product", ach, STANDARD_TYPE(StepBasic_Product), aOfProduct);
51
52         // --- own field : makeOrBuy ---
53
54         StepBasic_Source aMakeOrBuy = StepBasic_sNotKnown;
55         if (data->ParamType(num,4) == Interface_ParamEnum) {
56           Standard_CString text = data->ParamCValue(num,4);
57           if      (sBought.IsEqual(text)) aMakeOrBuy = StepBasic_sBought;
58           else if (sNotKnown.IsEqual(text)) aMakeOrBuy = StepBasic_sNotKnown;
59           else if (sMade.IsEqual(text)) aMakeOrBuy = StepBasic_sMade;
60           else ach->AddFail("Enumeration source has not an allowed value");
61         }
62         else ach->AddFail("Parameter #4 (make_or_buy) is not an enumeration");
63
64         //--- Initialisation of the read entity ---
65
66
67         ent->Init(aId, aDescription, aOfProduct, aMakeOrBuy);
68 }
69
70
71 void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::WriteStep
72         (StepData_StepWriter& SW,
73          const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent) const
74 {
75
76         // --- inherited field id ---
77
78         SW.Send(ent->Id());
79
80         // --- inherited field description ---
81
82         SW.Send(ent->Description());
83
84         // --- inherited field ofProduct ---
85
86         SW.Send(ent->OfProduct());
87
88         // --- own field : makeOrBuy ---
89
90         switch(ent->MakeOrBuy()) {
91           case StepBasic_sBought : SW.SendEnum (sBought); break;
92           case StepBasic_sNotKnown : SW.SendEnum (sNotKnown); break;
93           case StepBasic_sMade : SW.SendEnum (sMade); break;
94         }
95 }
96
97
98 void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::Share(const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent, Interface_EntityIterator& iter) const
99 {
100
101         iter.GetOneItem(ent->OfProduct());
102 }
103