0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / APIHeaderSection / APIHeaderSection_EditHeader.cxx
CommitLineData
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.
b311480e 13
7fd59977 14
42cf5bc1 15#include <APIHeaderSection_EditHeader.hxx>
7fd59977 16#include <APIHeaderSection_MakeHeader.hxx>
42cf5bc1 17#include <IFSelect_EditForm.hxx>
18#include <Interface_InterfaceModel.hxx>
19#include <Interface_TypedValue.hxx>
20#include <Standard_Transient.hxx>
21#include <Standard_Type.hxx>
ec357c5c 22#include <StepData_StepModel.hxx>
42cf5bc1 23#include <TCollection_AsciiString.hxx>
24#include <TCollection_HAsciiString.hxx>
7fd59977 25
92efcf78 26IMPLEMENT_STANDARD_RTTIEXT(APIHeaderSection_EditHeader,IFSelect_Editor)
27
7fd59977 28static Standard_Boolean IsTimeStamp
29 (const Handle(TCollection_HAsciiString)& val)
30{
31 if (val.IsNull()) return Standard_False;
32 if (val->Length() != 19) return Standard_False;
33// On y va
34 char dizmois = val->Value(6);
35 char dizjour = val->Value(9);
36 char dizheur = val->Value(12);
37 for (Standard_Integer i = 1; i <= 19; i ++) {
38 char uncar = val->Value(i);
39 switch (i) {
40 case 1 : if (uncar != '1' && uncar != '2') return Standard_False; break;
41 case 2 :
42 case 3 :
43 case 4 : if (uncar < '0' || uncar > '9') return Standard_False; break;
44 case 5 : if (uncar != '-') return Standard_False;
45 case 6 : if (uncar != '0' && uncar != '1') return Standard_False; break;
d3f26155 46 case 7 : if (uncar < '0' || uncar > '9') return Standard_False;
47 if (dizmois == '1' && (uncar < '0' || uncar > '2')) return Standard_False; break;
7fd59977 48 case 8 : if (uncar != '-') return Standard_False;
49 case 9 : if (uncar < '0' || uncar > '3') return Standard_False; break;
50 case 10 : if (uncar < '0' || uncar > '9') return Standard_False;
d3f26155 51 if (dizjour == '3' && (uncar != '0' && uncar != '1')) return Standard_False; break;
7fd59977 52 case 11 : if (uncar != 'T') return Standard_False;
53 case 12 : if (uncar < '0' || uncar > '2') return Standard_False; break;
54 case 13 : if (uncar < '0' || uncar > '9') return Standard_False;
55 if (dizheur == '2' && (uncar < '0' || uncar > '3')) return Standard_False; break;
7fd59977 56 case 14 : if (uncar != ':') return Standard_False;
57 case 15 : if (uncar < '0' || uncar > '5') return Standard_False; break;
58 case 16 : if (uncar < '0' || uncar > '9') return Standard_False; break;
59 case 17 : if (uncar != ':') return Standard_False;
60 case 18 : if (uncar < '0' || uncar > '5') return Standard_False; break;
61 case 19 : if (uncar < '0' || uncar > '9') return Standard_False; break;
62 default : break;
63 }
64 }
65 return Standard_True;
66}
67
68
69 APIHeaderSection_EditHeader::APIHeaderSection_EditHeader ()
70 : IFSelect_Editor (10)
71{
72// Definition
73 Handle(Interface_TypedValue) fn_name = new Interface_TypedValue("fn_name");
74 SetValue (1,fn_name,"name");
75 Handle(Interface_TypedValue) fn_time = new Interface_TypedValue("fn_time_stamp");
76 fn_time->SetSatisfies (IsTimeStamp,"IsTimeStamp");
77 SetValue (2,fn_time,"time");
78 Handle(Interface_TypedValue) fn_author = new Interface_TypedValue("fn_author");
79 SetValue (3,fn_author,"author"); // 1 seul (1er de liste)
80 Handle(Interface_TypedValue) fn_org = new Interface_TypedValue("fn_organization");
81 SetValue (4,fn_org,"org"); // 1 seul (1er de liste)
82 Handle(Interface_TypedValue) fn_preproc = new Interface_TypedValue("fn_preprocessor_version");
83 SetValue (5,fn_preproc,"preproc");
84 Handle(Interface_TypedValue) fn_orig = new Interface_TypedValue("fn_originating_system");
85 SetValue (6,fn_orig,"orig");
86 Handle(Interface_TypedValue) fn_autorize = new Interface_TypedValue("fn_authorization");
87 SetValue (7,fn_autorize,"autorize");
88
89 Handle(Interface_TypedValue) fs_schema = new Interface_TypedValue("fs_schema_identifiers");
90 SetValue (8,fs_schema,"schema"); // 1 seul (1er de liste)
91
92 Handle(Interface_TypedValue) fd_descr = new Interface_TypedValue("fd_description");
93 SetValue (9,fd_descr,"descr"); // 1 seul (1er de liste)
94
95 Handle(Interface_TypedValue) fd_level = new Interface_TypedValue("fd_implementation_level");
96 SetValue (10,fd_level,"level");
97
98}
99
100 TCollection_AsciiString APIHeaderSection_EditHeader::Label () const
101 { return TCollection_AsciiString ("Step Header"); }
102
103 Standard_Boolean APIHeaderSection_EditHeader::Recognize
35e08fe8 104 (const Handle(IFSelect_EditForm)& /*form*/) const
7fd59977 105{ return Standard_True; } // ??
106
107 Handle(TCollection_HAsciiString) APIHeaderSection_EditHeader::StringValue
35e08fe8 108 (const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer num) const
7fd59977 109{
110// Default Values
111 return TypedValue(num)->HStringValue();
112}
113
114 Standard_Boolean APIHeaderSection_EditHeader::Load
115 (const Handle(IFSelect_EditForm)& form,
35e08fe8 116 const Handle(Standard_Transient)& /*ent*/,
7fd59977 117 const Handle(Interface_InterfaceModel)& model) const
118{
119 Handle(StepData_StepModel) modl =
120 Handle(StepData_StepModel)::DownCast(model);
121 if (modl.IsNull()) return Standard_False;
122
123 APIHeaderSection_MakeHeader mkh (modl);
124
125 form->LoadValue (1 ,mkh.Name ());
126 form->LoadValue (2 ,mkh.TimeStamp ());
127 form->LoadValue (3 ,mkh.AuthorValue (1));
128 form->LoadValue (4 ,mkh.OrganizationValue (1));
129 form->LoadValue (5 ,mkh.PreprocessorVersion ());
130 form->LoadValue (6 ,mkh.OriginatingSystem ());
131 form->LoadValue (7 ,mkh.Authorisation ());
132
133 form->LoadValue (8 ,mkh.SchemaIdentifiersValue (1));
134
135 form->LoadValue (9 ,mkh.DescriptionValue (1));
136 form->LoadValue (10,mkh.ImplementationLevel ());
137
138 return Standard_True;
139}
140
141 Standard_Boolean APIHeaderSection_EditHeader::Apply
142 (const Handle(IFSelect_EditForm)& form,
35e08fe8 143 const Handle(Standard_Transient)& /*ent*/,
7fd59977 144 const Handle(Interface_InterfaceModel)& model) const
145{
146 Handle(StepData_StepModel) modl =
147 Handle(StepData_StepModel)::DownCast(model);
148 if (modl.IsNull()) return Standard_False;
149
150 APIHeaderSection_MakeHeader mkh (modl);
151
152 if (form->IsModified(1)) mkh.SetName (form->EditedValue(1));
153 if (form->IsModified(2)) mkh.SetTimeStamp (form->EditedValue(2));
154 if (form->IsModified(3)) mkh.SetAuthorValue (1,form->EditedValue(3));
155 if (form->IsModified(4)) mkh.SetOrganizationValue (1,form->EditedValue(4));
156 if (form->IsModified(5)) mkh.SetPreprocessorVersion (form->EditedValue(5));
157 if (form->IsModified(6)) mkh.SetOriginatingSystem (form->EditedValue(6));
158 if (form->IsModified(7)) mkh.SetAuthorisation (form->EditedValue(7));
159
160 if (form->IsModified(8)) mkh.SetSchemaIdentifiersValue (1,form->EditedValue(8));
161
162 if (form->IsModified(9)) mkh.SetDescriptionValue (1,form->EditedValue(9));
163 if (form->IsModified(10)) mkh.SetImplementationLevel (form->EditedValue(10));
164
165 mkh.Apply( Handle(StepData_StepModel)::DownCast(model) );
166
167 return Standard_True;
168}