1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <Standard_Type.hxx>
16 #include <StepData_Described.hxx>
17 #include <StepData_ECDescr.hxx>
18 #include <StepData_ESDescr.hxx>
19 #include <StepData_Plex.hxx>
20 #include <StepData_Simple.hxx>
21 #include <TCollection_AsciiString.hxx>
23 StepData_ECDescr::StepData_ECDescr () { }
25 void StepData_ECDescr::Add (const Handle(StepData_ESDescr)& member)
27 if (member.IsNull()) return;
28 Standard_CString name = member->TypeName();
29 TCollection_AsciiString nam (name);
30 for (Standard_Integer i = NbMembers(); i > 0; i --) {
31 Handle(StepData_ESDescr) mem = Member(i);
32 if (nam.IsLess (mem->TypeName())) { thelist.InsertBefore (i,member); return; }
34 thelist.Append (member);
37 Standard_Integer StepData_ECDescr::NbMembers () const
38 { return thelist.Length(); }
40 Handle(StepData_ESDescr) StepData_ECDescr::Member
41 (const Standard_Integer num) const
42 { return Handle(StepData_ESDescr)::DownCast (thelist.Value(num)); }
44 Handle(TColStd_HSequenceOfAsciiString) StepData_ECDescr::TypeList () const
46 Handle(TColStd_HSequenceOfAsciiString) tl = new TColStd_HSequenceOfAsciiString();
47 Standard_Integer i, nb = NbMembers();
48 for (i = 1; i <= nb; i ++) {
49 TCollection_AsciiString nam (Member(i)->TypeName());
56 Standard_Boolean StepData_ECDescr::Matches (const Standard_CString name) const
58 Standard_Integer i, nb = NbMembers();
59 for (i = 1; i <= nb; i ++) {
60 Handle(StepData_ESDescr) member = Member(i);
61 if (member->Matches(name)) return Standard_True;
63 return Standard_False;
66 Standard_Boolean StepData_ECDescr::IsComplex () const
67 { return Standard_True; }
69 Handle(StepData_Described) StepData_ECDescr::NewEntity () const
71 Handle(StepData_Plex) ent = new StepData_Plex (this);
72 Standard_Integer i, nb = NbMembers();
73 for (i = 1; i <= nb; i ++) {
74 Handle(StepData_ESDescr) member = Member(i);
75 Handle(StepData_Simple) mem = Handle(StepData_Simple)::DownCast(member->NewEntity());
76 if (!mem.IsNull()) ent->Add (mem);