home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK11 / MFC / SAMPLES / TESTSERV / SERVDOC.CP$ / servdoc
Encoding:
Text File  |  1992-03-07  |  2.7 KB  |  117 lines

  1. // servdoc.cpp : This file contains code which implements the pure
  2. //  virtual functions for CServDoc which inherits from COleServerDoc.
  3. //
  4. // This is a part of the Microsoft Foundation Classes C++ library.
  5. // Copyright (C) 1992 Microsoft Corporation
  6. // All rights reserved.
  7. //
  8. // This source code is only intended as a supplement to the
  9. // Microsoft Foundation Classes Reference and Microsoft
  10. // QuickHelp documentation provided with the library.
  11. // See these sources for detailed information regarding the
  12. // Microsoft Foundation Classes product.
  13.  
  14.  
  15. #include "testserv.h"
  16.  
  17. static CString GLOBAL_szItemName = "TestServ";
  18. extern void OutputLog(const char* pText);
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CServDoc::CServDoc
  22. //
  23. CServDoc::CServDoc(LPCSTR lpszDoc)
  24. {
  25.     m_DocName = lpszDoc;
  26.     m_pItem = NULL;
  27. }
  28.  
  29.  
  30.  
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CServDoc::OnGetItem(LPCSTR lpszObjname)
  33. //
  34. COleServerItem* CServDoc::OnGetItem(LPCSTR lpszObjname)
  35. {
  36.     ASSERT_VALID(this);
  37.     ASSERT(lpszObjname != NULL);
  38.  
  39.     if (m_pItem == NULL)
  40.     {
  41.         m_pItem = new CServItem((CTestServer*)AfxGetApp()->m_pMainWnd,
  42.                     this, m_DocName, lpszObjname);
  43.     }
  44.  
  45.     return m_pItem;
  46. }
  47.  
  48.  
  49.  
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CServDoc::OnGetDocument()
  53. //
  54. COleServerItem* CServDoc::OnGetDocument()
  55. {
  56.     ASSERT_VALID(this);
  57.  
  58.     // we return only the one object we have
  59.     TRACE("CServDoc::OnGetDocument\n");
  60.  
  61.     TRACE("The current CServDoc.m_pItem is:  %x\n",m_pItem);
  62.     if (m_pItem == NULL)
  63.     {
  64.         TRACE("We are about to create a new Item:  %x\n",m_pItem);
  65.         m_pItem = new CServItem((CTestServer*)AfxGetApp()->m_pMainWnd,
  66.                     this, m_DocName, NULL);
  67.     }
  68.  
  69.     TRACE("Returning New Item as %x\n",m_pItem);
  70.     return m_pItem;
  71. }
  72.  
  73.  
  74.  
  75.  
  76. /////////////////////////////////////////////////////////////////////////////
  77. // CServDoc::GetNextItem(POSITION &rPosition)
  78. //
  79. COleServerItem* CServDoc::GetNextItem(POSITION &rPosition)
  80. {
  81.     if (rPosition == NULL)
  82.     {
  83.         rPosition = (POSITION) 1;
  84.         return m_pItem;
  85.     }
  86.     else
  87.     {
  88.         return NULL;
  89.     }
  90. }
  91.  
  92.  
  93. #ifdef _DEBUG
  94. /////////////////////////////////////////////////////////////////////////////
  95. // CServDoc::AssertValid() const
  96. //
  97. void CServDoc::AssertValid() const
  98. {
  99.     COleServerDoc::AssertValid();
  100. }
  101.  
  102.  
  103.  
  104.  
  105. /////////////////////////////////////////////////////////////////////////////
  106. // CServDoc::Dump(CDumpContext &dc) const
  107. //
  108. void CServDoc::Dump (CDumpContext &dc) const
  109. {
  110.     dc << "\nCServDoc Dump Beginning";
  111.     COleServerDoc::Dump(dc);
  112.     dc << "\nCServItem object at " << m_pItem;
  113. }
  114. #endif
  115.  
  116. /////////////////////////////////////////////////////////////////////////////
  117.