1 // Created on: 1992-02-10
2 // Created by: Christian CAILLET
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Interface_FileReaderData_HeaderFile
18 #define _Interface_FileReaderData_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Integer.hxx>
24 #include <TColStd_Array1OfInteger.hxx>
25 #include <TColStd_Array1OfTransient.hxx>
26 #include <MMgt_TShared.hxx>
27 #include <Standard_CString.hxx>
28 #include <Interface_ParamType.hxx>
29 #include <Standard_Boolean.hxx>
30 #include <Standard_Real.hxx>
31 class Interface_ParamSet;
32 class Standard_NoSuchObject;
33 class TCollection_AsciiString;
34 class Interface_FileParameter;
35 class Interface_ParamList;
36 class Standard_Transient;
39 class Interface_FileReaderData;
40 DEFINE_STANDARD_HANDLE(Interface_FileReaderData, MMgt_TShared)
42 //! This class defines services which permit to access Data issued
43 //! from a File, in a form which does not depend of physical
44 //! format : thus, each Record has an attached ParamList (to be
45 //! managed) and resulting Entity.
47 //! Each Interface defines its own FileReaderData : on one hand by
48 //! defining deferred methods given here, on the other hand by
49 //! describing literal data and their accesses, with the help of
50 //! basic classes such as String, Array1OfString, etc...
52 //! FileReaderData is used by a FileReaderTool, which is also
53 //! specific of each Norm, to read an InterfaceModel of the Norm
54 //! FileReaderData inherits TShared to be accessed by Handle :
55 //! this allows FileReaderTool to define more easily the specific
56 //! methods, and improves memory management.
57 class Interface_FileReaderData : public MMgt_TShared
63 //! Returns the count of registered records
64 //! That is, value given for Initialization (can be redefined)
65 Standard_EXPORT virtual Standard_Integer NbRecords() const;
67 //! Returns the count of entities. Depending of each norm, records
68 //! can be Entities or SubParts (SubList in STEP, SubGroup in SET
69 //! ...). NbEntities counts only Entities, not Subs
70 //! Used for memory reservation in InterfaceModel
71 //! Default implementation uses FindNextRecord
72 //! Can be redefined into a more performant way
73 Standard_EXPORT virtual Standard_Integer NbEntities() const;
75 //! Determines the record number defining an Entity following a
76 //! given record number. Specific to each sub-class of
77 //! FileReaderData. Returning zero means no record found
78 Standard_EXPORT virtual Standard_Integer FindNextRecord (const Standard_Integer num) const = 0;
80 //! attaches an empty ParamList to a Record
81 Standard_EXPORT void InitParams (const Standard_Integer num);
83 //! Adds a parameter to record no "num" and fills its fields
84 //! (EntityNumber is optional)
85 //! Warning : <aval> is assumed to be memory-managed elsewhere : it is NOT
86 //! copied. This gives a best speed : strings remain stored in
87 //! pages of characters
88 Standard_EXPORT void AddParam (const Standard_Integer num, const Standard_CString aval, const Interface_ParamType atype, const Standard_Integer nument = 0);
90 //! Same as above, but gets a AsciiString from TCollection
91 //! Remark that the content of the AsciiString is locally copied
92 //! (because its content is most often lost after using)
93 Standard_EXPORT void AddParam (const Standard_Integer num, const TCollection_AsciiString& aval, const Interface_ParamType atype, const Standard_Integer nument = 0);
95 //! Same as above, but gets a complete FileParameter
96 //! Warning : Content of <FP> is NOT copied : its original address and space
97 //! in memory are assumed to be managed elsewhere (see ParamSet)
98 Standard_EXPORT void AddParam (const Standard_Integer num, const Interface_FileParameter& FP);
100 //! Sets a new value for a parameter of a record, given by :
101 //! num : record number; nump : parameter number in the record
102 Standard_EXPORT void SetParam (const Standard_Integer num, const Standard_Integer nump, const Interface_FileParameter& FP);
104 //! Returns count of parameters attached to record "num"
105 //! If <num> = 0, returns the total recorded count of parameters
106 Standard_EXPORT Standard_Integer NbParams (const Standard_Integer num) const;
108 //! Returns the complete ParamList of a record (read only)
109 //! num = 0 to return the whole param list for the file
110 Standard_EXPORT Handle(Interface_ParamList) Params (const Standard_Integer num) const;
112 //! Returns parameter "nump" of record "num", as a complete
114 Standard_EXPORT const Interface_FileParameter& Param (const Standard_Integer num, const Standard_Integer nump) const;
116 //! Same as above, but in order to be modified on place
117 Standard_EXPORT Interface_FileParameter& ChangeParam (const Standard_Integer num, const Standard_Integer nump);
119 //! Returns type of parameter "nump" of record "num"
120 //! Returns literal value of parameter "nump" of record "num"
121 //! was C++ : return const &
122 Standard_EXPORT Interface_ParamType ParamType (const Standard_Integer num, const Standard_Integer nump) const;
124 //! Same as above, but as a CString
125 //! was C++ : return const
126 Standard_EXPORT Standard_CString ParamCValue (const Standard_Integer num, const Standard_Integer nump) const;
128 //! Returns True if parameter "nump" of record "num" is defined
129 //! (it is not if its type is ParamVoid)
130 Standard_EXPORT Standard_Boolean IsParamDefined (const Standard_Integer num, const Standard_Integer nump) const;
132 //! Returns record number of an entity referenced by a parameter
133 //! of type Ident; 0 if no EntityNumber has been determined
134 //! Note that it is used to reference Entities but also Sublists
135 //! (sublists are not objects, but internal descriptions)
136 Standard_EXPORT Standard_Integer ParamNumber (const Standard_Integer num, const Standard_Integer nump) const;
138 //! Returns the StepEntity referenced by a parameter
140 Standard_EXPORT const Handle(Standard_Transient)& ParamEntity (const Standard_Integer num, const Standard_Integer nump) const;
142 //! Returns the absolute rank of the beginning of a record
143 //! (its lsit is from ParamFirstRank+1 to ParamFirstRank+NbParams)
144 Standard_EXPORT Standard_Integer ParamFirstRank (const Standard_Integer num) const;
146 //! Returns the entity bound to a record, set by SetEntities
147 Standard_EXPORT const Handle(Standard_Transient)& BoundEntity (const Standard_Integer num) const;
149 //! Binds an entity to a record
150 Standard_EXPORT void BindEntity (const Standard_Integer num, const Handle(Standard_Transient)& ent);
152 //! Sets the status "Error Load" on, to overside check fails
153 //! <val> True : declares unloaded
154 //! <val> False : declares loaded
155 //! If not called before loading (see FileReaderTool), check fails
157 //! IsErrorLoad says if SetErrorLoad has been called by user
158 //! ResetErrorLoad resets it (called by FileReaderTool)
159 //! This allows to specify that the currently loaded entity
160 //! remains unloaded (because of syntactic fail)
161 Standard_EXPORT void SetErrorLoad (const Standard_Boolean val);
163 //! Returns True if the status "Error Load" has been set (to True
165 Standard_EXPORT Standard_Boolean IsErrorLoad() const;
167 //! Returns the former value of status "Error Load" then resets it
168 //! Used to read the status then ensure it is reset
169 Standard_EXPORT Standard_Boolean ResetErrorLoad();
171 //! Destructor (waiting for memory management)
172 Standard_EXPORT void Destroy();
173 ~Interface_FileReaderData()
178 //! Same spec.s as standard <atof> but 5 times faster
179 Standard_EXPORT static Standard_Real Fastof (const Standard_CString str);
183 DEFINE_STANDARD_RTTIEXT(Interface_FileReaderData,MMgt_TShared)
188 //! Initializes arrays of Entities and of ParamLists attached
189 //! to registered records
190 //! <nbr> must be the maximum number of records to get (no way to
191 //! extend it at run-time) : count entities and sub-entities ...
192 //! <npar> is the total count of parameters (if it is not exact,
193 //! it will be extented as necessary)
195 //! Hence, to each record can be bound an Entity and a list of
196 //! Parameters. Each kind of FileReaderData can add other data, by
197 //! having them in parallel (other arrays with same sizes)
198 //! Else, it must manage binding between items and their data
199 Standard_EXPORT Interface_FileReaderData(const Standard_Integer nbr, const Standard_Integer npar);
201 //! Returns a parameter given its absolute rank in the file
202 //! in order to be consulted or modified in specilaized actions
203 Standard_EXPORT Interface_FileParameter& ChangeParameter (const Standard_Integer numpar);
205 //! For a given absolute rank of parameter, determines the
206 //! record to which its belongs, and the parameter number for it
207 Standard_EXPORT void ParamPosition (const Standard_Integer numpar, Standard_Integer& num, Standard_Integer& nump) const;
214 Standard_Integer thenum0;
215 Standard_Integer therrload;
216 Handle(Interface_ParamSet) theparams;
217 TColStd_Array1OfInteger thenumpar;
218 TColStd_Array1OfTransient theents;
229 #endif // _Interface_FileReaderData_HeaderFile