0024947: Redesign OCCT legacy type system -- automatic
[occt.git] / src / StepData / StepData_Plex.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 under
6 // the terms of the GNU Lesser General Public License 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_Plex.ixx>
15 #include <TCollection_AsciiString.hxx>
16 #include <Interface_InterfaceMismatch.hxx>
17 #include <StepData_ECDescr.hxx>
18 #include <StepData_Simple.hxx>
19
20
21 static StepData_Field bid;
22
23     StepData_Plex::StepData_Plex  (const Handle(StepData_ECDescr)& descr)
24     : StepData_Described (descr)    {  }
25
26     void  StepData_Plex::Add (const Handle(StepData_Simple)& member)
27       {  themembers.Append (member);  }
28
29     Handle(StepData_ECDescr)  StepData_Plex::ECDescr () const
30       {  return Handle(StepData_ECDescr)::DownCast(Description());  }
31
32
33     Standard_Boolean  StepData_Plex::IsComplex () const
34       {  return Standard_True;  }
35
36     Standard_Boolean  StepData_Plex::Matches (const Standard_CString steptype) const
37 {
38   Standard_Integer i, nb = NbMembers();
39   for (i = 1; i <= nb; i ++) {
40     if (Member(i)->Matches (steptype)) return Standard_True;
41   }
42   return Standard_False;
43 }
44
45     Handle(StepData_Simple)  StepData_Plex::As  (const Standard_CString steptype) const
46 {
47   Handle(StepData_Simple) ent;
48   Standard_Integer i, nb = NbMembers();
49   for (i = 1; i <= nb; i ++) {
50     ent = Member(i);
51     if (ent->Matches(steptype)) return ent;
52   }
53   ent.Nullify();
54   return ent;
55 }
56
57     Standard_Boolean  StepData_Plex::HasField (const Standard_CString name) const
58 {
59   Standard_Integer i, nb = NbMembers();
60   for (i = 1; i <= nb; i ++) {
61     if (Member(i)->HasField (name)) return Standard_True;
62   }
63   return Standard_False;
64 }
65
66     const StepData_Field&  StepData_Plex::Field (const Standard_CString name) const
67 {
68   Handle(StepData_Simple) ent;
69   Standard_Integer i, nb = NbMembers();
70   for (i = 1; i <= nb; i ++) {
71     ent = Member(i);
72     if (ent->HasField (name)) return ent->Field (name);
73   }
74   Interface_InterfaceMismatch::Raise("StepData_Plex : Field");
75   return bid;  // pour faire plaisir au compilo
76 }
77
78
79     StepData_Field&  StepData_Plex::CField (const Standard_CString name)
80 {
81   Handle(StepData_Simple) ent;
82   Standard_Integer i, nb = NbMembers();
83   for (i = 1; i <= nb; i ++) {
84     ent = Member(i);
85     if (ent->HasField (name)) return ent->CField (name);
86   }
87   Interface_InterfaceMismatch::Raise("StepData_Plex : Field");
88   return bid;  // pour faire plaisir au compilo
89 }
90
91
92     Standard_Integer  StepData_Plex::NbMembers () const
93       {  return themembers.Length();  }
94
95     Handle(StepData_Simple)  StepData_Plex::Member (const Standard_Integer num) const
96       {  return Handle(StepData_Simple)::DownCast (themembers.Value(num));  }
97
98     Handle(TColStd_HSequenceOfAsciiString)  StepData_Plex::TypeList () const
99 {
100   Handle(TColStd_HSequenceOfAsciiString) tl = new TColStd_HSequenceOfAsciiString();
101   Standard_Integer i, nb = NbMembers();
102   for (i = 1; i <= nb; i ++) {
103     TCollection_AsciiString nam (Member(i)->StepType());
104     tl->Append (nam);
105   }
106   return tl;
107 }
108
109
110 void StepData_Plex::Check(Handle(Interface_Check)& ach) const
111 {
112   Standard_Integer i, nb = NbMembers();
113   for (i = 1; i <= nb; i ++) {
114     Handle(StepData_Simple) si = Member(i);
115     si->Check(ach);
116   }
117 }
118
119
120     void  StepData_Plex::Shared (Interface_EntityIterator& list) const
121 {
122   Standard_Integer i, nb = NbMembers();
123   for (i = 1; i <= nb; i ++) {
124     Handle(StepData_Simple) si = Member(i);
125     si->Shared (list);
126   }
127 }