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.
14 #include <Interface_GTool.ixx>
15 #include <Interface_GeneralModule.hxx>
17 Interface_GTool::Interface_GTool () { }
19 Interface_GTool::Interface_GTool
20 (const Handle(Interface_Protocol)& proto, const Standard_Integer nb)
21 : theproto (proto) , thelib (proto)
22 { if (nb > 0) { thentnum.ReSize(nb); thentmod.ReSize(nb); } }
25 void Interface_GTool::SetSignType (const Handle(Interface_SignType)& sign)
28 Handle(Interface_SignType) Interface_GTool::SignType () const
31 Standard_CString Interface_GTool::SignValue
32 (const Handle(Standard_Transient)& ent,
33 const Handle(Interface_InterfaceModel)& model) const
35 if (ent.IsNull()) return "";
36 if (thesign.IsNull()) return Interface_SignType::ClassName(ent->DynamicType()->Name());
37 return thesign->Value (ent,model);
40 Standard_CString Interface_GTool::SignName () const
42 if (thesign.IsNull()) return "Class Name";
43 return thesign->Name();
47 void Interface_GTool::SetProtocol
48 (const Handle(Interface_Protocol)& proto, const Standard_Boolean enforce)
50 if (proto == theproto && !enforce) return;
53 thelib.AddProtocol (proto);
56 Handle(Interface_Protocol) Interface_GTool::Protocol () const
59 Interface_GeneralLib& Interface_GTool::Lib ()
62 void Interface_GTool::Reservate
63 (const Standard_Integer nb, const Standard_Boolean enforce)
65 Standard_Integer n = thentnum.NbBuckets();
66 if (n < nb && !enforce) return;
67 thentnum.ReSize (nb); thentmod.ReSize (nb);
70 void Interface_GTool::ClearEntities ()
71 { thentnum.Clear(); thentmod.Clear(); }
74 //=======================================================================
77 //=======================================================================
79 Standard_Boolean Interface_GTool::Select (const Handle(Standard_Transient)& ent,
80 Handle(Interface_GeneralModule)& gmod,
82 const Standard_Boolean enforce)
84 const Handle(Standard_Type)& aType = ent->DynamicType();
85 Standard_Integer num = thentmod.FindIndex(aType);// (ent);
86 if (num == 0 || enforce) {
87 if (thelib.Select (ent,gmod,CN)) {
88 num = thentmod.Add (aType,gmod);
89 thentnum.Bind (aType,CN);
92 return Standard_False;
94 gmod = Handle(Interface_GeneralModule)::DownCast (thentmod.FindFromKey(aType));
95 CN = thentnum.Find (aType);