Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:01

0001 // Copyright (c) 2017 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _StdStorage_TypeData_HeaderFile
0015 #define _StdStorage_TypeData_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <Standard_Type.hxx>
0019 
0020 #include <StdStorage_MapOfTypes.hxx>
0021 #include <Storage_Error.hxx>
0022 #include <TCollection_AsciiString.hxx>
0023 #include <Standard_Transient.hxx>
0024 #include <Standard_Integer.hxx>
0025 #include <StdObjMgt_MapOfInstantiators.hxx>
0026 #include <TColStd_HSequenceOfAsciiString.hxx>
0027 class Storage_BaseDriver;
0028 
0029 class StdStorage_TypeData;
0030 DEFINE_STANDARD_HANDLE(StdStorage_TypeData, Standard_Transient)
0031 
0032 //! Storage type data section keeps association between
0033 //! persistent textual types and their numbers
0034 class StdStorage_TypeData
0035   : public Standard_Transient
0036 {
0037   friend class StdStorage_Data;
0038 
0039 public:
0040 
0041   DEFINE_STANDARD_RTTIEXT(StdStorage_TypeData, Standard_Transient)
0042 
0043   //! Reads the type data section from the container defined by theDriver. 
0044   //! Returns Standard_True in case of success. Otherwise, one need to get 
0045   //! an error code and description using ErrorStatus and ErrorStatusExtension
0046   //! functions correspondingly.
0047   Standard_EXPORT Standard_Boolean Read(const Handle(Storage_BaseDriver)& theDriver);
0048 
0049   //! Writes the type data section to the container defined by theDriver. 
0050   //! Returns Standard_True in case of success. Otherwise, one need to get 
0051   //! an error code and description using ErrorStatus and ErrorStatusExtension
0052   //! functions correspondingly.
0053   Standard_EXPORT Standard_Boolean Write(const Handle(Storage_BaseDriver)& theDriver);
0054 
0055   //! Returns the number of registered types
0056   Standard_EXPORT Standard_Integer NumberOfTypes() const;
0057 
0058   //! Add a type to the list in case of reading data
0059   Standard_EXPORT void AddType (const TCollection_AsciiString& aTypeName, const Standard_Integer aTypeNum);
0060 
0061   //! Add a type of the persistent object in case of writing data
0062   Standard_EXPORT Standard_Integer AddType (const Handle(StdObjMgt_Persistent)& aPObj);
0063 
0064   //! Returns the name of the type with number <aTypeNum>
0065   Standard_EXPORT TCollection_AsciiString Type (const Standard_Integer aTypeNum) const;
0066 
0067   //! Returns the name of the type with number <aTypeNum>
0068   Standard_EXPORT Standard_Integer Type (const TCollection_AsciiString& aTypeName) const;
0069 
0070   //! Returns a persistent object instantiator of <aTypeName>
0071   Standard_EXPORT StdObjMgt_Persistent::Instantiator Instantiator(const Standard_Integer aTypeNum) const;
0072   
0073   //! Checks if <aName> is a registered type
0074   Standard_EXPORT Standard_Boolean IsType (const TCollection_AsciiString& aName) const;
0075 
0076   //! Returns a sequence of all registered types
0077   Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) Types() const;
0078   
0079   //! Returns a status of the latest call to Read / Write functions
0080   Standard_EXPORT Storage_Error ErrorStatus() const;
0081   
0082   //! Returns an error message if any of the latest call to Read / Write functions
0083   Standard_EXPORT TCollection_AsciiString ErrorStatusExtension() const;
0084   
0085   //! Clears error status
0086   Standard_EXPORT void ClearErrorStatus();
0087   
0088   //! Unregisters all types
0089   Standard_EXPORT void Clear();
0090 
0091 private:
0092   
0093   Standard_EXPORT StdStorage_TypeData();
0094 
0095   Standard_EXPORT void SetErrorStatus (const Storage_Error anError);
0096   
0097   Standard_EXPORT void SetErrorStatusExtension (const TCollection_AsciiString& anErrorExt);
0098 
0099   Standard_Integer             myTypeId;
0100   StdObjMgt_MapOfInstantiators myMapOfPInst;
0101   StdStorage_MapOfTypes        myPt;
0102   Storage_Error                myErrorStatus;
0103   TCollection_AsciiString      myErrorStatusExt;
0104 
0105 };
0106 
0107 #endif // _StdStorage_TypeData_HeaderFile