/Volumes/Plantain/MyDocuments/Projects/MacTrek/MacTrek/Luky/Comm/LLNotificationCenter.h

00001 //
00002 //  LLNotificationCenter.h
00003 //  MacTrek
00004 //
00005 //  Created by Aqua on 27/04/2006.
00006 //  Copyright 2006 __MyCompanyName__. All rights reserved.
00007 //
00008 
00009 #import <Cocoa/Cocoa.h>
00010 #import "LLNotificationCenterEntry.h"
00011 #import "LLDOSender.h"
00012 #import "LLDOReceiver.h"
00013 
00014 // very simple notification centre, but also very fast
00015 // allows any kind of payload, even a dictionairy
00016 
00017 // to make thread safe call setUseLocks:YES (default off)
00018 // to make thread safe for a single observer use the appropriate addObserver
00019 // don't forget to set the lock timeout (default 2 seconds)
00020 
00021 @interface LLNotificationCenter : NSObject {
00022 
00023     NSMutableArray *listeners;
00024     bool useLocks;
00025     int timeOut;
00026 }
00027 
00028 // must be called from the main event loop!
00029 + (LLNotificationCenter*) defaultCenter;
00030 
00031 - (void)addObserver:(id)notificationObserver            // cannot be nil
00032            selector:(SEL)notificationSelector           // cannot be nil
00033                name:(NSString *)notificationName;       // nil means all
00034 
00035 - (void)addObserver:(id)notificationObserver            // cannot be nil
00036            selector:(SEL)notificationSelector           // cannot be nil
00037                name:(NSString *)notificationName        // nil means all
00038              object:(NSString *)notificationSender;     // nil means of all
00039 
00040 - (void)addObserver:(id)notificationObserver            // cannot be nil
00041            selector:(SEL)notificationSelector           // cannot be nil
00042                name:(NSString *)notificationName        // nil means all
00043              object:(NSString *)notificationSender      // nil means of all
00044            useLocks:(bool)protect;                      // set to YES for multi thread safe
00045 
00046 
00047 - (void)addObserver:(id)notificationObserver            // cannot be nil
00048            selector:(SEL)notificationSelector           // cannot be nil
00049                name:(NSString *)notificationName        // nil means all
00050              object:(NSString *)notificationSender      // nil means of all
00051            useLocks:(bool)protect                       // set to YES for multi thread safe
00052      useMainRunLoop:(bool)mainThread;                   // set to YES for excute in my (main) thread
00053                                                         // even when event occured elsewhere
00054 
00055 - (void)removeObserver:(id)notificationObserver         // remove observer for event
00056                   name:(NSString *)notificationName;    // nil means all
00057 
00058 - (void) postNotificationName:(NSString *)name object:(id) sender userInfo:(id)userInfo;
00059 - (void) postNotificationName:(NSString *)name userInfo:(id)userInfo;
00060 - (void) postNotificationName:(NSString *)name;
00061 
00062 - (bool) useLocks;
00063 - (void) setUseLocks:(bool)protect;
00064 
00065 - (int)  timeOut;
00066 - (void) setTimeOut:(int)interval;
00067 
00068 - (void) setEnable:(bool)enable;
00069 
00070 @end

Generated on Fri Jul 28 19:15:22 2006 for MacTrek by  doxygen 1.4.7