home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / xpcom / src / nsRepository.h < prev   
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.5 KB  |  100 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef __nsRespository_h
  20. #define __nsRespository_h
  21.  
  22. #include "prtypes.h"
  23. #include "prmon.h"
  24. #include "nsCom.h"
  25. #include "nsID.h"
  26. #include "nsISupports.h"
  27. #include "nsIFactory.h"
  28. #include "nsHashtable.h"
  29.  
  30. /*
  31.  * NSIRepository class
  32.  */
  33.  
  34. // Errors
  35. #define NS_ERROR_FACTORY_EXISTS               (NS_ERROR_BASE + 0x100)
  36. #define NS_ERROR_FACTORY_NOT_REGISTERED       (NS_ERROR_BASE + 0x101)
  37. #define NS_ERROR_FACTORY_NOT_LOADED           (NS_ERROR_BASE + 0x102)
  38. #define NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT (NS_ERROR_BASE + 0x103)
  39. #define NS_ERROR_FACTORY_NOT_UNREGISTERED     (NS_ERROR_BASE + 0x104)
  40.  
  41. typedef nsresult (*nsFactoryProc)(const nsCID &aCLass,
  42.                                   nsIFactory **aFactory);
  43. typedef PRBool (*nsCanUnloadProc)();
  44. typedef nsresult (*nsRegisterProc)(const char *path);
  45. typedef nsresult (*nsUnregisterProc)(const char *path);
  46.  
  47. class FactoryEntry;
  48.  
  49. class NS_COM NSRepository {
  50. private:
  51.   static nsHashtable *factories;
  52.   static PRMonitor *monitor;
  53.  
  54.   static nsresult checkInitialized();
  55.  
  56. public:
  57.   static nsresult Initialize();
  58.  
  59.   // Finds a factory for a specific class ID
  60.   static nsresult FindFactory(const nsCID &aClass,
  61.                               nsIFactory **aFactory);
  62.  
  63.   // Creates a class instance for a specific class ID
  64.   static nsresult CreateInstance(const nsCID &aClass, 
  65.                                  nsISupports *aDelegate,
  66.                                  const nsIID &aIID,
  67.                                  void **aResult);
  68.  
  69.   // Creates a class instance for a specific class ID
  70.   static nsresult CreateInstance2(const nsCID &aClass, 
  71.                                   nsISupports *aDelegate,
  72.                                   const nsIID &aIID,
  73.                                   void *aSignature,
  74.                                   void **aResult);
  75.  
  76.   // Manually registry a factory for a class
  77.   static nsresult RegisterFactory(const nsCID &aClass,
  78.                                   nsIFactory *aFactory,
  79.                                   PRBool aReplace);
  80.  
  81.   // Manually registry a dynamically loaded factory for a class
  82.   static nsresult RegisterFactory(const nsCID &aClass,
  83.                                   const char *aLibrary,
  84.                                   PRBool aReplace,
  85.                                   PRBool aPersist);
  86.  
  87.   // Manually unregister a factory for a class
  88.   static nsresult UnregisterFactory(const nsCID &aClass,
  89.                                     nsIFactory *aFactory);
  90.  
  91.   // Manually unregister a dynamically loaded factory for a class
  92.   static nsresult UnregisterFactory(const nsCID &aClass,
  93.                                     const char *aLibrary);
  94.  
  95.   // Unload dynamically loaded factories that are not in use
  96.   static nsresult FreeLibraries();
  97. };
  98.  
  99. #endif
  100.