home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Apple Shared Library Manager / ASLM Examples / Example Tools / Sources / TProcNotifierExample.cp < prev    next >
Encoding:
Text File  |  1996-11-19  |  2.1 KB  |  59 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TProcNotifierExample.cp
  3.  
  4.     Contains:    This module is a very simple example of how to use a TProcNotifer.
  5.  
  6.     Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10. #include "TInitSLM.h"            // the TInitSLM class and SLM include files
  11.  
  12. ///————————————————————————————————————————————————————————————————————————————————————
  13. /// PROTOTYPES
  14. ///————————————————————————————————————————————————————————————————————————————————————
  15.  
  16. static void MyNotifyProc(void*, EventCode, OSErrParm, void* theData );
  17.  
  18. /*————————————————————————————————————————————————————————————————————————————————————
  19.     main 
  20.     
  21.     Simple program to demonstrate the use of a TProcNotifier. It simply creates an
  22.     instance of TProcNotifier and sets it's notify routine. We invoke the 
  23.     notify routine by calling the TProcNotifier::Notify method. The notify routine
  24.     displays its parameters. Normally you will give your TProcNotifier to someone
  25.     else who is then responsible for calling the Notify method at the appropriate
  26.     time, but in this example we call Notify ourself to keep things simple.
  27.     
  28. ————————————————————————————————————————————————————————————————————————————————————*/
  29.  
  30. main() 
  31. {    
  32.     TInitSLM initLibraryManager;            // initialize the shared library manager
  33.     
  34.     if( initLibraryManager.Failed() )    // If we failed, let's go home
  35.         return 1;
  36.         
  37.     // allocate TProcNotifier, and initialize it with the notify routine. Then
  38.     // simply call the notify routine indirectly, passing information to it.
  39.     TProcNotifier ownernotifier(MyNotifyProc);
  40.     
  41.     // invoke the notify routine
  42.  
  43.     ownernotifier.Notify( kDeathEvent, kNoError, &ownernotifier );
  44.     
  45.     return 0;
  46. }
  47.  
  48. /*————————————————————————————————————————————————————————————————————————————————————
  49.     MyNotifyProc
  50.     
  51.     this program simply gets called, by the 
  52. ————————————————————————————————————————————————————————————————————————————————————*/
  53. static void MyNotifyProc(void* refPtr, EventCode evtCode, OSErrParm err, void* theData )
  54. {
  55.     cout << "MyNotifyProc called with refPtr = " << (void*)refPtr;
  56.     cout << " evtCode = " << (void*)evtCode;
  57.     cout << " err = " << err;
  58.     cout << " theData = " << (void*)theData << endl;
  59. }