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 <Interface_InterfaceError.hxx>
16 #include <Interface_InterfaceModel.hxx>
17 #include <Interface_Macros.hxx>
18 #include <Interface_Protocol.hxx>
19 #include <Standard_Transient.hxx>
20 #include <Standard_Type.hxx>
21 #include <StepData_Protocol.hxx>
22 #include <StepData_ReadWriteModule.hxx>
23 #include <StepData_UndefinedEntity.hxx>
24 #include <StepSelect_StepType.hxx>
25 #include <TColStd_SequenceOfAsciiString.hxx>
27 static TCollection_AsciiString lastvalue;
30 StepSelect_StepType::StepSelect_StepType ()
31 : IFSelect_Signature ("Step Type") { }
33 void StepSelect_StepType::SetProtocol
34 (const Handle(Interface_Protocol)& proto)
36 DeclareAndCast(StepData_Protocol,newproto,proto);
37 if (newproto.IsNull()) Interface_InterfaceError::Raise("StepSelect_StepType");
40 thelib.AddProtocol (theproto);
42 thename.AssignCat ("Step Type (Schema ");
43 thename.AssignCat (theproto->SchemaName());
44 thename.AssignCat (")");
47 Standard_CString StepSelect_StepType::Value
48 (const Handle(Standard_Transient)& ent,
49 const Handle(Interface_InterfaceModel)& /*model*/) const
52 Handle(StepData_ReadWriteModule) module;
54 Standard_Boolean ok = thelib.Select (ent,module,CN);
56 lastvalue.AssignCat ("..NOT FROM SCHEMA ");
57 lastvalue.AssignCat (theproto->SchemaName());
58 lastvalue.AssignCat ("..");
60 Standard_Boolean plex = module->IsComplex(CN);
61 if (!plex) lastvalue = module->StepType(CN);
63 lastvalue.AssignCat ("(");
64 TColStd_SequenceOfAsciiString list;
65 module->ComplexType (CN,list);
66 Standard_Integer nb = list.Length();
67 if (nb == 0) lastvalue.AssignCat ("..COMPLEX TYPE..");
68 for (Standard_Integer i = 1; i <= nb; i ++) {
69 if (i > 1) lastvalue.AssignCat (",");
70 lastvalue.AssignCat (list.Value(i).ToCString());
72 lastvalue.AssignCat (")");
75 if (lastvalue.Length() > 0) return lastvalue.ToCString();
77 DeclareAndCast(StepData_UndefinedEntity,und,ent);
78 if (und.IsNull()) return lastvalue.ToCString();
79 if (und->IsComplex()) {
80 lastvalue.AssignCat("(");
81 while (!und.IsNull()) {
82 lastvalue.AssignCat (und->StepType());
84 if (!und.IsNull()) lastvalue.AssignCat(",");
86 lastvalue.AssignCat(")");
88 else return und->StepType();
89 return lastvalue.ToCString();