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