1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-08 18:40:55 +03:00
occt/src/Interface/Interface_Recognizer.gxx
bugmaster b311480ed5 0023024: Update headers of OCCT files
Added appropriate copyright and license information in source files
2012-03-21 19:43:04 +04:00

66 lines
2.6 KiB
Plaintext
Executable File

// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
//#include <Interface_Recognizer.ixx>
#include <Standard_NoSuchObject.hxx>
// ATTENTION : TransRecognizer a exactement le meme code ...
// Mais produit un Transient au lieu d un Persistent
// Principe : a un objet de depart (cle), un Recognizer tente d'associer un
// resultat. La classe Recognizer offre le mecanisme general gerant cela
// Chaque classe particuliere (une fois definie l'instanciation) doit fournir
// une methode specifique Eval, qui opere la correspondance
// Eval considere l'objet par tous moyens appropries, et en cas de succes,
// appelle SetOK(result) puis sort (return)
// en cas d'echec, suite au retour d'Eval, Recognizer sait que SetOK n'a pas
// ete appele
Interface_Recognizer::Interface_Recognizer ()
{ hasnext = Standard_False; }
//thekey.Nullify(); inutile, fait par le constructeur ...
Standard_Boolean Interface_Recognizer::Evaluate
(const TheKey& akey, Handle(TheResul)& res)
{
theres.Nullify();
Eval(akey);
if (!theres.IsNull()) {
res = theres;
return Standard_True;
}
else if (hasnext) return thenext->Evaluate(akey,res);
return Standard_False;
}
Handle(TheResul) Interface_Recognizer::Result () const
{
if (!theres.IsNull()) return theres;
if (hasnext) return thenext->Result();
Standard_NoSuchObject::Raise ("Recognizer evaluation has failed");
return theres; // pour calmer le compilateur
}
void Interface_Recognizer::Add (const Handle(Interface_Recognizer)& reco)
{ thenext = reco; hasnext = Standard_True; }
void Interface_Recognizer::SetOK (const Handle(TheResul)& aresult)
{ theres = aresult; }
void Interface_Recognizer::SetKO ()
{ theres.Nullify(); }