Back to home page

EIC code displayed by LXR

 
 

    


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

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