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_Recognizer.ixx>
15 #include <Standard_NoSuchObject.hxx>
17 // ATTENTION : TransRecognizer a exactement le meme code ...
18 // Mais produit un Transient au lieu d un Persistent
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
29 Interface_Recognizer::Interface_Recognizer ()
30 { hasnext = Standard_False; }
31 //thekey.Nullify(); inutile, fait par le constructeur ...
33 Standard_Boolean Interface_Recognizer::Evaluate
34 (const TheKey& akey, Handle(TheResul)& res)
38 if (!theres.IsNull()) {
42 else if (hasnext) return thenext->Evaluate(akey,res);
43 return Standard_False;
46 Handle(TheResul) Interface_Recognizer::Result () const
48 if (!theres.IsNull()) return theres;
49 if (hasnext) return thenext->Result();
50 throw Standard_NoSuchObject("Recognizer evaluation has failed");
53 void Interface_Recognizer::Add (const Handle(Interface_Recognizer)& reco)
54 { thenext = reco; hasnext = Standard_True; }
56 void Interface_Recognizer::SetOK (const Handle(TheResul)& aresult)
59 void Interface_Recognizer::SetKO ()