Commit | Line | Data |
---|---|---|
b311480e | 1 | -- Created on: 1993-02-04 |
2 | -- Created by: Christian CAILLET | |
3 | -- Copyright (c) 1993-1999 Matra Datavision | |
973c2be1 | 4 | -- Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | -- |
973c2be1 | 6 | -- This file is part of Open CASCADE Technology software library. |
b311480e | 7 | -- |
d5f74e42 | 8 | -- This library is free software; you can redistribute it and/or modify it under |
9 | -- the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 10 | -- by the Free Software Foundation, with special exception defined in the file |
11 | -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | -- distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 13 | -- |
973c2be1 | 14 | -- Alternatively, this file may be used under the terms of Open CASCADE |
15 | -- commercial license or contractual agreement. | |
7fd59977 | 16 | |
17 | deferred class FileReaderTool from Interface | |
18 | ||
19 | ---Purpose : Defines services which are required to load an InterfaceModel | |
20 | -- from a File. Typically, it may firstly transform a system | |
21 | -- file into a FileReaderData object, then work on it, not longer | |
22 | -- considering file contents, to load an Interface Model. | |
23 | -- It may also work on a FileReaderData already loaded. | |
24 | -- | |
25 | -- FileReaderTool provides, on one hand, some general services | |
26 | -- which are common to all read operations but can be redefined, | |
27 | -- plus general actions to be performed specifically for each | |
28 | -- Norm, as deferred methods to define. | |
29 | -- | |
30 | -- In particular, FileReaderTool defines the Interface's Unknown | |
31 | -- and Error entities | |
32 | ||
33 | uses Integer, Boolean, Transient, HArray1OfTransient, | |
34 | FileReaderData, InterfaceModel, Check, Protocol from Interface, | |
35 | Messenger from Message, | |
36 | GeneralLib, ReaderLib | |
37 | ||
38 | raises DomainError, NoSuchObject | |
39 | ||
40 | is | |
41 | ||
42 | -- -- generals -- -- | |
43 | Initialize returns FileReaderTool from Interface; | |
44 | ---Purpose: Constructor; sets default fields | |
45 | ||
6e33d3ce | 46 | SetData (me : in out; reader : FileReaderData; |
7fd59977 | 47 | protocol : Protocol from Interface); |
48 | ---Purpose : Sets Data to a FileReaderData. Works with a Protocol | |
49 | ||
50 | Protocol (me) returns Protocol from Interface; | |
51 | ---Purpose : Returns the Protocol given at creation time | |
52 | ||
6e33d3ce | 53 | Data (me) returns FileReaderData; |
7fd59977 | 54 | ---Purpose : Returns the FileReaderData which is used to work |
55 | ||
6e33d3ce | 56 | SetModel (me : in out; amodel : InterfaceModel); |
7fd59977 | 57 | ---Purpose : Stores a Model. Used when the Model has been loaded |
58 | ||
6e33d3ce | 59 | Model (me) returns InterfaceModel; |
7fd59977 | 60 | ---Purpose : Returns the stored Model |
61 | ||
62 | -- -- setting empty entities before loading model -- -- | |
63 | ||
64 | SetMessenger (me: out; messenger: Messenger from Message); | |
65 | ---Purpose : Sets Messenger used for outputting messages | |
66 | ||
67 | Messenger (me) returns Messenger from Message; | |
68 | ---Purpose : Returns Messenger used for outputting messages. | |
69 | -- The returned object is guaranteed to be non-null; | |
70 | -- default is Message::Messenger(). | |
71 | ||
72 | SetTraceLevel (me: out; tracelev: Integer); | |
73 | ---Purpose : Sets trace level used for outputting messages | |
74 | -- - 0: no trace at all | |
75 | -- - 1: errors | |
76 | -- - 2: errors and warnings | |
77 | -- - 3: all messages | |
78 | -- Default is 1 : Errors traced | |
79 | ||
80 | TraceLevel (me) returns Integer; | |
81 | ---Purpose : Returns trace level used for outputting messages. | |
82 | ||
83 | SetErrorHandle (me : in out; err : Boolean); | |
84 | ---Purpose : Allows controlling whether exception raisings are handled | |
85 | -- If err is False, they are not (hence, dbx can take control) | |
86 | -- If err is True, they are, and they are traced | |
87 | -- (by putting on messenger Entity's Number and file record num) | |
88 | -- Default given at Model's creation time is True | |
89 | ||
90 | ErrorHandle (me) returns Boolean; | |
91 | ---Purpose : Returns ErrorHandle flag | |
92 | ||
93 | -- -- setting empty entities before loading model -- -- | |
94 | ||
95 | SetEntities (me : in out); | |
96 | ---Purpose : Fills records with empty entities; once done, each entity can | |
97 | -- ask the FileReaderTool for any entity referenced through an | |
98 | -- identifier. Calls Recognize which is specific to each specific | |
99 | -- type of FileReaderTool | |
100 | ||
101 | Recognize (me : in out; num : Integer; | |
6e33d3ce | 102 | ach : in out Check; ent : out Transient) |
7fd59977 | 103 | returns Boolean is deferred; |
104 | ---Purpose : Recognizes a record, given its number. Specific to each | |
105 | -- Interface; called by SetEntities. It can call the basic method | |
106 | -- RecognizeByLib. | |
107 | -- Returns False if recognition has failed, True else. | |
108 | -- <ach> has not to be filled if simply Recognition has failed : | |
109 | -- it must record true error messages : RecognizeByLib can | |
110 | -- generate error messages if NewRead is called | |
111 | -- | |
112 | -- Note that it works thru a Recognizer (method Evaluate) which | |
113 | -- has to be memorized before starting | |
114 | ||
115 | RecognizeByLib (me; num : Integer; | |
116 | glib : in out GeneralLib; rlib : in out ReaderLib; | |
6e33d3ce | 117 | ach : in out Check; ent : out Transient) |
7fd59977 | 118 | returns Boolean; |
119 | ---Purpose : Recognizes a record with the help of Libraries. Can be used | |
120 | -- to implement the method Recognize. | |
121 | -- <rlib> is used to find Protocol and CaseNumber to apply | |
122 | -- <glib> performs the creation (by service NewVoid, or NewRead | |
123 | -- if NewVoid gave no result) | |
124 | -- <ach> is a check, which is transmitted to NewRead if it is | |
125 | -- called, gives a result but which is false | |
126 | -- <ent> is the result | |
127 | -- Returns False if recognition has failed, True else | |
128 | ||
6e33d3ce | 129 | UnknownEntity (me) returns Transient; |
7fd59977 | 130 | ---Purpose : Provides an unknown entity, specific to the Interface |
131 | -- called by SetEntities when Recognize has failed (Unknown alone) | |
132 | -- or by LoadModel when an Entity has caused a Fail on reading | |
133 | -- (to keep at least its literal description) | |
134 | -- Uses Protocol to do it | |
135 | ||
136 | -- -- loading entities into the model -- -- | |
137 | ||
6e33d3ce | 138 | NewModel (me) returns InterfaceModel; |
7fd59977 | 139 | ---Purpose : Creates an empty Model of the norm. Uses Protocol to do it |
140 | ||
6e33d3ce | 141 | LoadModel (me : in out; amodel : InterfaceModel) |
7fd59977 | 142 | raises DomainError; |
143 | ---Purpose : Reads and fills Entities from the FileReaderData set by | |
144 | -- SetData to an InterfaceModel. | |
145 | -- It enchains required operations, the specific ones correspond | |
146 | -- to deferred methods (below) to be defined for each Norm. | |
147 | -- It manages also error recovery and trace. | |
148 | -- Remark : it calls SetModel. | |
149 | -- It Can raise any error which can occur during a load | |
150 | -- operation, unless Error Handling is set. | |
151 | -- This method can also be redefined if judged necessary. | |
152 | ||
6e33d3ce | 153 | LoadedEntity (me : in out; num : Integer) returns Transient; |
7fd59977 | 154 | ---Purpose : Reads, Fills and Returns one Entity read from a Record of the |
155 | -- FileReaderData. This Method manages also case of Fail or | |
156 | -- Warning, by producing a ReportEntyty plus , for a Fail, a | |
157 | -- literal Content (as an UnknownEntity). Performs also Trace | |
158 | ||
6e33d3ce | 159 | BeginRead (me : in out; amodel : InterfaceModel) is deferred; |
7fd59977 | 160 | ---Purpose : Fills model's header; each Interface defines for its Model its |
161 | -- own file header; this method fills it from FileReaderTool.+ | |
162 | -- It is called by AnalyseFile from InterfaceModel | |
163 | ||
164 | AnalyseRecord (me : in out; | |
6e33d3ce | 165 | num : Integer; anent : Transient; acheck : in out Check) |
7fd59977 | 166 | returns Boolean is deferred; |
167 | ---Purpose : Fills an Entity, given record no; specific to each Interface, | |
168 | -- called by AnalyseFile from InterfaceModel (which manages its | |
169 | -- calling arguments) | |
170 | -- To work, each Interface can define a method in its proper | |
171 | -- Transient class, like this (given as an example) : | |
172 | -- AnalyseRecord (me : mutable; FR : in out FileReaderTool; | |
173 | -- num : Integer; acheck : in out Check) | |
174 | -- returns Boolean; | |
175 | -- and call it from AnalyseRecord | |
176 | -- | |
177 | -- Returned Value : True if the entity could be loaded, False | |
178 | -- else (in case of syntactic fail) | |
179 | ||
180 | Destroy (me: in out) is virtual; | |
181 | ---C++ : alias "Standard_EXPORT virtual ~Interface_FileReaderTool() { Destroy(); }" | |
182 | ||
6e33d3ce | 183 | EndRead (me : in out; amodel : InterfaceModel) is virtual; |
7fd59977 | 184 | ---Purpose : Ends file reading after reading all the entities |
185 | -- default is doing nothing; redefinable as necessary | |
bc650d41 G |
186 | |
187 | ||
188 | Clear(me : in out); | |
189 | ---Purpose : Clear filelds | |
7fd59977 | 190 | |
191 | fields | |
192 | ||
193 | theproto : Protocol from Interface; | |
194 | thereader : FileReaderData; | |
195 | themodel : InterfaceModel; | |
196 | themessenger:Messenger from Message; | |
197 | thetrace : Integer; -- trace level (exceptions,errors, etc...) | |
198 | theerrhand : Boolean; -- to handle or not exceptions | |
199 | thenbrep0 : Integer; -- (reports at creation time) | |
200 | thenbreps : Integer; -- (all reports) | |
201 | thereports : HArray1OfTransient; | |
202 | ||
203 | end FileReaderTool; |