~ubuntu-branches/ubuntu/saucy/sope/saucy

« back to all changes in this revision

Viewing changes to sope-core/EOControl/EOObserver.h

  • Committer: Package Import Robot
  • Author(s): Jeroen Dekkers
  • Date: 2012-05-09 15:39:17 UTC
  • Revision ID: package-import@ubuntu.com-20120509153917-nr4jlm8mktma1yv3
Tags: upstream-1.3.14
ImportĀ upstreamĀ versionĀ 1.3.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (C) 2000-2005 SKYRIX Software AG
 
3
 
 
4
  This file is part of SOPE.
 
5
 
 
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
 
9
  later version.
 
10
 
 
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.
 
15
 
 
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
 
19
  02111-1307, USA.
 
20
*/
 
21
 
 
22
#ifndef __EOControl_EOObserver_H__
 
23
#define __EOControl_EOObserver_H__
 
24
 
 
25
#import <Foundation/NSObject.h>
 
26
 
 
27
@class NSArray;
 
28
 
 
29
@protocol EOObserving < NSObject >
 
30
 
 
31
- (void)objectWillChange:(id)_object;
 
32
 
 
33
@end
 
34
 
 
35
@interface NSObject(EOObserver)
 
36
 
 
37
- (void)willChange;
 
38
 
 
39
@end
 
40
 
 
41
/*
 
42
  Note that -addObserver/-removeObserver methods do *not* nest !
 
43
  Suppression methods do nest.
 
44
*/
 
45
 
 
46
@interface EOObserverCenter : NSObject
 
47
 
 
48
+ (void)notifyObserversObjectWillChange:(id)_object;
 
49
 
 
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;
 
54
 
 
55
+ (NSArray *)observersForObject:(id)_object;
 
56
+ (id)observerForObject:(id)_object ofClass:(Class)_targetClass;
 
57
 
 
58
/* suppressing notifications */
 
59
 
 
60
+ (void)suppressObserverNotification;
 
61
+ (void)enableObserverNotification;
 
62
+ (unsigned)observerNotificationSuppressCount;
 
63
 
 
64
@end
 
65
 
 
66
/* asynchronous observing */
 
67
 
 
68
typedef enum {
 
69
  EOObserverPriorityImmediate,
 
70
  EOObserverPriorityFirst,
 
71
  EOObserverPrioritySecond,
 
72
  EOObserverPriorityThird,
 
73
  EOObserverPriorityFourth,
 
74
  EOObserverPriorityFifth,
 
75
  EOObserverPrioritySixth,
 
76
  EOObserverPriorityLater
 
77
} EOObserverPriority;
 
78
 
 
79
@class EODelayedObserver;
 
80
 
 
81
@interface EODelayedObserverQueue : NSObject
 
82
{
 
83
@protected
 
84
  EODelayedObserver *queues[8];
 
85
  NSArray           *runLoopModes;
 
86
  BOOL              hasObservers;
 
87
}
 
88
 
 
89
+ (EODelayedObserverQueue *)defaultObserverQueue;
 
90
 
 
91
/* accessors */
 
92
 
 
93
- (void)setRunLoopModes:(NSArray *)_modes;
 
94
- (NSArray *)runLoopModes;
 
95
 
 
96
/* managing queue */
 
97
 
 
98
- (void)enqueueObserver:(EODelayedObserver *)_observer;
 
99
- (void)dequeueObserver:(EODelayedObserver *)_observer;
 
100
 
 
101
/* notification */
 
102
 
 
103
- (void)notifyObserversUpToPriority:(EOObserverPriority)_lastPriority;
 
104
 
 
105
@end
 
106
 
 
107
@interface EODelayedObserver : NSObject < EOObserving >
 
108
{
 
109
@public
 
110
  EODelayedObserver *next; /* for access by queue */
 
111
}
 
112
 
 
113
/* accessors */
 
114
 
 
115
- (EOObserverPriority)priority;
 
116
- (EODelayedObserverQueue *)observerQueue;
 
117
 
 
118
/* notifications */
 
119
 
 
120
- (void)subjectChanged;
 
121
- (void)discardPendingNotification;
 
122
 
 
123
@end
 
124
 
 
125
@interface EOObserverProxy : EODelayedObserver
 
126
{
 
127
@protected
 
128
  EOObserverPriority priority;
 
129
  id  target;
 
130
  SEL action;
 
131
}
 
132
 
 
133
- (id)initWithTarget:(id)_target action:(SEL)_action
 
134
  priority:(EOObserverPriority)_priority;
 
135
 
 
136
@end
 
137
 
 
138
#endif /* __EOControl_EOObserver_H__ */