home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / idocstor.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  7.6 KB  |  200 lines

  1. /*******************************************************************************
  2. * FILE NAME: idocstor.hpp                                                      *
  3. *                                                                              *
  4. * DESCRIPTION:                                                                 *
  5. *   Declaration of the classes:                                                *
  6. *     IDocumentStorage                                                         *
  7. *     IStructuredStorage                                                       *
  8. *     IFlatFileStorage                                                         *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM Open Class Library                                                     *
  12. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  13. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18. #ifndef _IDOCSTOR_
  19. #define _IDOCSTOR_
  20.  
  21. #include <ivbase.hpp>
  22. #include <istring.hpp>
  23.  
  24. // forward references
  25. class IComponent;
  26. class IModel;
  27. class IEmbedderModel;
  28. class CAswStream;
  29. class CAswStorage;
  30. class CAswDocFileStorage;
  31.  
  32. // Classes defined in this module
  33. class IDocumentStorage;
  34. class IFlatFileStorage;
  35. class IStructuredStorage;
  36.  
  37. #pragma pack(4)
  38.  
  39.  
  40. /*******************************************************************************
  41. *                                                                              *
  42. *   The IDocumentStorage class is an abstract base class for managing          *
  43. *   the file representation of an IComponent.  Two concrete subclasses,        *
  44. *   IStructuredStorage and IFlatFileStorage derive from IDocumentStorage.      *
  45. *                                                                              *
  46. *******************************************************************************/
  47.  
  48. class IDocumentStorage : public IVBase {
  49. public:
  50.  
  51. /*----------------------- Construction/Destruction ---------------------------*/
  52.  
  53.     virtual                 ~IDocumentStorage();
  54.  
  55.  
  56. /*------------------------------- File I/O -----------------------------------*/
  57.  
  58.     virtual void            loadFile(const IString& name) = 0;
  59.     virtual void            saveFile(const IString& name,
  60.                                      Boolean sameAsLoad,
  61.                                      Boolean remember) = 0;
  62.  
  63.  
  64. /*--------------------------- Title Components -------------------------------*/
  65.  
  66.     virtual void            setFileName(const IString& name);
  67.  
  68.  
  69. /*----------------------------- Informational --------------------------------*/
  70.  
  71.     const IString&          fileName() const;
  72.     IComponent&             component() const;
  73.  
  74.  
  75. #ifdef IC_LIBRARYUSEONLY
  76.     IString                 fileToUse( const char* name ) const;
  77.  
  78.     CAswStorage*            storage() const;
  79.     virtual void            setStorage( CAswStorage* );
  80.     virtual void            loadStorage( CAswStorage*, CAswStream* );
  81.     virtual void            saveStorage( CAswStorage* stor,
  82.                                          CAswStream* strm,
  83.                                          Boolean sameAsLoad,
  84.                                          Boolean remember ) const;
  85. #endif // IC_LIBRARYUSEONLY
  86.  
  87. protected:
  88.                             IDocumentStorage( IComponent& );
  89.                             IDocumentStorage( const IDocumentStorage& );
  90.  
  91. #ifdef IC_LIBRARYUSEONLY
  92.     // Helper functions
  93.     virtual void            resetFile();
  94.  
  95. #endif // IC_LIBRARYUSEONLY
  96.  
  97. private:
  98.     IDocumentStorage&       operator=( const IDocumentStorage& );
  99.  
  100.     IString                 fFileName;
  101.     IComponent*             fpComponent;
  102.     CAswStorage*            fpStorage;
  103.  
  104. };
  105.  
  106.  
  107. /*******************************************************************************
  108. *                                                                              *
  109. *   The IFlatFileStorage class stores the document model in a flat file.       *
  110. *   It can only be used for stand-alone servers that do not support            *
  111. *   embedding (i.e. non containers).                                           *
  112. *                                                                              *
  113. *******************************************************************************/
  114.  
  115. class IFlatFileStorage : public IDocumentStorage {
  116. public:
  117.  
  118. /*----------------------- Construction/Destruction ---------------------------*/
  119.  
  120.                             IFlatFileStorage( IComponent& );
  121.     virtual                 ~IFlatFileStorage();
  122.  
  123.  
  124. /*------------------------------- File I/O -----------------------------------*/
  125.  
  126.     virtual void            loadFile(const IString& name);
  127.     virtual void            saveFile(const IString& name,
  128.                                      Boolean sameAsLoad,
  129.                                      Boolean remember);
  130.  
  131. protected:
  132.                             IFlatFileStorage( const IFlatFileStorage& );
  133.  
  134. private:
  135.     IFlatFileStorage&       operator=( const IFlatFileStorage& );
  136.  
  137. };
  138.  
  139.  
  140. /*******************************************************************************
  141. *                                                                              *
  142. *   The IStructuredStorage class stores the document model in an OLE           *
  143. *   Doc File.                                                                  *
  144. *                                                                              *
  145. *******************************************************************************/
  146.  
  147. class IStructuredStorage : public IDocumentStorage {
  148. public:
  149.  
  150. /*----------------------- Construction/Destruction ---------------------------*/
  151.  
  152.                             IStructuredStorage( IComponent&, IEmbedderModel* );
  153.     virtual                 ~IStructuredStorage();
  154.  
  155.  
  156. /*------------------------------- File I/O -----------------------------------*/
  157.  
  158.     virtual void            loadFile(const IString& name);
  159.     virtual void            saveFile(const IString& name,
  160.                                      Boolean sameAsLoad,
  161.                                      Boolean remember);
  162.  
  163. #ifdef IC_LIBRARYUSEONLY
  164.     virtual void            setStorage( CAswStorage* );
  165.  
  166.     virtual void            loadStorage( CAswStorage*, CAswStream* );
  167.     virtual void            saveStorage( CAswStorage* stor,
  168.                                          CAswStream* strm,
  169.                                          Boolean sameAsLoad,
  170.                                          Boolean remember ) const;
  171. #endif
  172.  
  173. protected:
  174.                             IStructuredStorage( const IStructuredStorage& );
  175.  
  176. #ifdef IC_LIBRARYUSEONLY
  177.     // Helper functions
  178.     virtual void            resetFile();
  179.     virtual void            loadEmbeddedComponents( CAswStorage* );
  180.     virtual void            saveEmbeddedComponents( CAswStorage*,
  181.                                                     Boolean,
  182.                                                     Boolean ) const;
  183. #endif
  184.  
  185. private:
  186.     IStructuredStorage&     operator=( const IStructuredStorage& );
  187.  
  188.     CAswDocFileStorage*     fpDocFile;
  189.     CAswStorage*            fpRootStorage;
  190.  
  191. };
  192.  
  193.   #include <idocstor.inl>
  194.  
  195.  
  196. #pragma pack()
  197.  
  198.  
  199. #endif // _IDOCSTOR_
  200.