home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / advanced / collect / colledoc.h < prev    next >
C/C++ Source or Header  |  1998-03-26  |  3KB  |  114 lines

  1. // colledoc.h : interface of the CCollectDoc class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 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 related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. class CMyStruct
  14. {
  15. // Attributes
  16. public:
  17.     int m_int;
  18.     float m_float;
  19.     CString m_str;
  20.  
  21. // Operations
  22. public:
  23.     void FormatMyStruct(CString& str);
  24. };
  25.  
  26. // Note: in order for the specialization to be accepted by the compiler
  27. //  the prototype for SerializeElements (or any other specialization)
  28. //  must be visible when the template is expanded.  It is best to place
  29. //  these declarations in the header file to avoid any unexpected
  30. //  results.
  31.  
  32. #if _MSC_VER > 1020
  33. template <> void AFXAPI SerializeElements<CMyStruct*>(CArchive& ar, CMyStruct** ppElements, int nCount);
  34. #else
  35. void SerializeElements(CArchive& ar, CMyStruct** ppElements, int nCount);
  36. #endif
  37.  
  38. class CMyObject : public CObject
  39. {
  40. public:
  41.     CMyObject();
  42.     DECLARE_SERIAL(CMyObject)
  43.  
  44. // Attributes
  45. public:
  46.     int m_int;
  47.     float m_float;
  48.     CString m_str;
  49.  
  50. // Operations
  51. public:
  52.     void FormatMyObject(CString& str);
  53.  
  54. // Implementation
  55. public:
  56.     virtual ~CMyObject();
  57.     virtual void Serialize(CArchive& ar);
  58. };
  59.  
  60. typedef CTypedPtrList<CPtrList, CMyStruct*> CMyStructList;
  61. typedef CTypedPtrArray<CObArray,CMyObject*> CMyObjectArray;
  62. typedef CTypedPtrMap<CMapStringToOb,CString,CMyObject*> CMapStringToMyObject;
  63. typedef CMap<DWORD,DWORD,CMyStruct*,CMyStruct*&> CMapDWordToMyStruct;
  64.  
  65.  
  66. class CCollectDoc : public CDocument
  67. {
  68. protected: // create from serialization only
  69.     CCollectDoc();
  70.     DECLARE_DYNCREATE(CCollectDoc)
  71.  
  72. // Attributes
  73. public:
  74.     CStringList m_stringList;
  75.     CMyStructList m_mystructList;
  76.     CList<int,int> m_intList;
  77.     CDWordArray m_dwArray;
  78.     CMyObjectArray m_myobArray;
  79.     CArray<CPoint,CPoint> m_ptArray;
  80.     CMapStringToString m_mapStringToString;
  81.     CMapStringToMyObject m_mapStringToMyObject;
  82.     CMapDWordToMyStruct m_mapDWordToMyStruct;
  83.  
  84.  
  85. // Operations
  86.  
  87. // Overrides
  88.     virtual void DeleteContents();
  89.     // ClassWizard generate virtual function overrides
  90.     //{{AFX_VIRTUAL(CCollectDoc)
  91.     protected:
  92.     virtual BOOL OnNewDocument();
  93.     //}}AFX_VIRTUAL
  94.  
  95. // Implementation
  96. public:
  97.     virtual ~CCollectDoc();
  98.     virtual void Serialize(CArchive& ar);   // overridden for document i/o
  99. #ifdef _DEBUG
  100.     virtual void AssertValid() const;
  101.     virtual void Dump(CDumpContext& dc) const;
  102. #endif
  103.  
  104. protected:
  105.  
  106. // Generated message map functions
  107. protected:
  108.     //{{AFX_MSG(CCollectDoc)
  109.     //}}AFX_MSG
  110.     DECLARE_MESSAGE_MAP()
  111. };
  112.  
  113. /////////////////////////////////////////////////////////////////////////////
  114.