|
|
|||
File indexing completed on 2026-09-18 09:20:55
0001 // Created on: 1992-02-10 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1992-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_FileReaderData_HeaderFile 0018 #define _Interface_FileReaderData_HeaderFile 0019 0020 #include <Standard.hxx> 0021 0022 #include <Standard_Integer.hxx> 0023 #include <NCollection_Array1.hxx> 0024 #include <Standard_Transient.hxx> 0025 #include <Standard_CString.hxx> 0026 #include <Interface_ParamType.hxx> 0027 class Interface_ParamSet; 0028 class TCollection_AsciiString; 0029 class Interface_FileParameter; 0030 class Interface_ParamList; 0031 0032 //! This class defines services which permit to access Data issued 0033 //! from a File, in a form which does not depend of physical 0034 //! format : thus, each Record has an attached ParamList (to be 0035 //! managed) and resulting Entity. 0036 //! 0037 //! Each Interface defines its own FileReaderData : on one hand by 0038 //! defining deferred methods given here, on the other hand by 0039 //! describing literal data and their accesses, with the help of 0040 //! basic classes such as String, Array1OfString, etc... 0041 //! 0042 //! FileReaderData is used by a FileReaderTool, which is also 0043 //! specific of each Norm, to read an InterfaceModel of the Norm 0044 //! FileReaderData inherits TShared to be accessed by Handle : 0045 //! this allows FileReaderTool to define more easily the specific 0046 //! methods, and improves memory management. 0047 class Interface_FileReaderData : public Standard_Transient 0048 { 0049 0050 public: 0051 //! Returns the count of registered records 0052 //! That is, value given for Initialization (can be redefined) 0053 Standard_EXPORT virtual int NbRecords() const; 0054 0055 //! Returns the count of entities. Depending of each norm, records 0056 //! can be Entities or SubParts (SubList in STEP, SubGroup in SET 0057 //! ...). NbEntities counts only Entities, not Subs 0058 //! Used for memory reservation in InterfaceModel 0059 //! Default implementation uses FindNextRecord 0060 //! Can be redefined into a more performant way 0061 Standard_EXPORT virtual int NbEntities() const; 0062 0063 //! Determines the record number defining an Entity following a 0064 //! given record number. Specific to each sub-class of 0065 //! FileReaderData. Returning zero means no record found 0066 Standard_EXPORT virtual int FindNextRecord(const int num) const = 0; 0067 0068 //! attaches an empty ParamList to a Record 0069 Standard_EXPORT void InitParams(const int num); 0070 0071 //! Adds a parameter to record no "num" and fills its fields 0072 //! (EntityNumber is optional) 0073 //! Warning : <aval> is assumed to be memory-managed elsewhere : it is NOT 0074 //! copied. This gives a best speed : strings remain stored in 0075 //! pages of characters 0076 Standard_EXPORT void AddParam(const int num, 0077 const char* const aval, 0078 const Interface_ParamType atype, 0079 const int nument = 0); 0080 0081 //! Same as above, but gets a AsciiString from TCollection 0082 //! Remark that the content of the AsciiString is locally copied 0083 //! (because its content is most often lost after using) 0084 Standard_EXPORT void AddParam(const int num, 0085 const TCollection_AsciiString& aval, 0086 const Interface_ParamType atype, 0087 const int nument = 0); 0088 0089 //! Same as above, but gets a complete FileParameter 0090 //! Warning : Content of <FP> is NOT copied : its original address and space 0091 //! in memory are assumed to be managed elsewhere (see ParamSet) 0092 Standard_EXPORT void AddParam(const int num, const Interface_FileParameter& FP); 0093 0094 //! Sets a new value for a parameter of a record, given by : 0095 //! num : record number; nump : parameter number in the record 0096 Standard_EXPORT void SetParam(const int num, const int nump, const Interface_FileParameter& FP); 0097 0098 //! Returns count of parameters attached to record "num" 0099 //! If <num> = 0, returns the total recorded count of parameters 0100 Standard_EXPORT int NbParams(const int num) const; 0101 0102 //! Returns the complete ParamList of a record (read only) 0103 //! num = 0 to return the whole param list for the file 0104 Standard_EXPORT occ::handle<Interface_ParamList> Params(const int num) const; 0105 0106 //! Returns parameter "nump" of record "num", as a complete 0107 //! FileParameter 0108 Standard_EXPORT const Interface_FileParameter& Param(const int num, const int nump) const; 0109 0110 //! Same as above, but in order to be modified on place 0111 Standard_EXPORT Interface_FileParameter& ChangeParam(const int num, const int nump); 0112 0113 //! Returns type of parameter "nump" of record "num" 0114 //! Returns literal value of parameter "nump" of record "num" 0115 //! was C++ : return const & 0116 Standard_EXPORT Interface_ParamType ParamType(const int num, const int nump) const; 0117 0118 //! Same as above, but as a CString 0119 //! was C++ : return const 0120 Standard_EXPORT const char* ParamCValue(const int num, const int nump) const; 0121 0122 //! Returns True if parameter "nump" of record "num" is defined 0123 //! (it is not if its type is ParamVoid) 0124 Standard_EXPORT bool IsParamDefined(const int num, const int nump) const; 0125 0126 //! Returns record number of an entity referenced by a parameter 0127 //! of type Ident; 0 if no EntityNumber has been determined 0128 //! Note that it is used to reference Entities but also Sublists 0129 //! (sublists are not objects, but internal descriptions) 0130 Standard_EXPORT int ParamNumber(const int num, const int nump) const; 0131 0132 //! Returns the StepEntity referenced by a parameter 0133 //! Error if none 0134 Standard_EXPORT const occ::handle<Standard_Transient>& ParamEntity(const int num, 0135 const int nump) const; 0136 0137 //! Returns the absolute rank of the beginning of a record 0138 //! (its list is from ParamFirstRank+1 to ParamFirstRank+NbParams) 0139 Standard_EXPORT int ParamFirstRank(const int num) const; 0140 0141 //! Returns the entity bound to a record, set by SetEntities 0142 Standard_EXPORT const occ::handle<Standard_Transient>& BoundEntity(const int num) const; 0143 0144 //! Binds an entity to a record 0145 Standard_EXPORT void BindEntity(const int num, const occ::handle<Standard_Transient>& ent); 0146 0147 //! Sets the status "Error Load" on, to overside check fails 0148 //! <val> True : declares unloaded 0149 //! <val> False : declares loaded 0150 //! If not called before loading (see FileReaderTool), check fails 0151 //! give the status 0152 //! IsErrorLoad says if SetErrorLoad has been called by user 0153 //! ResetErrorLoad resets it (called by FileReaderTool) 0154 //! This allows to specify that the currently loaded entity 0155 //! remains unloaded (because of syntactic fail) 0156 Standard_EXPORT void SetErrorLoad(const bool val); 0157 0158 //! Returns True if the status "Error Load" has been set (to True 0159 //! or False) 0160 Standard_EXPORT bool IsErrorLoad() const; 0161 0162 //! Returns the former value of status "Error Load" then resets it 0163 //! Used to read the status then ensure it is reset 0164 Standard_EXPORT bool ResetErrorLoad(); 0165 0166 //! Destructor (waiting for memory management) 0167 Standard_EXPORT void Destroy(); 0168 0169 ~Interface_FileReaderData() override { Destroy(); } 0170 0171 //! Same spec.s as standard <atof> but 5 times faster 0172 Standard_EXPORT static double Fastof(const char* const str); 0173 0174 DEFINE_STANDARD_RTTIEXT(Interface_FileReaderData, Standard_Transient) 0175 0176 protected: 0177 //! Initializes arrays of Entities and of ParamLists attached 0178 //! to registered records 0179 //! <nbr> must be the maximum number of records to get (no way to 0180 //! extend it at run-time) : count entities and sub-entities ... 0181 //! <npar> is the total count of parameters (if it is not exact, 0182 //! it will be extended as necessary) 0183 //! 0184 //! Hence, to each record can be bound an Entity and a list of 0185 //! Parameters. Each kind of FileReaderData can add other data, by 0186 //! having them in parallel (other arrays with same sizes) 0187 //! Else, it must manage binding between items and their data 0188 Standard_EXPORT Interface_FileReaderData(const int nbr, const int npar); 0189 0190 //! Returns a parameter given its absolute rank in the file 0191 //! in order to be consulted or modified in specilaized actions 0192 Standard_EXPORT Interface_FileParameter& ChangeParameter(const int numpar); 0193 0194 //! For a given absolute rank of parameter, determines the 0195 //! record to which its belongs, and the parameter number for it 0196 Standard_EXPORT void ParamPosition(const int numpar, int& num, int& nump) const; 0197 0198 private: 0199 int thenum0; 0200 int therrload; 0201 occ::handle<Interface_ParamSet> theparams; 0202 NCollection_Array1<int> thenumpar; 0203 NCollection_Array1<occ::handle<Standard_Transient>> theents; 0204 }; 0205 0206 #endif // _Interface_FileReaderData_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|