0024947: Redesign OCCT legacy type system -- automatic
[occt.git] / src / StepData / StepData_ECDescr.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
7fd59977 14#include <StepData_ECDescr.ixx>
15#include <TCollection_AsciiString.hxx>
16#include <StepData_Plex.hxx>
ec357c5c 17#include <StepData_ESDescr.hxx>
18#include <StepData_Simple.hxx>
7fd59977 19
b311480e 20StepData_ECDescr::StepData_ECDescr () { }
7fd59977 21
22 void StepData_ECDescr::Add (const Handle(StepData_ESDescr)& member)
23{
24 if (member.IsNull()) return;
25 Standard_CString name = member->TypeName();
26 TCollection_AsciiString nam (name);
27 for (Standard_Integer i = NbMembers(); i > 0; i --) {
28 Handle(StepData_ESDescr) mem = Member(i);
29 if (nam.IsLess (mem->TypeName())) { thelist.InsertBefore (i,member); return; }
30 }
31 thelist.Append (member);
32}
33
34 Standard_Integer StepData_ECDescr::NbMembers () const
35 { return thelist.Length(); }
36
37 Handle(StepData_ESDescr) StepData_ECDescr::Member
38 (const Standard_Integer num) const
39 { return Handle(StepData_ESDescr)::DownCast (thelist.Value(num)); }
40
41 Handle(TColStd_HSequenceOfAsciiString) StepData_ECDescr::TypeList () const
42{
43 Handle(TColStd_HSequenceOfAsciiString) tl = new TColStd_HSequenceOfAsciiString();
44 Standard_Integer i, nb = NbMembers();
45 for (i = 1; i <= nb; i ++) {
46 TCollection_AsciiString nam (Member(i)->TypeName());
47 tl->Append(nam);
48 }
49 return tl;
50}
51
52
53 Standard_Boolean StepData_ECDescr::Matches (const Standard_CString name) const
54{
55 Standard_Integer i, nb = NbMembers();
56 for (i = 1; i <= nb; i ++) {
57 Handle(StepData_ESDescr) member = Member(i);
58 if (member->Matches(name)) return Standard_True;
59 }
60 return Standard_False;
61}
62
63 Standard_Boolean StepData_ECDescr::IsComplex () const
64 { return Standard_True; }
65
66 Handle(StepData_Described) StepData_ECDescr::NewEntity () const
67{
68 Handle(StepData_Plex) ent = new StepData_Plex (this);
69 Standard_Integer i, nb = NbMembers();
70 for (i = 1; i <= nb; i ++) {
71 Handle(StepData_ESDescr) member = Member(i);
72 Handle(StepData_Simple) mem = Handle(StepData_Simple)::DownCast(member->NewEntity());
73 if (!mem.IsNull()) ent->Add (mem);
74 }
75 return ent;
76}