home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextLibrary / Frameworks / NEXTIME.framework / Versions / A / Headers / NTContext.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-05  |  2.9 KB  |  108 lines

  1. #import <Foundation/NSObject.h>
  2. #import <Foundation/NSString.h>
  3. #import <Foundation/NSThread.h>
  4. #import <Foundation/NSLock.h>
  5. #import <Foundation/NSZone.h>
  6. #import "NTDictionaryKeys.h"
  7. #import "NTComponentManager.h"
  8. #import "NTErrorMonitor.h"
  9.  
  10. // Protocol for context client.  Used for keepalive pings
  11. @protocol NTClient
  12. - (void)pingClient;
  13. @end
  14. // Protocol for the NTContext API that we export for use by the NTClient
  15. // object.
  16. @protocol NTContext <NTErrorGenerator>
  17. - (NTComponentManager *)componentManager;
  18. - (void)pingServer:(id <NTClient>)client;    // target for keepalive pings from client
  19. @end
  20.  
  21. /* NSNotification names */
  22. extern NSString *NTContextWillTerminateNotification;
  23.  
  24. /*
  25.  * A class for representing a context within the NT server.
  26.  * Contexts are associated with a specific client connection.
  27.  * Each context holds a zone used for all memory allocation within the
  28.  * context.  One or more cthreads may share a context.
  29.  *
  30.  * Contexts also hold generally useful context dependent information, including
  31.  * a Component Manager instance.
  32.  *
  33.  */
  34. @interface NTContext: NSObject <NTContext>
  35. {
  36. @private
  37.     int            _refcount;
  38.     NSLock            *contextLock;
  39.     NSLock            *zoneLock;
  40.     NTComponentManager    *componentManager;
  41.     NSZone *        sampleZone;
  42.     NSZone *        zone;
  43.     NSString *        name;
  44.     id <NTErrorMonitor>    errorMonitor;
  45.     BOOL            connIsOK;
  46. }
  47.  
  48. //
  49. // Construct a new context, running in a new thread, and return the name
  50. // it is advertised with.  This is the factory through which all new
  51. // contexts are normally constructed.
  52. //
  53. + (NSString *)nameForNewContext;
  54.  
  55. /* Create a new context, with a new zone */
  56. + new;
  57.  
  58. /* Return the current context instance. */
  59. + (NTContext *)currentContext;
  60.  
  61. /*
  62.  * Return the root context instance, used to hold
  63.  * everything not claimed by other contexts.
  64.  */
  65. + (NTContext *)rootContext;
  66. /*
  67.  * Add a thread to a context. If the thread is a member of another context
  68.  * that context is dereferenced, possibly freeing it.
  69.  */
  70. + (void)addThread:(NSThread *)thread toContext:(NTContext *)context;
  71. + (void)removeThread:(NSThread *)thread;
  72.  
  73. /* Support for creating new contexts and service threads on new connections */
  74. - (void)runConnection;
  75.  
  76. - init;
  77. - (void)dealloc;
  78. - (NSZone *)zone;
  79.  
  80. - (NSZone *)sampleZone;    // Return playback zone, creating it if needed.
  81. - (void)freeSampleZone;    // Destroy the playback zone and it's contents
  82. - (void)wireSampleZone;    // Try to make the zone's pages resident
  83. - (void)unwireSampleZone;    // Try to make the zone's pages non-resident
  84.  
  85. - (NSLock *)zoneLock;
  86.  
  87. - (NSString *)name;
  88.  
  89. - (void)postErrorTitle:(NSString *)title
  90.     message:(NSString *)msg
  91.     details:(NSString *)details
  92.     errorCode:(NSString *)code;
  93.  
  94. - (void)postErrorForClass:(id)class
  95.     title:(NSString *)title
  96.     prefix:(NSString *)prefix
  97.     filename:(NSString *)file
  98.     message:(NSString *)message
  99.     details:(NSString *)details
  100.     errorCode:(NSString *)code;
  101.  
  102. @end
  103.  
  104. // Interesting messages a context can send to registered objects
  105. @interface NSObject(NTContextEvents)
  106. - (void)contextWillTerminate:(id)sender;
  107. @end
  108.