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 IMPLEMENT_STANDARD_RTTIEXT(StepSelect_StepType,IFSelect_Signature)
29 static TCollection_AsciiString lastvalue;
32 StepSelect_StepType::StepSelect_StepType ()
33 : IFSelect_Signature ("Step Type") { }
35 void StepSelect_StepType::SetProtocol
36 (const Handle(Interface_Protocol)& proto)
38 DeclareAndCast(StepData_Protocol,newproto,proto);
39 if (newproto.IsNull()) throw Interface_InterfaceError("StepSelect_StepType");
42 thelib.AddProtocol (theproto);
44 thename.AssignCat ("Step Type (Schema ");
45 thename.AssignCat (theproto->SchemaName());
46 thename.AssignCat (")");
49 Standard_CString StepSelect_StepType::Value
50 (const Handle(Standard_Transient)& ent,
51 const Handle(Interface_InterfaceModel)& /*model*/) const
54 Handle(StepData_ReadWriteModule) module;
56 Standard_Boolean ok = thelib.Select (ent,module,CN);
58 lastvalue.AssignCat ("..NOT FROM SCHEMA ");
59 lastvalue.AssignCat (theproto->SchemaName());
60 lastvalue.AssignCat ("..");
62 Standard_Boolean plex = module->IsComplex(CN);
63 if (!plex) lastvalue = module->StepType(CN);
65 lastvalue.AssignCat ("(");
66 TColStd_SequenceOfAsciiString list;
67 module->ComplexType (CN,list);
68 Standard_Integer nb = list.Length();
69 if (nb == 0) lastvalue.AssignCat ("..COMPLEX TYPE..");
70 for (Standard_Integer i = 1; i <= nb; i ++) {
71 if (i > 1) lastvalue.AssignCat (",");
72 lastvalue.AssignCat (list.Value(i).ToCString());
74 lastvalue.AssignCat (")");
77 if (lastvalue.Length() > 0) return lastvalue.ToCString();
79 DeclareAndCast(StepData_UndefinedEntity,und,ent);
80 if (und.IsNull()) return lastvalue.ToCString();
81 if (und->IsComplex()) {
82 lastvalue.AssignCat("(");
83 while (!und.IsNull()) {
84 lastvalue.AssignCat (und->StepType());
86 if (!und.IsNull()) lastvalue.AssignCat(",");
88 lastvalue.AssignCat(")");
90 else return und->StepType();
91 return lastvalue.ToCString();