Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:07

0001 // Created on: 1993-02-04
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Interface_FileReaderTool_HeaderFile
0018 #define _Interface_FileReaderTool_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <TColStd_HArray1OfTransient.hxx>
0026 class Interface_Protocol;
0027 class Interface_FileReaderData;
0028 class Interface_InterfaceModel;
0029 class Message_Messenger;
0030 class Interface_Check;
0031 class Standard_Transient;
0032 class Interface_GeneralLib;
0033 class Interface_ReaderLib;
0034 
0035 
0036 //! Defines services which are required to load an InterfaceModel
0037 //! from a File. Typically, it may firstly transform a system
0038 //! file into a FileReaderData object, then work on it, not longer
0039 //! considering file contents, to load an Interface Model.
0040 //! It may also work on a FileReaderData already loaded.
0041 //!
0042 //! FileReaderTool provides, on one hand, some general services
0043 //! which are common to all read operations but can be redefined,
0044 //! plus general actions to be performed specifically for each
0045 //! Norm, as deferred methods to define.
0046 //!
0047 //! In particular, FileReaderTool defines the Interface's Unknown
0048 //! and Error entities
0049 class Interface_FileReaderTool 
0050 {
0051 public:
0052 
0053   DEFINE_STANDARD_ALLOC
0054 
0055   
0056   //! Sets Data to a FileReaderData. Works with a Protocol
0057   Standard_EXPORT void SetData (const Handle(Interface_FileReaderData)& reader, const Handle(Interface_Protocol)& protocol);
0058   
0059   //! Returns the Protocol given at creation time
0060   Standard_EXPORT Handle(Interface_Protocol) Protocol() const;
0061   
0062   //! Returns the FileReaderData which is used to work
0063   Standard_EXPORT Handle(Interface_FileReaderData) Data() const;
0064   
0065   //! Stores a Model. Used when the Model has been loaded
0066   Standard_EXPORT void SetModel (const Handle(Interface_InterfaceModel)& amodel);
0067   
0068   //! Returns the stored Model
0069   Standard_EXPORT Handle(Interface_InterfaceModel) Model() const;
0070   
0071   //! Sets Messenger used for outputting messages
0072   Standard_EXPORT void SetMessenger (const Handle(Message_Messenger)& messenger);
0073   
0074   //! Returns Messenger used for outputting messages.
0075   //! The returned object is guaranteed to be non-null;
0076   //! default is Message::Messenger().
0077   Standard_EXPORT Handle(Message_Messenger) Messenger() const;
0078   
0079   //! Sets trace level used for outputting messages
0080   //! - 0: no trace at all
0081   //! - 1: errors
0082   //! - 2: errors and warnings
0083   //! - 3: all messages
0084   //! Default is 1 : Errors traced
0085   Standard_EXPORT void SetTraceLevel (const Standard_Integer tracelev);
0086   
0087   //! Returns trace level used for outputting messages.
0088   Standard_EXPORT Standard_Integer TraceLevel() const;
0089   
0090   //! Allows controlling whether exception raisings are handled
0091   //! If err is False, they are not (hence, dbx can take control)
0092   //! If err is True, they are, and they are traced
0093   //! (by putting on messenger Entity's Number and file record num)
0094   //! Default given at Model's creation time is True
0095   Standard_EXPORT void SetErrorHandle (const Standard_Boolean err);
0096   
0097   //! Returns ErrorHandle flag
0098   Standard_EXPORT Standard_Boolean ErrorHandle() const;
0099   
0100   //! Fills records with empty entities; once done, each entity can
0101   //! ask the FileReaderTool for any entity referenced through an
0102   //! identifier. Calls Recognize which is specific to each specific
0103   //! type of FileReaderTool
0104   Standard_EXPORT void SetEntities();
0105   
0106   //! Recognizes a record, given its number. Specific to each
0107   //! Interface; called by SetEntities. It can call the basic method
0108   //! RecognizeByLib.
0109   //! Returns False if recognition has failed, True else.
0110   //! <ach> has not to be filled if simply Recognition has failed :
0111   //! it must record true error messages : RecognizeByLib can
0112   //! generate error messages if NewRead is called
0113   //!
0114   //! Note that it works thru a Recognizer (method Evaluate) which
0115   //! has to be memorized before starting
0116   Standard_EXPORT virtual Standard_Boolean Recognize (const Standard_Integer num, Handle(Interface_Check)& ach, Handle(Standard_Transient)& ent) = 0;
0117   
0118   //! Recognizes a record with the help of Libraries. Can be used
0119   //! to implement the method Recognize.
0120   //! <rlib> is used to find Protocol and CaseNumber to apply
0121   //! <glib> performs the creation (by service NewVoid, or NewRead
0122   //! if NewVoid gave no result)
0123   //! <ach> is a check, which is transmitted to NewRead if it is
0124   //! called, gives a result but which is false
0125   //! <ent> is the result
0126   //! Returns False if recognition has failed, True else
0127   Standard_EXPORT Standard_Boolean RecognizeByLib (const Standard_Integer num, Interface_GeneralLib& glib, Interface_ReaderLib& rlib, Handle(Interface_Check)& ach, Handle(Standard_Transient)& ent) const;
0128   
0129   //! Provides an unknown entity, specific to the Interface
0130   //! called by SetEntities when Recognize has failed (Unknown alone)
0131   //! or by LoadModel when an Entity has caused a Fail on reading
0132   //! (to keep at least its literal description)
0133   //! Uses Protocol to do it
0134   Standard_EXPORT Handle(Standard_Transient) UnknownEntity() const;
0135   
0136   //! Creates an empty Model of the norm. Uses Protocol to do it
0137   Standard_EXPORT Handle(Interface_InterfaceModel) NewModel() const;
0138   
0139   //! Reads and fills Entities from the FileReaderData set by
0140   //! SetData to an InterfaceModel.
0141   //! It enchains required operations, the specific ones correspond
0142   //! to deferred methods (below) to be defined for each Norm.
0143   //! It manages also error recovery and trace.
0144   //! Remark : it calls SetModel.
0145   //! It Can raise any error which can occur during a load
0146   //! operation, unless Error Handling is set.
0147   //! This method can also be redefined if judged necessary.
0148   Standard_EXPORT void LoadModel (const Handle(Interface_InterfaceModel)& amodel);
0149   
0150   //! Reads, Fills and Returns one Entity read from a Record of the
0151   //! FileReaderData. This Method manages also case of Fail or
0152   //! Warning, by producing a ReportEntyty plus , for a Fail, a
0153   //! literal Content (as an UnknownEntity). Performs also Trace
0154   Standard_EXPORT Handle(Standard_Transient) LoadedEntity (const Standard_Integer num);
0155   
0156   //! Fills model's header; each Interface defines for its Model its
0157   //! own file header; this method fills it from FileReaderTool.+
0158   //! It is called by AnalyseFile from InterfaceModel
0159   Standard_EXPORT virtual void BeginRead (const Handle(Interface_InterfaceModel)& amodel) = 0;
0160   
0161   //! Fills an Entity, given record no; specific to each Interface,
0162   //! called by AnalyseFile from InterfaceModel (which manages its
0163   //! calling arguments)
0164   //! To work, each Interface can define a method in its proper
0165   //! Transient class, like this (given as an example) :
0166   //! AnalyseRecord (me  : mutable; FR     : in out FileReaderTool;
0167   //! num : Integer; acheck : in out Check)
0168   //! returns Boolean;
0169   //! and call it from AnalyseRecord
0170   //!
0171   //! Returned Value : True if the entity could be loaded, False
0172   //! else (in case of syntactic fail)
0173   Standard_EXPORT virtual Standard_Boolean AnalyseRecord (const Standard_Integer num, const Handle(Standard_Transient)& anent, Handle(Interface_Check)& acheck) = 0;
0174   
0175   Standard_EXPORT virtual ~Interface_FileReaderTool();
0176   
0177   //! Ends file reading after reading all the entities
0178   //! default is doing nothing; redefinable as necessary
0179   Standard_EXPORT virtual void EndRead (const Handle(Interface_InterfaceModel)& amodel);
0180   
0181   //! Clear fields
0182   Standard_EXPORT void Clear();
0183 
0184 
0185 
0186 
0187 protected:
0188 
0189   
0190   //! Constructor; sets default fields
0191   Standard_EXPORT Interface_FileReaderTool();
0192 
0193 
0194 
0195 
0196 private:
0197 
0198 
0199 
0200   Handle(Interface_Protocol) theproto;
0201   Handle(Interface_FileReaderData) thereader;
0202   Handle(Interface_InterfaceModel) themodel;
0203   Handle(Message_Messenger) themessenger;
0204   Standard_Integer thetrace;
0205   Standard_Boolean theerrhand;
0206   Standard_Integer thenbrep0;
0207   Standard_Integer thenbreps;
0208   Handle(TColStd_HArray1OfTransient) thereports;
0209 
0210 
0211 };
0212 
0213 
0214 
0215 
0216 
0217 
0218 
0219 #endif // _Interface_FileReaderTool_HeaderFile