home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-11-19 | 2.1 KB | 59 lines | [TEXT/MPS ] |
- /*
- File: TProcNotifierExample.cp
-
- Contains: This module is a very simple example of how to use a TProcNotifer.
-
- Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #include "TInitSLM.h" // the TInitSLM class and SLM include files
-
- ///————————————————————————————————————————————————————————————————————————————————————
- /// PROTOTYPES
- ///————————————————————————————————————————————————————————————————————————————————————
-
- static void MyNotifyProc(void*, EventCode, OSErrParm, void* theData );
-
- /*————————————————————————————————————————————————————————————————————————————————————
- main
-
- Simple program to demonstrate the use of a TProcNotifier. It simply creates an
- instance of TProcNotifier and sets it's notify routine. We invoke the
- notify routine by calling the TProcNotifier::Notify method. The notify routine
- displays its parameters. Normally you will give your TProcNotifier to someone
- else who is then responsible for calling the Notify method at the appropriate
- time, but in this example we call Notify ourself to keep things simple.
-
- ————————————————————————————————————————————————————————————————————————————————————*/
-
- main()
- {
- TInitSLM initLibraryManager; // initialize the shared library manager
-
- if( initLibraryManager.Failed() ) // If we failed, let's go home
- return 1;
-
- // allocate TProcNotifier, and initialize it with the notify routine. Then
- // simply call the notify routine indirectly, passing information to it.
- TProcNotifier ownernotifier(MyNotifyProc);
-
- // invoke the notify routine
-
- ownernotifier.Notify( kDeathEvent, kNoError, &ownernotifier );
-
- return 0;
- }
-
- /*————————————————————————————————————————————————————————————————————————————————————
- MyNotifyProc
-
- this program simply gets called, by the
- ————————————————————————————————————————————————————————————————————————————————————*/
- static void MyNotifyProc(void* refPtr, EventCode evtCode, OSErrParm err, void* theData )
- {
- cout << "MyNotifyProc called with refPtr = " << (void*)refPtr;
- cout << " evtCode = " << (void*)evtCode;
- cout << " err = " << err;
- cout << " theData = " << (void*)theData << endl;
- }