0024428: Implementation of LGPL license
[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//
973c2be1 5// This library is free software; you can redistribute it and / or modify it
6// under the terms of the GNU Lesser General Public 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.
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>
17
b311480e 18StepData_ECDescr::StepData_ECDescr () { }
7fd59977 19
20 void StepData_ECDescr::Add (const Handle(StepData_ESDescr)& member)
21{
22 if (member.IsNull()) return;
23 Standard_CString name = member->TypeName();
24 TCollection_AsciiString nam (name);
25 for (Standard_Integer i = NbMembers(); i > 0; i --) {
26 Handle(StepData_ESDescr) mem = Member(i);
27 if (nam.IsLess (mem->TypeName())) { thelist.InsertBefore (i,member); return; }
28 }
29 thelist.Append (member);
30}
31
32 Standard_Integer StepData_ECDescr::NbMembers () const
33 { return thelist.Length(); }
34
35 Handle(StepData_ESDescr) StepData_ECDescr::Member
36 (const Standard_Integer num) const
37 { return Handle(StepData_ESDescr)::DownCast (thelist.Value(num)); }
38
39 Handle(TColStd_HSequenceOfAsciiString) StepData_ECDescr::TypeList () const
40{
41 Handle(TColStd_HSequenceOfAsciiString) tl = new TColStd_HSequenceOfAsciiString();
42 Standard_Integer i, nb = NbMembers();
43 for (i = 1; i <= nb; i ++) {
44 TCollection_AsciiString nam (Member(i)->TypeName());
45 tl->Append(nam);
46 }
47 return tl;
48}
49
50
51 Standard_Boolean StepData_ECDescr::Matches (const Standard_CString name) const
52{
53 Standard_Integer i, nb = NbMembers();
54 for (i = 1; i <= nb; i ++) {
55 Handle(StepData_ESDescr) member = Member(i);
56 if (member->Matches(name)) return Standard_True;
57 }
58 return Standard_False;
59}
60
61 Standard_Boolean StepData_ECDescr::IsComplex () const
62 { return Standard_True; }
63
64 Handle(StepData_Described) StepData_ECDescr::NewEntity () const
65{
66 Handle(StepData_Plex) ent = new StepData_Plex (this);
67 Standard_Integer i, nb = NbMembers();
68 for (i = 1; i <= nb; i ++) {
69 Handle(StepData_ESDescr) member = Member(i);
70 Handle(StepData_Simple) mem = Handle(StepData_Simple)::DownCast(member->NewEntity());
71 if (!mem.IsNull()) ent->Add (mem);
72 }
73 return ent;
74}