973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
7fd59977 |
13 | |
14 | #include <RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource.ixx> |
15 | #include <StepBasic_Source.hxx> |
16 | #include <StepBasic_Product.hxx> |
17 | |
18 | |
19 | #include <Interface_EntityIterator.hxx> |
20 | |
21 | |
22 | #include <StepBasic_ProductDefinitionFormationWithSpecifiedSource.hxx> |
23 | |
24 | #include <TCollection_AsciiString.hxx> |
25 | |
26 | |
b311480e |
27 | // --- Enum : Source --- |
7fd59977 |
28 | static TCollection_AsciiString sBought(".BOUGHT."); |
29 | static TCollection_AsciiString sNotKnown(".NOT_KNOWN."); |
30 | static TCollection_AsciiString sMade(".MADE."); |
31 | |
32 | RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource () {} |
33 | |
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 |
39 | { |
40 | |
41 | |
42 | // --- Number of Parameter Control --- |
43 | |
44 | if (!data->CheckNbParams(num,4,ach,"product_definition_formation_with_specified_source")) return; |
45 | |
46 | // --- inherited field : id --- |
47 | |
48 | Handle(TCollection_HAsciiString) aId; |
49 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
50 | data->ReadString (num,1,"id",ach,aId); |
51 | |
52 | // --- inherited field : description --- |
53 | |
54 | Handle(TCollection_HAsciiString) aDescription; |
55 | //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed |
56 | data->ReadString (num,2,"description",ach,aDescription); |
57 | |
58 | // --- inherited field : ofProduct --- |
59 | |
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); |
63 | |
64 | // --- own field : makeOrBuy --- |
65 | |
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"); |
73 | } |
74 | else ach->AddFail("Parameter #4 (make_or_buy) is not an enumeration"); |
75 | |
76 | //--- Initialisation of the read entity --- |
77 | |
78 | |
79 | ent->Init(aId, aDescription, aOfProduct, aMakeOrBuy); |
80 | } |
81 | |
82 | |
83 | void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::WriteStep |
84 | (StepData_StepWriter& SW, |
85 | const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent) const |
86 | { |
87 | |
88 | // --- inherited field id --- |
89 | |
90 | SW.Send(ent->Id()); |
91 | |
92 | // --- inherited field description --- |
93 | |
94 | SW.Send(ent->Description()); |
95 | |
96 | // --- inherited field ofProduct --- |
97 | |
98 | SW.Send(ent->OfProduct()); |
99 | |
100 | // --- own field : makeOrBuy --- |
101 | |
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; |
106 | } |
107 | } |
108 | |
109 | |
110 | void RWStepBasic_RWProductDefinitionFormationWithSpecifiedSource::Share(const Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)& ent, Interface_EntityIterator& iter) const |
111 | { |
112 | |
113 | iter.GetOneItem(ent->OfProduct()); |
114 | } |
115 | |