0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / Interface / Interface_Recognizer.gxx
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 //#include <Interface_Recognizer.ixx>
15 #include <Standard_NoSuchObject.hxx>
16
17 //  ATTENTION : TransRecognizer a exactement le meme code ...
18 //  Mais produit un Transient au lieu d un Persistent
19
20 // Principe : a un objet de depart (cle), un Recognizer tente d'associer un
21 // resultat. La classe Recognizer offre le mecanisme general gerant cela
22 // Chaque classe particuliere (une fois definie l'instanciation) doit fournir
23 // une methode specifique Eval, qui opere la correspondance
24 // Eval considere l'objet par tous moyens appropries, et en cas de succes,
25 // appelle  SetOK(result) puis sort (return)
26 // en cas d'echec, suite au retour d'Eval, Recognizer sait que SetOK n'a pas
27 // ete appele
28
29 Interface_Recognizer::Interface_Recognizer ()
30       {  hasnext = Standard_False;  }
31   //thekey.Nullify();  inutile, fait par le constructeur ...
32
33     Standard_Boolean Interface_Recognizer::Evaluate
34   (const TheKey& akey, Handle(TheResul)& res)
35 {
36   theres.Nullify();
37   Eval(akey);
38   if (!theres.IsNull()) {
39     res = theres;
40     return Standard_True;
41   }
42   else if (hasnext) return thenext->Evaluate(akey,res);
43   return Standard_False;
44 }
45
46     Handle(TheResul) Interface_Recognizer::Result () const
47 {
48   if (!theres.IsNull()) return theres;
49   if (hasnext) return thenext->Result();
50   throw Standard_NoSuchObject("Recognizer evaluation has failed");
51 }
52
53     void Interface_Recognizer::Add (const Handle(Interface_Recognizer)& reco)
54       {  thenext = reco;  hasnext = Standard_True;  }
55
56     void Interface_Recognizer::SetOK (const Handle(TheResul)& aresult)
57       {  theres = aresult;  }
58
59     void Interface_Recognizer::SetKO ()
60       {  theres.Nullify();  }