Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/opencascade/Interface_Recognizer.gxx is written in an unsupported language. File is not indexed.

0001 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 //#include <Interface_Recognizer.ixx>
0015 #include <Standard_NoSuchObject.hxx>
0016 
0017 //  ATTENTION : TransRecognizer a exactement le meme code ...
0018 //  Mais produit un Transient au lieu d un Persistent
0019 
0020 // Principe : a un objet de depart (cle), un Recognizer tente d'associer un
0021 // resultat. La classe Recognizer offre le mecanisme general gerant cela
0022 // Chaque classe particuliere (une fois definie l'instanciation) doit fournir
0023 // une methode specifique Eval, qui opere la correspondance
0024 // Eval considere l'objet par tous moyens appropries, et en cas de succes,
0025 // appelle  SetOK(result) puis sort (return)
0026 // en cas d'echec, suite au retour d'Eval, Recognizer sait que SetOK n'a pas
0027 // ete appele
0028 
0029 Interface_Recognizer::Interface_Recognizer ()
0030       {  hasnext = Standard_False;  }
0031   //thekey.Nullify();  inutile, fait par le constructeur ...
0032 
0033     Standard_Boolean Interface_Recognizer::Evaluate
0034   (const TheKey& akey, Handle(TheResul)& res)
0035 {
0036   theres.Nullify();
0037   Eval(akey);
0038   if (!theres.IsNull()) {
0039     res = theres;
0040     return Standard_True;
0041   }
0042   else if (hasnext) return thenext->Evaluate(akey,res);
0043   return Standard_False;
0044 }
0045 
0046     Handle(TheResul) Interface_Recognizer::Result () const
0047 {
0048   if (!theres.IsNull()) return theres;
0049   if (hasnext) return thenext->Result();
0050   throw Standard_NoSuchObject("Recognizer evaluation has failed");
0051 }
0052 
0053     void Interface_Recognizer::Add (const Handle(Interface_Recognizer)& reco)
0054       {  thenext = reco;  hasnext = Standard_True;  }
0055 
0056     void Interface_Recognizer::SetOK (const Handle(TheResul)& aresult)
0057       {  theres = aresult;  }
0058 
0059     void Interface_Recognizer::SetKO ()
0060       {  theres.Nullify();  }