1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include <StepSelect_StepType.ixx>
19 #include <TColStd_SequenceOfAsciiString.hxx>
20 #include <StepData_ReadWriteModule.hxx>
21 #include <StepData_UndefinedEntity.hxx>
22 #include <Interface_InterfaceError.hxx>
23 #include <Interface_Macros.hxx>
26 static TCollection_AsciiString lastvalue;
29 StepSelect_StepType::StepSelect_StepType ()
30 : IFSelect_Signature ("Step Type") { }
32 void StepSelect_StepType::SetProtocol
33 (const Handle(Interface_Protocol)& proto)
35 DeclareAndCast(StepData_Protocol,newproto,proto);
36 if (newproto.IsNull()) Interface_InterfaceError::Raise("StepSelect_StepType");
39 thelib.AddProtocol (theproto);
41 thename.AssignCat ("Step Type (Schema ");
42 thename.AssignCat (theproto->SchemaName());
43 thename.AssignCat (")");
46 Standard_CString StepSelect_StepType::Value
47 (const Handle(Standard_Transient)& ent,
48 const Handle(Interface_InterfaceModel)& /*model*/) const
51 Handle(StepData_ReadWriteModule) module;
53 Standard_Boolean ok = thelib.Select (ent,module,CN);
55 lastvalue.AssignCat ("..NOT FROM SCHEMA ");
56 lastvalue.AssignCat (theproto->SchemaName());
57 lastvalue.AssignCat ("..");
59 Standard_Boolean plex = module->IsComplex(CN);
60 if (!plex) lastvalue = module->StepType(CN);
62 lastvalue.AssignCat ("(");
63 TColStd_SequenceOfAsciiString list;
64 module->ComplexType (CN,list);
65 Standard_Integer nb = list.Length();
66 if (nb == 0) lastvalue.AssignCat ("..COMPLEX TYPE..");
67 for (Standard_Integer i = 1; i <= nb; i ++) {
68 if (i > 1) lastvalue.AssignCat (",");
69 lastvalue.AssignCat (list.Value(i).ToCString());
71 lastvalue.AssignCat (")");
74 if (lastvalue.Length() > 0) return lastvalue.ToCString();
76 DeclareAndCast(StepData_UndefinedEntity,und,ent);
77 if (und.IsNull()) return lastvalue.ToCString();
78 if (und->IsComplex()) {
79 lastvalue.AssignCat("(");
80 while (!und.IsNull()) {
81 lastvalue.AssignCat (und->StepType());
83 if (!und.IsNull()) lastvalue.AssignCat(",");
85 lastvalue.AssignCat(")");
87 else return und->StepType();
88 return lastvalue.ToCString();