2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE 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 SOPE 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 SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #ifndef __EOControl_EOObserver_H__
23 #define __EOControl_EOObserver_H__
25 #import <Foundation/NSObject.h>
29 @protocol EOObserving < NSObject >
31 - (void)objectWillChange:(id)_object;
35 @interface NSObject(EOObserver)
42 Note that -addObserver/-removeObserver methods do *not* nest !
43 Suppression methods do nest.
46 @interface EOObserverCenter : NSObject
48 + (void)notifyObserversObjectWillChange:(id)_object;
50 + (void)addObserver:(id<EOObserving>)_observer forObject:(id)_object;
51 + (void)removeObserver:(id<EOObserving>)_observer forObject:(id)_object;
52 + (void)addOmniscientObserver:(id<EOObserving>)_observer;
53 + (void)removeOmniscientObserver:(id<EOObserving>)_observer;
55 + (NSArray *)observersForObject:(id)_object;
56 + (id)observerForObject:(id)_object ofClass:(Class)_targetClass;
58 /* suppressing notifications */
60 + (void)suppressObserverNotification;
61 + (void)enableObserverNotification;
62 + (unsigned)observerNotificationSuppressCount;
66 /* asynchronous observing */
69 EOObserverPriorityImmediate,
70 EOObserverPriorityFirst,
71 EOObserverPrioritySecond,
72 EOObserverPriorityThird,
73 EOObserverPriorityFourth,
74 EOObserverPriorityFifth,
75 EOObserverPrioritySixth,
76 EOObserverPriorityLater
79 @class EODelayedObserver;
81 @interface EODelayedObserverQueue : NSObject
84 EODelayedObserver *queues[8];
85 NSArray *runLoopModes;
89 + (EODelayedObserverQueue *)defaultObserverQueue;
93 - (void)setRunLoopModes:(NSArray *)_modes;
94 - (NSArray *)runLoopModes;
98 - (void)enqueueObserver:(EODelayedObserver *)_observer;
99 - (void)dequeueObserver:(EODelayedObserver *)_observer;
103 - (void)notifyObserversUpToPriority:(EOObserverPriority)_lastPriority;
107 @interface EODelayedObserver : NSObject < EOObserving >
110 EODelayedObserver *next; /* for access by queue */
115 - (EOObserverPriority)priority;
116 - (EODelayedObserverQueue *)observerQueue;
120 - (void)subjectChanged;
121 - (void)discardPendingNotification;
125 @interface EOObserverProxy : EODelayedObserver
128 EOObserverPriority priority;
133 - (id)initWithTarget:(id)_target action:(SEL)_action
134 priority:(EOObserverPriority)_priority;
138 #endif /* __EOControl_EOObserver_H__ */