0024057: Eliminate compiler warning C4100 in MSVC++ with warning level 4
[occt.git] / src / StepData / StepData_SelectType.cxx
1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
2 //
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
7 //
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10 //
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
17
18 #include <StepData_SelectType.ixx>
19 #include <Standard_TypeMismatch.hxx>
20 #include <StepData_SelectNamed.hxx>
21 #include <StepData_SelectReal.hxx>
22 #include <StepData_SelectInt.hxx>
23 #include <Interface_Macros.hxx>
24
25
26
27 Standard_Boolean  StepData_SelectType::Matches
28   (const Handle(Standard_Transient)& ent) const
29 {
30   if (CaseNum(ent) > 0) return Standard_True;
31   DeclareAndCast(StepData_SelectMember,sm,ent);
32   if (sm.IsNull()) return Standard_False;
33   if (CaseMem(sm)  > 0) return Standard_True;
34   return Standard_False;
35 }
36
37     void  StepData_SelectType::SetValue (const Handle(Standard_Transient)& ent)
38 {
39   if (ent.IsNull())  thevalue.Nullify();
40   else if (!Matches(ent))
41     Standard_TypeMismatch::Raise ("StepData : SelectType, SetValue");
42   else thevalue = ent;
43 }
44
45     void  StepData_SelectType::Nullify ()
46       {  thevalue.Nullify();  }
47
48     const Handle(Standard_Transient)&  StepData_SelectType::Value () const
49       {  return thevalue;  }
50
51     Standard_Boolean  StepData_SelectType::IsNull () const
52       {  return thevalue.IsNull();  }
53
54     Handle(Standard_Type) StepData_SelectType::Type () const
55 {
56   if (thevalue.IsNull()) return STANDARD_TYPE(Standard_Transient);
57   return thevalue->DynamicType();
58 }
59
60     Standard_Integer  StepData_SelectType::CaseNumber () const
61       {  if (thevalue.IsNull()) return 0;  return CaseNum(thevalue);  }
62
63
64 //  **********   Types Immediats   ***********
65
66     Handle(StepData_PDescr)  StepData_SelectType::Description () const
67       {  Handle(StepData_PDescr) nuldescr;  return nuldescr;  }
68
69     Handle(StepData_SelectMember)   StepData_SelectType::NewMember () const
70       {  Handle(StepData_SelectMember) nulmem;  return nulmem;  }
71
72     Standard_Integer  StepData_SelectType::CaseMem (const Handle(StepData_SelectMember)& /*ent*/) const
73       {  return 0;  }
74
75     Standard_Integer  StepData_SelectType::CaseMember () const
76 {
77   DeclareAndCast(StepData_SelectMember,sm,thevalue);
78   if (sm.IsNull()) return 0;
79   return CaseMem (sm);
80 }
81
82     Handle(StepData_SelectMember)  StepData_SelectType::Member () const
83       {  return GetCasted(StepData_SelectMember,thevalue);  }
84
85     Standard_CString  StepData_SelectType::SelectName () const
86 {
87   DeclareAndCast(StepData_SelectMember,sm,thevalue);
88   if (sm.IsNull()) return "";
89   return sm->Name();
90 }
91
92     Standard_Integer  StepData_SelectType::Int () const
93 {
94   DeclareAndCast(StepData_SelectMember,sm,thevalue);
95   if (sm.IsNull()) return 0;
96   return sm->Int();
97 }
98
99     void  StepData_SelectType::SetInt (const Standard_Integer val)
100 {
101   DeclareAndCast(StepData_SelectMember,sm,thevalue);
102   if (sm.IsNull()) Standard_TypeMismatch::Raise ("StepData : SelectType, SetInt");
103   sm->SetInt (val);
104 }
105
106 //  **********   Types Immediats : Differents Cas  ***********
107
108 static Handle(StepData_SelectMember) SelectVal
109   (const Handle(Standard_Transient)& thevalue, const Standard_CString name,
110    const int mode)
111 {
112   DeclareAndCast(StepData_SelectMember,sm,thevalue);
113   if (!sm.IsNull()) {
114     if (name && name[0] != '\0')
115       if (!sm->SetName(name)) Standard_TypeMismatch::Raise ("StepData : SelectType, SetInteger");
116   }
117   else if (name && name[0] != '\0') {
118     Handle(StepData_SelectNamed) sn = new StepData_SelectNamed;
119     sn->SetName (name);
120     sm = sn;
121   } else {
122     if (mode == 0) sm = new StepData_SelectInt;
123     if (mode == 1) sm = new StepData_SelectReal;
124   }
125   return sm;
126 }
127
128
129     Standard_Integer  StepData_SelectType::Integer () const
130 {
131   DeclareAndCast(StepData_SelectMember,sm,thevalue);
132   if (sm.IsNull()) return 0;
133   return sm->Integer();
134 }
135
136     void  StepData_SelectType::SetInteger
137   (const Standard_Integer val, const Standard_CString name)
138 {
139   Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,0);
140   sm->SetInteger (val);
141   if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetInteger");
142   thevalue = sm;
143 }
144
145     Standard_Boolean  StepData_SelectType::Boolean () const
146 {
147   DeclareAndCast(StepData_SelectMember,sm,thevalue);
148   if (sm.IsNull()) return Standard_False;
149   return sm->Boolean();
150 }
151
152     void  StepData_SelectType::SetBoolean
153   (const Standard_Boolean val, const Standard_CString name)
154 {
155   Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,0);
156   sm->SetBoolean (val);
157   if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetBoolean");
158   thevalue = sm;
159 }
160
161     StepData_Logical  StepData_SelectType::Logical () const
162 {
163   DeclareAndCast(StepData_SelectMember,sm,thevalue);
164   if (sm.IsNull()) return StepData_LUnknown;
165   return sm->Logical();
166 }
167
168     void  StepData_SelectType::SetLogical
169   (const StepData_Logical val, const Standard_CString name)
170 {
171   Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,0);
172   sm->SetLogical (val);
173   if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetLogical");
174   thevalue = sm;
175 }
176
177 Standard_Real  StepData_SelectType::Real () const
178 {
179   DeclareAndCast(StepData_SelectMember,sm,thevalue);
180   if (sm.IsNull()) return 0.0;
181   return sm->Real();
182 }
183
184     void  StepData_SelectType::SetReal
185   (const Standard_Real val, const Standard_CString name)
186 {
187   Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,1);
188   sm->SetReal (val);
189   if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetReal");
190   thevalue = sm;
191 }
192
193 void StepData_SelectType::Destroy(){}