home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / tutsamp / dllserve / server.cpp < prev    next >
C/C++ Source or Header  |  1997-08-05  |  5KB  |  180 lines

  1. /*+==========================================================================
  2.   File:      SERVER.CPP
  3.  
  4.   Summary:   Implementation file for the CServer server-related utility
  5.              C++ object.  This object encapsulates the server's internal
  6.              control of global server object and lock counts.
  7.  
  8.              For a comprehensive tutorial code tour of this module's
  9.              contents and offerings see the tutorial DLLSERVE.HTM file.
  10.              For more specific technical details on the internal workings
  11.              see the comments dispersed throughout the module's source code.
  12.  
  13.   Classes:   CServer.
  14.  
  15.   Functions:
  16.  
  17.   Origin:    9-11-95: atrent - Editor-inheritance from COMOBJ.CPP in
  18.                the COMOBJ Tutorial Code Sample.
  19.  
  20. ----------------------------------------------------------------------------
  21.   This file is part of the Microsoft COM Tutorial Code Samples.
  22.  
  23.   Copyright (C) Microsoft Corporation, 1997.  All rights reserved.
  24.  
  25.   This source code is intended only as a supplement to Microsoft
  26.   Development Tools and/or on-line documentation.  See these other
  27.   materials for detailed information regarding Microsoft code samples.
  28.  
  29.   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  30.   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  31.   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  32.   PARTICULAR PURPOSE.
  33. ==========================================================================+*/
  34.  
  35. /*---------------------------------------------------------------------------
  36.   We include WINDOWS.H for all Win32 applications.
  37.   We include OLE2.H because we will be calling the COM/OLE Libraries.
  38.   We include APPUTIL.H because we will be building this DLL using
  39.     the convenient Virtual Window and Dialog classes and other
  40.     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
  41.   We include SERVER.H for the object class declarations for the
  42.     C++ CServer server control object.
  43. ---------------------------------------------------------------------------*/
  44. #include <windows.h>
  45. #include <ole2.h>
  46. #include <apputil.h>
  47. #include "server.h"
  48.  
  49.  
  50. /*---------------------------------------------------------------------------
  51.   Implementation the internal CServer C++ object.  Used to encapsulate
  52.   some server data and the methods for Lock and Object count incrementing
  53.   and decrementing.
  54. ---------------------------------------------------------------------------*/
  55.  
  56. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  57.   Method:   CServer::CServer
  58.  
  59.   Summary:  CServer Constructor.
  60.  
  61.   Args:     void
  62.  
  63.   Modifies: .
  64.  
  65.   Returns:  void
  66. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  67. CServer::CServer(void)
  68. {
  69.   m_hDllInst = NULL;
  70.   m_hWndParent = NULL;
  71.   m_pMsgBox = NULL;
  72.  
  73.   // Zero the Object and Lock counts for this attached process.
  74.   m_cObjects = 0;
  75.   m_cLocks = 0;
  76.  
  77.   return;
  78. }
  79.  
  80.  
  81. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  82.   Method:   CServer::~CServer
  83.  
  84.   Summary:  CServer Destructor.
  85.  
  86.   Args:     void
  87.  
  88.   Modifies: .
  89.  
  90.   Returns:  void
  91. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  92. CServer::~CServer(void)
  93. {
  94.   return;
  95. }
  96.  
  97.  
  98. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  99.   Method:   CServer::Lock
  100.  
  101.   Summary:  Increment the Server's Lock count.
  102.  
  103.   Args:     void
  104.  
  105.   Modifies: .
  106.  
  107.   Returns:  void
  108. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  109. void CServer::Lock(void)
  110. {
  111.   InterlockedIncrement((PLONG) &m_cLocks);
  112.  
  113.   LOGF1("S: CServer::Lock. New cLocks=%i.", m_cLocks);
  114.  
  115.   return;
  116. }
  117.  
  118.  
  119. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  120.   Method:   CServer::Unlock
  121.  
  122.   Summary:  Decrement the Server's Lock count.
  123.  
  124.   Args:     void
  125.  
  126.   Modifies: .
  127.  
  128.   Returns:  void
  129. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  130. void CServer::Unlock(void)
  131. {
  132.   InterlockedDecrement((PLONG) &m_cLocks);
  133.  
  134.   LOGF1("S: CServer::Unlock. New cLocks=%i.", m_cLocks);
  135.  
  136.   return;
  137. }
  138.  
  139.  
  140. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  141.   Method:   CServer::ObjectsUp
  142.  
  143.   Summary:  Increment the Server's living Object count.
  144.  
  145.   Args:     void
  146.  
  147.   Modifies: .
  148.  
  149.   Returns:  void
  150. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  151. void CServer::ObjectsUp(void)
  152. {
  153.   InterlockedIncrement((PLONG) &m_cObjects);
  154.  
  155.   LOGF1("S: CServer::ObjectsUp. New cObjects=%i.", m_cObjects);
  156.  
  157.   return;
  158. }
  159.  
  160.  
  161. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  162.   Method:   CServer::ObjectsDown
  163.  
  164.   Summary:  Decrement the Server's living object count.
  165.  
  166.   Args:     void
  167.  
  168.   Modifies: .
  169.  
  170.   Returns:  void
  171. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  172. void CServer::ObjectsDown(void)
  173. {
  174.   InterlockedDecrement((PLONG) &m_cObjects);
  175.  
  176.   LOGF1("S: CServer::ObjectsDown. New cObjects=%i.", m_cObjects);
  177.  
  178.   return;
  179. }
  180.