1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <Interface_EntityIterator.hxx>
15 #include "RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource.pxx"
16 #include <StepBasic_Product.hxx>
17 #include <StepBasic_ProductDefinitionFormationWithSpecifiedSource.hxx>
18 #include <StepBasic_Source.hxx>
19 #include <StepData_StepReaderData.hxx>
20 #include <StepData_StepWriter.hxx>
21 #include <TCollection_AsciiString.hxx>
23 // --- Enum : Source ---
24 static TCollection_AsciiString sBought(".BOUGHT.");
25 static TCollection_AsciiString sNotKnown(".NOT_KNOWN.");
26 static TCollection_AsciiString sMade(".MADE.");
28 RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::
29 RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource()
33 void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::ReadStep(
34 const Handle(StepData_StepReaderData)& data,
35 const Standard_Integer num,
36 Handle(Interface_Check)& ach,
37 const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent) const
40 // --- Number of Parameter Control ---
42 if (!data->CheckNbParams(num, 4, ach, "product_definition_formation_with_specified_source"))
45 // --- inherited field : id ---
47 Handle(TCollection_HAsciiString) aId;
48 // szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
49 data->ReadString(num, 1, "id", ach, aId);
51 // --- inherited field : description ---
53 Handle(TCollection_HAsciiString) aDescription;
54 // szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
55 data->ReadString(num, 2, "description", ach, aDescription);
57 // --- inherited field : ofProduct ---
59 Handle(StepBasic_Product) aOfProduct;
60 // szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
61 data->ReadEntity(num, 3, "of_product", ach, STANDARD_TYPE(StepBasic_Product), aOfProduct);
63 // --- own field : makeOrBuy ---
65 StepBasic_Source aMakeOrBuy = StepBasic_sNotKnown;
66 if (data->ParamType(num, 4) == Interface_ParamEnum)
68 Standard_CString text = data->ParamCValue(num, 4);
69 if (sBought.IsEqual(text))
70 aMakeOrBuy = StepBasic_sBought;
71 else if (sNotKnown.IsEqual(text))
72 aMakeOrBuy = StepBasic_sNotKnown;
73 else if (sMade.IsEqual(text))
74 aMakeOrBuy = StepBasic_sMade;
76 ach->AddFail("Enumeration source has not an allowed value");
79 ach->AddFail("Parameter #4 (make_or_buy) is not an enumeration");
81 //--- Initialisation of the read entity ---
83 ent->Init(aId, aDescription, aOfProduct, aMakeOrBuy);
86 void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::WriteStep(
87 StepData_StepWriter& SW,
88 const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent) const
91 // --- inherited field id ---
95 // --- inherited field description ---
97 SW.Send(ent->Description());
99 // --- inherited field ofProduct ---
101 SW.Send(ent->OfProduct());
103 // --- own field : makeOrBuy ---
105 switch (ent->MakeOrBuy())
107 case StepBasic_sBought:
108 SW.SendEnum(sBought);
110 case StepBasic_sNotKnown:
111 SW.SendEnum(sNotKnown);
113 case StepBasic_sMade:
119 void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::Share(
120 const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent,
121 Interface_EntityIterator& iter) const
124 iter.GetOneItem(ent->OfProduct());