0024788: Foundation Classes - remove Dico_Dictionary
[occt.git] / src / IFSelect / IFSelect_CheckCounter.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <IFSelect_CheckCounter.hxx>
16 #include <Interface_Check.hxx>
17 #include <Interface_CheckIterator.hxx>
18 #include <Interface_InterfaceModel.hxx>
19 #include <MoniTool_SignText.hxx>
20 #include <Standard_Transient.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <stdio.h>
24 IMPLEMENT_STANDARD_RTTIEXT(IFSelect_CheckCounter,IFSelect_SignatureList)
25
26 //=======================================================================
27 //function : IFSelect_CheckCounter
28 //purpose  : 
29 //=======================================================================
30 IFSelect_CheckCounter::IFSelect_CheckCounter(const Standard_Boolean withlist)
31      : IFSelect_SignatureList (withlist)
32 {
33   SetName("Check");
34 }
35
36
37 //=======================================================================
38 //function : SetSignature
39 //purpose  : 
40 //=======================================================================
41
42 void IFSelect_CheckCounter::SetSignature(const Handle(MoniTool_SignText)& sign)
43 {
44   thesign = sign;
45 }
46
47
48 //=======================================================================
49 //function : Signature
50 //purpose  : 
51 //=======================================================================
52
53 Handle(MoniTool_SignText) IFSelect_CheckCounter::Signature () const
54 {
55  return thesign;
56 }
57
58
59 //=======================================================================
60 //function : Analyse
61 //purpose  : 
62 //=======================================================================
63
64 void  IFSelect_CheckCounter::Analyse(const Interface_CheckIterator& list,
65                                      const Handle(Interface_InterfaceModel)& model,
66                                      const Standard_Boolean original,
67                                      const Standard_Boolean failsonly)
68 {
69   Standard_Integer i,nb,num, nbe = (model.IsNull() ? 0 : model->NbEntities());
70   char mess[300];
71   sprintf (mess,"Check %s",list.Name());
72   SetName (mess);
73   for (list.Start(); list.More(); list.Next()) {
74     num = list.Number();
75     Handle(Standard_Transient) ent;
76     const Handle(Interface_Check) check = list.Value();
77     ent = check->Entity();
78     if (ent.IsNull() && num > 0 && num <= nbe) ent = model->Value(num);
79     nb = check->NbFails();
80     Standard_CString tystr = NULL;
81     if (!ent.IsNull()) {
82       if (!thesign.IsNull()) tystr = thesign->Text (ent,model).ToCString();
83       else if (!model.IsNull()) tystr = model->TypeName (ent);
84       else tystr =
85         Interface_InterfaceModel::ClassName(ent->DynamicType()->Name());
86     }
87     for (i = 1; i <= nb; i ++) {
88       if (ent.IsNull())  sprintf(mess,"F: %s",check->CFail(i,original));
89       else sprintf(mess,"F:%s: %s",tystr,check->CFail(i,original));
90       Add (ent,mess);
91     }
92     nb = 0;
93     if (!failsonly) nb = check->NbWarnings();
94     for (i = 1; i <= nb; i ++) {
95       if (ent.IsNull())  sprintf(mess,"W: %s",check->CWarning(i,original));
96       else sprintf(mess,"W:%s: %s",tystr,check->CWarning(i,original));
97       Add (ent,mess);
98     }
99   }
100 }