home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / Example Tools / Sources / TMethodNotifierExample.cp < prev    next >
Encoding:
Text File  |  1996-11-19  |  1.6 KB  |  47 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TMethodNotifierExample.cp
  3.  
  4.     Contains:    This module is a very simple example of how to use a TMethodNotifer
  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. #include "TMethodNotifierExample.h"
  12.  
  13.  
  14. /*————————————————————————————————————————————————————————————————————————————————————
  15.     main 
  16.     
  17.     Simple program to demonstrate the use of a TMethodNotifer. It simply creates
  18.     an instance of TMethodNotifer and sets it's notify routine to a method of
  19.     an instance of TNotifyHandler.  We invoke the notify routine by calling the
  20.     TMethodNotifer::Notify method.  The notify routine displays its parameters.
  21.     Normally you will give your TMethodNotifer to someone else who is then
  22.     responsible for calling the Notify method at the appropriate time, but in
  23.     this example we call Notify ourself to keep things simple.
  24. ————————————————————————————————————————————————————————————————————————————————————*/
  25.  
  26. main() 
  27. {    
  28.     TInitSLM initLibraryManager;        // initialize the shared library manager
  29.     
  30.     if( initLibraryManager.Failed() )    // If we failed, let's go home
  31.         return 1;
  32.     
  33.     // create an instance of the class that has the notify method.
  34.     TNotifyHandler myhandler;
  35.  
  36.     // allocate TMethodNotifier, and initialize it with the notify method. Then
  37.     // simply call the notify method indirectly, passing information to it.
  38.     
  39.     TMethodNotifier mynotifier( &myhandler, (NotifyMethodPtr)&TNotifyHandler::MyNotifyMethod);
  40.     
  41.     // invoke the notify routine, and passing it evtCode, err, and data
  42.  
  43.     mynotifier.Notify( 123, 456, (void *)6789 );
  44.     
  45.     return 0;
  46. }
  47.