2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #ifndef __EOControl_EOObserver_H__
24 #define __EOControl_EOObserver_H__
26 #import <Foundation/NSObject.h>
30 @protocol EOObserving < NSObject >
32 - (void)objectWillChange:(id)_object;
36 @interface NSObject(EOObserver)
43 Note that -addObserver/-removeObserver methods do *not* nest !
44 Suppression methods do nest.
47 @interface EOObserverCenter : NSObject
49 + (void)notifyObserversObjectWillChange:(id)_object;
51 + (void)addObserver:(id<EOObserving>)_observer forObject:(id)_object;
52 + (void)removeObserver:(id<EOObserving>)_observer forObject:(id)_object;
53 + (void)addOmniscientObserver:(id<EOObserving>)_observer;
54 + (void)removeOmniscientObserver:(id<EOObserving>)_observer;
56 + (NSArray *)observersForObject:(id)_object;
57 + (id)observerForObject:(id)_object ofClass:(Class)_targetClass;
59 /* suppressing notifications */
61 + (void)suppressObserverNotification;
62 + (void)enableObserverNotification;
63 + (unsigned)observerNotificationSuppressCount;
67 /* asynchronous observing */
70 EOObserverPriorityImmediate,
71 EOObserverPriorityFirst,
72 EOObserverPrioritySecond,
73 EOObserverPriorityThird,
74 EOObserverPriorityFourth,
75 EOObserverPriorityFifth,
76 EOObserverPrioritySixth,
77 EOObserverPriorityLater
80 @class EODelayedObserver;
82 @interface EODelayedObserverQueue : NSObject
85 EODelayedObserver *queues[8];
86 NSArray *runLoopModes;
90 + (EODelayedObserverQueue *)defaultObserverQueue;
94 - (void)setRunLoopModes:(NSArray *)_modes;
95 - (NSArray *)runLoopModes;
99 - (void)enqueueObserver:(EODelayedObserver *)_observer;
100 - (void)dequeueObserver:(EODelayedObserver *)_observer;
104 - (void)notifyObserversUpToPriority:(EOObserverPriority)_lastPriority;
108 @interface EODelayedObserver : NSObject < EOObserving >
111 EODelayedObserver *next; /* for access by queue */
116 - (EOObserverPriority)priority;
117 - (EODelayedObserverQueue *)observerQueue;
121 - (void)subjectChanged;
122 - (void)discardPendingNotification;
126 @interface EOObserverProxy : EODelayedObserver
129 EOObserverPriority priority;
134 - (id)initWithTarget:(id)_target action:(SEL)_action
135 priority:(EOObserverPriority)_priority;
139 #endif /* __EOControl_EOObserver_H__ */