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 <RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource.ixx>
15 #include <StepBasic_Source.hxx>
16 #include <StepBasic_Product.hxx>
19 #include <Interface_EntityIterator.hxx>
22 #include <StepBasic_ProductDefinitionFormationWithSpecifiedSource.hxx>
24 #include <TCollection_AsciiString.hxx>
27 // --- Enum : Source ---
28 static TCollection_AsciiString sBought(".BOUGHT.");
29 static TCollection_AsciiString sNotKnown(".NOT_KNOWN.");
30 static TCollection_AsciiString sMade(".MADE.");
32 RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource () {}
34 void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::ReadStep
35 (const Handle(StepData_StepReaderData)& data,
36 const Standard_Integer num,
37 Handle(Interface_Check)& ach,
38 const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent) const
42 // --- Number of Parameter Control ---
44 if (!data->CheckNbParams(num,4,ach,"product_definition_formation_with_specified_source")) return;
46 // --- inherited field : id ---
48 Handle(TCollection_HAsciiString) aId;
49 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
50 data->ReadString (num,1,"id",ach,aId);
52 // --- inherited field : description ---
54 Handle(TCollection_HAsciiString) aDescription;
55 //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
56 data->ReadString (num,2,"description",ach,aDescription);
58 // --- inherited field : ofProduct ---
60 Handle(StepBasic_Product) aOfProduct;
61 //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
62 data->ReadEntity(num, 3,"of_product", ach, STANDARD_TYPE(StepBasic_Product), aOfProduct);
64 // --- own field : makeOrBuy ---
66 StepBasic_Source aMakeOrBuy = StepBasic_sNotKnown;
67 if (data->ParamType(num,4) == Interface_ParamEnum) {
68 Standard_CString text = data->ParamCValue(num,4);
69 if (sBought.IsEqual(text)) aMakeOrBuy = StepBasic_sBought;
70 else if (sNotKnown.IsEqual(text)) aMakeOrBuy = StepBasic_sNotKnown;
71 else if (sMade.IsEqual(text)) aMakeOrBuy = StepBasic_sMade;
72 else ach->AddFail("Enumeration source has not an allowed value");
74 else ach->AddFail("Parameter #4 (make_or_buy) is not an enumeration");
76 //--- Initialisation of the read entity ---
79 ent->Init(aId, aDescription, aOfProduct, aMakeOrBuy);
83 void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::WriteStep
84 (StepData_StepWriter& SW,
85 const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent) const
88 // --- inherited field id ---
92 // --- inherited field description ---
94 SW.Send(ent->Description());
96 // --- inherited field ofProduct ---
98 SW.Send(ent->OfProduct());
100 // --- own field : makeOrBuy ---
102 switch(ent->MakeOrBuy()) {
103 case StepBasic_sBought : SW.SendEnum (sBought); break;
104 case StepBasic_sNotKnown : SW.SendEnum (sNotKnown); break;
105 case StepBasic_sMade : SW.SendEnum (sMade); break;
110 void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::Share(const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent, Interface_EntityIterator& iter) const
113 iter.GetOneItem(ent->OfProduct());