home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SAMPLES / CHKBOOK / FXRECDOC.H_ / FXRECDOC.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  2.8 KB  |  88 lines

  1. // fxrecdoc.h : interface of the CFixedLenRecDoc and CFixedLenRecHint classes
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and Microsoft
  9. // QuickHelp and/or WinHelp documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. // CFixedLenRecDoc implements the behavior of a transaction-based
  14. // document in which each record has a fixed size.  The file has
  15. // a fixed-length header.  The derived class can specify the length
  16. // of an extra header, that is, a header in addition to that required
  17. // by CFixedLenRecDoc.  This is an abstract class that must be
  18. // derived from.
  19. /////////////////////////////////////////////////////////////////////////////
  20.  
  21. class CFixedLenRecHint : public CObject
  22. {
  23.     DECLARE_DYNAMIC(CFixedLenRecHint)
  24. public:
  25.     CFixedLenRecHint();
  26. };
  27.  
  28.  
  29. class CFixedLenRecDoc : public CDocument
  30. {
  31.     DECLARE_DYNAMIC(CFixedLenRecDoc)
  32. public:
  33.     CFixedLenRecDoc(); 
  34.  
  35. protected:
  36.     
  37.     CFile m_file;       // The file is kept open to do read/writes on per
  38.                         // transaction basis.
  39.  
  40.     // The following header, and optional extra header implemented
  41.     // in the derived class, are updated each time a new record is 
  42.     // added, or WriteHeader() is called.
  43.  
  44.     struct
  45.     {
  46.         UINT nRecordCount;          // count of records in the file
  47.         UINT nRecordLength;         // length of fixed-length records
  48.         UINT nExtraHeaderLength;    // length of additional header written
  49.                                     // by derived class
  50.     } m_header;
  51.  
  52. // Overridables
  53.     virtual void* OnCreateNewRecord(int nNewRecordIndex) = 0;   
  54.                                     // returns pointer to new record
  55.     virtual BOOL OnReadExtraHeader();
  56.     virtual void OnWriteExtraHeader(BOOL bNewHeader);
  57.     
  58. // Operations
  59. public:
  60.     virtual void WriteHeader(CFile* pFile, BOOL bNewHeader);
  61.     virtual BOOL ReadHeader(CFile* pFile);  
  62.                                 // returns FALSE if file can't be interpreted
  63.  
  64.     // Operations used by views
  65.     virtual UINT CreateNewRecord(); // creates a new record 
  66.     UINT GetRecordCount() 
  67.         { return m_header.nRecordCount; }
  68.     virtual void GetRecord(UINT nRecordIndex, void* pRecord);
  69.     virtual void UpdateRecord(CView* pSourceView, UINT nRecordIndex, 
  70.         void* pRecord); 
  71.     virtual void UpdateAllViewsWithRecord(CView* pSourceView, 
  72.         UINT nRecordIndex); 
  73.  
  74. // Implementation
  75. protected:
  76.     // Overrides of CDocument member functions
  77.     virtual BOOL OnOpenDocument(const char* pszPathName);   
  78.                                     // reopen file using m_file
  79.     virtual void DeleteContents();  // closes the m_file
  80.     
  81.     virtual void FileSeekRecord(UINT nRecord);
  82.     
  83. public:
  84.     virtual ~CFixedLenRecDoc();
  85.     virtual void Serialize(CArchive& ar);
  86. };
  87.  
  88.