0024530: TKMesh - remove unused package IntPoly
[occt.git] / src / StepData / StepData_SelectType.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and / or modify it
6 // under the terms of the GNU Lesser General Public 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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #include <StepData_SelectType.ixx>
15 #include <Standard_TypeMismatch.hxx>
16 #include <StepData_SelectNamed.hxx>
17 #include <StepData_SelectReal.hxx>
18 #include <StepData_SelectInt.hxx>
19 #include <Interface_Macros.hxx>
20
21
22
23 Standard_Boolean  StepData_SelectType::Matches
24   (const Handle(Standard_Transient)& ent) const
25 {
26   if (CaseNum(ent) > 0) return Standard_True;
27   DeclareAndCast(StepData_SelectMember,sm,ent);
28   if (sm.IsNull()) return Standard_False;
29   if (CaseMem(sm)  > 0) return Standard_True;
30   return Standard_False;
31 }
32
33     void  StepData_SelectType::SetValue (const Handle(Standard_Transient)& ent)
34 {
35   if (ent.IsNull())  thevalue.Nullify();
36   else if (!Matches(ent))
37     Standard_TypeMismatch::Raise ("StepData : SelectType, SetValue");
38   else thevalue = ent;
39 }
40
41     void  StepData_SelectType::Nullify ()
42       {  thevalue.Nullify();  }
43
44     const Handle(Standard_Transient)&  StepData_SelectType::Value () const
45       {  return thevalue;  }
46
47     Standard_Boolean  StepData_SelectType::IsNull () const
48       {  return thevalue.IsNull();  }
49
50     Handle(Standard_Type) StepData_SelectType::Type () const
51 {
52   if (thevalue.IsNull()) return STANDARD_TYPE(Standard_Transient);
53   return thevalue->DynamicType();
54 }
55
56     Standard_Integer  StepData_SelectType::CaseNumber () const
57       {  if (thevalue.IsNull()) return 0;  return CaseNum(thevalue);  }
58
59
60 //  **********   Types Immediats   ***********
61
62     Handle(StepData_PDescr)  StepData_SelectType::Description () const
63       {  Handle(StepData_PDescr) nuldescr;  return nuldescr;  }
64
65     Handle(StepData_SelectMember)   StepData_SelectType::NewMember () const
66       {  Handle(StepData_SelectMember) nulmem;  return nulmem;  }
67
68     Standard_Integer  StepData_SelectType::CaseMem (const Handle(StepData_SelectMember)& /*ent*/) const
69       {  return 0;  }
70
71     Standard_Integer  StepData_SelectType::CaseMember () const
72 {
73   DeclareAndCast(StepData_SelectMember,sm,thevalue);
74   if (sm.IsNull()) return 0;
75   return CaseMem (sm);
76 }
77
78     Handle(StepData_SelectMember)  StepData_SelectType::Member () const
79       {  return GetCasted(StepData_SelectMember,thevalue);  }
80
81     Standard_CString  StepData_SelectType::SelectName () const
82 {
83   DeclareAndCast(StepData_SelectMember,sm,thevalue);
84   if (sm.IsNull()) return "";
85   return sm->Name();
86 }
87
88     Standard_Integer  StepData_SelectType::Int () const
89 {
90   DeclareAndCast(StepData_SelectMember,sm,thevalue);
91   if (sm.IsNull()) return 0;
92   return sm->Int();
93 }
94
95     void  StepData_SelectType::SetInt (const Standard_Integer val)
96 {
97   DeclareAndCast(StepData_SelectMember,sm,thevalue);
98   if (sm.IsNull()) Standard_TypeMismatch::Raise ("StepData : SelectType, SetInt");
99   sm->SetInt (val);
100 }
101
102 //  **********   Types Immediats : Differents Cas  ***********
103
104 static Handle(StepData_SelectMember) SelectVal
105   (const Handle(Standard_Transient)& thevalue, const Standard_CString name,
106    const int mode)
107 {
108   DeclareAndCast(StepData_SelectMember,sm,thevalue);
109   if (!sm.IsNull()) {
110     if (name && name[0] != '\0')
111       if (!sm->SetName(name)) Standard_TypeMismatch::Raise ("StepData : SelectType, SetInteger");
112   }
113   else if (name && name[0] != '\0') {
114     Handle(StepData_SelectNamed) sn = new StepData_SelectNamed;
115     sn->SetName (name);
116     sm = sn;
117   } else {
118     if (mode == 0) sm = new StepData_SelectInt;
119     if (mode == 1) sm = new StepData_SelectReal;
120   }
121   return sm;
122 }
123
124
125     Standard_Integer  StepData_SelectType::Integer () const
126 {
127   DeclareAndCast(StepData_SelectMember,sm,thevalue);
128   if (sm.IsNull()) return 0;
129   return sm->Integer();
130 }
131
132     void  StepData_SelectType::SetInteger
133   (const Standard_Integer val, const Standard_CString name)
134 {
135   Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,0);
136   sm->SetInteger (val);
137   if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetInteger");
138   thevalue = sm;
139 }
140
141     Standard_Boolean  StepData_SelectType::Boolean () const
142 {
143   DeclareAndCast(StepData_SelectMember,sm,thevalue);
144   if (sm.IsNull()) return Standard_False;
145   return sm->Boolean();
146 }
147
148     void  StepData_SelectType::SetBoolean
149   (const Standard_Boolean val, const Standard_CString name)
150 {
151   Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,0);
152   sm->SetBoolean (val);
153   if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetBoolean");
154   thevalue = sm;
155 }
156
157     StepData_Logical  StepData_SelectType::Logical () const
158 {
159   DeclareAndCast(StepData_SelectMember,sm,thevalue);
160   if (sm.IsNull()) return StepData_LUnknown;
161   return sm->Logical();
162 }
163
164     void  StepData_SelectType::SetLogical
165   (const StepData_Logical val, const Standard_CString name)
166 {
167   Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,0);
168   sm->SetLogical (val);
169   if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetLogical");
170   thevalue = sm;
171 }
172
173 Standard_Real  StepData_SelectType::Real () const
174 {
175   DeclareAndCast(StepData_SelectMember,sm,thevalue);
176   if (sm.IsNull()) return 0.0;
177   return sm->Real();
178 }
179
180     void  StepData_SelectType::SetReal
181   (const Standard_Real val, const Standard_CString name)
182 {
183   Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,1);
184   sm->SetReal (val);
185   if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetReal");
186   thevalue = sm;
187 }
188
189 void StepData_SelectType::Destroy(){}