home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / Example Tools / Sources / TInitSLM.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-19  |  1.8 KB  |  76 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TInitSLM.h
  3.  
  4.     Contains:    Contains the declaration and implementation of the TInitSLM class.
  5.                 It also #includes all of the Shared Library Manager interface files
  6.                 we will need.
  7.  
  8.     Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11.  
  12. #ifndef __TINITSLM__
  13. #define __TINITSLM__
  14.  
  15. #ifndef __GLOBALNEW__
  16. #include <GlobalNew.h>    // this will make all of our "news" allocate out of memory pools
  17. #endif
  18.  
  19. #ifndef __LIBRARYMANAGERCLASSES__
  20. #include <LibraryManagerClasses.h>
  21. #endif
  22.  
  23. #ifndef __LIBRARYMANAGERUTILITIES__
  24. #include <LibraryManagerUtilities.h>
  25. #endif
  26.  
  27. #ifndef __STDIO__
  28. #include <stdio.h>
  29. #endif
  30.  
  31. #ifndef __STRING__
  32. #include <string.h>
  33. #endif
  34.  
  35. #ifndef __IOSTREAM__
  36. #include <iostream.h>
  37. #endif
  38.  
  39. ///————————————————————————————————————————————————————————————————————————————————————
  40. ///    TInitSLM
  41. ///
  42. /// This class initializes Shared Library Manager when it is constructed and cleans
  43. /// up when it is destroyed.
  44. ///————————————————————————————————————————————————————————————————————————————————————
  45.  
  46. class TInitSLM {
  47.     
  48.     public:
  49.                     TInitSLM();        // initialize the shared library manager
  50.         virtual     ~TInitSLM();    // cleanup and dispose our local TLibraryManager
  51.         Boolean Failed() const { return (fSuccess == false); } // true if we failed
  52.     protected:
  53.         Boolean    fSuccess;            // indicate if InitLibraryManager call succeeded
  54. };
  55.  
  56. ///————————————————————————————————————————————————————————————————————————————————————
  57. ///    TInitSLM IMLEMENTATION
  58. ///————————————————————————————————————————————————————————————————————————————————————
  59.  
  60.     TInitSLM::TInitSLM()
  61.     {
  62.         fSuccess = false;
  63.         if( InitLibraryManager() == noErr )
  64.             if( GetLocalLibraryManager() )
  65.                 fSuccess = true;
  66.     }
  67.  
  68.     TInitSLM::~TInitSLM()
  69.     {
  70.         if( fSuccess )
  71.             CleanupLibraryManager();
  72.         else
  73.             cout << "Sorry, failed to initialize/load the Shared Library Manager" << endl;
  74.     }
  75.  
  76. #endif