Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/StdObjMgt_WriteData.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 _StdObjMgt_WriteData_HeaderFile
0015 #define _StdObjMgt_WriteData_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <Storage_BaseDriver.hxx>
0019 
0020 class StdObjMgt_Persistent;
0021 class Standard_GUID;
0022 
0023 //! Auxiliary data used to write persistent objects to a file.
0024 class StdObjMgt_WriteData
0025 {
0026 public:
0027 
0028   //! Auxiliary class used to automate begin and end of
0029   //! writing object (adding opening and closing parenthesis)
0030   //! at constructor and destructor
0031   class ObjectSentry
0032   {
0033   public:
0034     explicit ObjectSentry (StdObjMgt_WriteData& theData) : myWriteData(&theData)
0035     { myWriteData->myDriver->BeginWriteObjectData(); }
0036 
0037     ~ObjectSentry()
0038     { myWriteData->myDriver->EndWriteObjectData(); }
0039 
0040   private:
0041     StdObjMgt_WriteData* myWriteData;
0042 
0043     ObjectSentry (const ObjectSentry&);
0044     ObjectSentry& operator = (const ObjectSentry&);
0045   };
0046 
0047   Standard_EXPORT StdObjMgt_WriteData (const Handle(Storage_BaseDriver)& theDriver);
0048 
0049   Standard_EXPORT void WritePersistentObject (const Handle(StdObjMgt_Persistent)& thePersistent);
0050 
0051   template <class Persistent>
0052   StdObjMgt_WriteData& operator << (const Handle(Persistent)& thePersistent)
0053   {
0054     myDriver->PutReference(thePersistent ? thePersistent->RefNum() : 0);
0055     return *this;
0056   }
0057 
0058   Standard_EXPORT StdObjMgt_WriteData& operator << (const Handle(StdObjMgt_Persistent)& thePersistent);
0059 
0060   template <class Type>
0061   StdObjMgt_WriteData& WriteValue(const Type& theValue)
0062   {
0063     *myDriver << theValue;
0064     return *this;
0065   }
0066 
0067   StdObjMgt_WriteData& operator << (const Standard_Character& theValue)
0068     { return WriteValue(theValue); }
0069   
0070   StdObjMgt_WriteData& operator << (const Standard_ExtCharacter& theValue)
0071     { return WriteValue(theValue); }
0072   
0073   StdObjMgt_WriteData& operator << (const Standard_Integer& theValue)
0074    { return WriteValue(theValue); }
0075   
0076   StdObjMgt_WriteData& operator << (const Standard_Boolean& theValue)
0077     { return WriteValue(theValue); }
0078   
0079   StdObjMgt_WriteData& operator << (const Standard_Real& theValue)
0080    { return WriteValue(theValue); }
0081   
0082   StdObjMgt_WriteData& operator << (const Standard_ShortReal& theValue)
0083     { return WriteValue(theValue); }
0084 
0085 private:
0086   Handle(Storage_BaseDriver) myDriver;
0087 };
0088 
0089 Standard_EXPORT StdObjMgt_WriteData& operator <<
0090   (StdObjMgt_WriteData& theWriteData, const Standard_GUID& theGUID);
0091 
0092 #endif // _StdObjMgt_WriteData_HeaderFile