b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
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. |
7 | // |
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. |
10 | // |
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. |
17 | |
7fd59977 |
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> |
24 | |
25 | |
26 | static TCollection_AsciiString lastvalue; |
27 | |
28 | |
29 | StepSelect_StepType::StepSelect_StepType () |
30 | : IFSelect_Signature ("Step Type") { } |
31 | |
32 | void StepSelect_StepType::SetProtocol |
33 | (const Handle(Interface_Protocol)& proto) |
34 | { |
35 | DeclareAndCast(StepData_Protocol,newproto,proto); |
36 | if (newproto.IsNull()) Interface_InterfaceError::Raise("StepSelect_StepType"); |
37 | theproto = newproto; |
38 | thelib.Clear(); |
39 | thelib.AddProtocol (theproto); |
40 | thename.Clear(); |
41 | thename.AssignCat ("Step Type (Schema "); |
42 | thename.AssignCat (theproto->SchemaName()); |
43 | thename.AssignCat (")"); |
44 | } |
45 | |
46 | Standard_CString StepSelect_StepType::Value |
47 | (const Handle(Standard_Transient)& ent, |
48 | const Handle(Interface_InterfaceModel)& model) const |
49 | { |
50 | lastvalue.Clear(); |
51 | Handle(StepData_ReadWriteModule) module; |
52 | Standard_Integer CN; |
53 | Standard_Boolean ok = thelib.Select (ent,module,CN); |
54 | if (!ok) { |
55 | lastvalue.AssignCat ("..NOT FROM SCHEMA "); |
56 | lastvalue.AssignCat (theproto->SchemaName()); |
57 | lastvalue.AssignCat (".."); |
58 | } else { |
59 | Standard_Boolean plex = module->IsComplex(CN); |
60 | if (!plex) lastvalue = module->StepType(CN); |
61 | else { |
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()); |
70 | } |
71 | lastvalue.AssignCat (")"); |
72 | } |
73 | } |
74 | if (lastvalue.Length() > 0) return lastvalue.ToCString(); |
75 | |
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()); |
82 | und = und->Next(); |
83 | if (!und.IsNull()) lastvalue.AssignCat(","); |
84 | } |
85 | lastvalue.AssignCat(")"); |
86 | } |
87 | else return und->StepType(); |
88 | return lastvalue.ToCString(); |
89 | } |