summaryrefslogtreecommitdiff
path: root/src/StepData/StepData_SelectType.cxx
blob: 43c220f379ab6edd9da861f9ca45306bcc8eeeb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#include <StepData_SelectType.ixx>
#include <Standard_TypeMismatch.hxx>
#include <StepData_SelectNamed.hxx>
#include <StepData_SelectReal.hxx>
#include <StepData_SelectInt.hxx>
#include <Interface_Macros.hxx>



    Standard_Boolean  StepData_SelectType::Matches
  (const Handle(Standard_Transient)& ent) const
{
  if (CaseNum(ent) > 0) return Standard_True;
  DeclareAndCast(StepData_SelectMember,sm,ent);
  if (sm.IsNull()) return Standard_False;
  if (CaseMem(sm)  > 0) return Standard_True;
  return Standard_False;
}

    void  StepData_SelectType::SetValue (const Handle(Standard_Transient)& ent)
{
  if (ent.IsNull())  thevalue.Nullify();
  else if (!Matches(ent))
    Standard_TypeMismatch::Raise ("StepData : SelectType, SetValue");
  else thevalue = ent;
}

    void  StepData_SelectType::Nullify ()
      {  thevalue.Nullify();  }

    const Handle(Standard_Transient)&  StepData_SelectType::Value () const
      {  return thevalue;  }

    Standard_Boolean  StepData_SelectType::IsNull () const
      {  return thevalue.IsNull();  }

    Handle(Standard_Type) StepData_SelectType::Type () const
{
  if (thevalue.IsNull()) return STANDARD_TYPE(Standard_Transient);
  return thevalue->DynamicType();
}

    Standard_Integer  StepData_SelectType::CaseNumber () const
      {  if (thevalue.IsNull()) return 0;  return CaseNum(thevalue);  }


//  **********   Types Immediats   ***********

    Handle(StepData_PDescr)  StepData_SelectType::Description () const
      {  Handle(StepData_PDescr) nuldescr;  return nuldescr;  }

    Handle(StepData_SelectMember)   StepData_SelectType::NewMember () const
      {  Handle(StepData_SelectMember) nulmem;  return nulmem;  }

    Standard_Integer  StepData_SelectType::CaseMem (const Handle(StepData_SelectMember)& ent) const
      {  return 0;  }

    Standard_Integer  StepData_SelectType::CaseMember () const
{
  DeclareAndCast(StepData_SelectMember,sm,thevalue);
  if (sm.IsNull()) return 0;
  return CaseMem (sm);
}

    Handle(StepData_SelectMember)  StepData_SelectType::Member () const
      {  return GetCasted(StepData_SelectMember,thevalue);  }

    Standard_CString  StepData_SelectType::SelectName () const
{
  DeclareAndCast(StepData_SelectMember,sm,thevalue);
  if (sm.IsNull()) return "";
  return sm->Name();
}

    Standard_Integer  StepData_SelectType::Int () const
{
  DeclareAndCast(StepData_SelectMember,sm,thevalue);
  if (sm.IsNull()) return 0;
  return sm->Int();
}

    void  StepData_SelectType::SetInt (const Standard_Integer val)
{
  DeclareAndCast(StepData_SelectMember,sm,thevalue);
  if (sm.IsNull()) Standard_TypeMismatch::Raise ("StepData : SelectType, SetInt");
  sm->SetInt (val);
}

//  **********   Types Immediats : Differents Cas  ***********

static Handle(StepData_SelectMember) SelectVal
  (const Handle(Standard_Transient)& thevalue, const Standard_CString name,
   const int mode)
{
  DeclareAndCast(StepData_SelectMember,sm,thevalue);
  if (!sm.IsNull()) {
    if (name && name[0] != '\0')
      if (!sm->SetName(name)) Standard_TypeMismatch::Raise ("StepData : SelectType, SetInteger");
  }
  else if (name && name[0] != '\0') {
    Handle(StepData_SelectNamed) sn = new StepData_SelectNamed;
    sn->SetName (name);
    sm = sn;
  } else {
    if (mode == 0) sm = new StepData_SelectInt;
    if (mode == 1) sm = new StepData_SelectReal;
  }
  return sm;
}


    Standard_Integer  StepData_SelectType::Integer () const
{
  DeclareAndCast(StepData_SelectMember,sm,thevalue);
  if (sm.IsNull()) return 0;
  return sm->Integer();
}

    void  StepData_SelectType::SetInteger
  (const Standard_Integer val, const Standard_CString name)
{
  Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,0);
  sm->SetInteger (val);
  if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetInteger");
  thevalue = sm;
}

    Standard_Boolean  StepData_SelectType::Boolean () const
{
  DeclareAndCast(StepData_SelectMember,sm,thevalue);
  if (sm.IsNull()) return Standard_False;
  return sm->Boolean();
}

    void  StepData_SelectType::SetBoolean
  (const Standard_Boolean val, const Standard_CString name)
{
  Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,0);
  sm->SetBoolean (val);
  if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetBoolean");
  thevalue = sm;
}

    StepData_Logical  StepData_SelectType::Logical () const
{
  DeclareAndCast(StepData_SelectMember,sm,thevalue);
  if (sm.IsNull()) return StepData_LUnknown;
  return sm->Logical();
}

    void  StepData_SelectType::SetLogical
  (const StepData_Logical val, const Standard_CString name)
{
  Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,0);
  sm->SetLogical (val);
  if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetLogical");
  thevalue = sm;
}

Standard_Real  StepData_SelectType::Real () const
{
  DeclareAndCast(StepData_SelectMember,sm,thevalue);
  if (sm.IsNull()) return 0.0;
  return sm->Real();
}

    void  StepData_SelectType::SetReal
  (const Standard_Real val, const Standard_CString name)
{
  Handle(StepData_SelectMember) sm = SelectVal (thevalue,name,1);
  sm->SetReal (val);
  if (CaseMem (sm) == 0) Standard_TypeMismatch::Raise ("StepData : SelectType, SetReal");
  thevalue = sm;
}

void StepData_SelectType::Destroy(){}