CoreLinux++  0.4.32
Subject.hpp
1 #if !defined(__SUBJECT_HPP)
2 #define __SUBJECT_HPP
3 
4 /*
5  CoreLinux++
6  Copyright (C) 2000 CoreLinux Consortium
7 
8  The CoreLinux++ Library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12 
13  The CoreLinux++ Library Library is distributed in the hope that it will
14  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public
19  License along with the GNU C Library; see the file COPYING.LIB. If not,
20  write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA 02111-1307, USA.
22 */
23 
24 #if !defined(__COMMON_HPP)
25 #include <Common.hpp>
26 #endif
27 
28 #if !defined(__EVENT_HPP)
29 #include <Event.hpp>
30 #endif
31 
32 #if !defined(__ITERATOR_HPP)
33 #include <Iterator.hpp>
34 #endif
35 
36 namespace corelinux
37 {
38  DECLARE_CLASS( Subject );
39  DECLARE_CLASS( Observer );
40 
46  class Subject
47  {
48  public:
49 
50  //
51  // Constructors and destructor
52  //
53 
58  Subject( void ) ;
59 
66 
68 
69  virtual ~Subject( void );
70 
71  //
72  // Operator overloads
73  //
74 
76 
78 
80 
81  bool operator==( SubjectCref ) const;
82 
84 
85  bool operator!=( SubjectCref ) const;
86  //
87  // Accessors
88  //
89 
90 
91  //
92  // Mutators
93  //
94 
101  virtual void addObserver( ObserverPtr, Event<Identifier> * )
102  throw ( NullPointerException ) = 0 ;
103 
110  virtual void removeObserver( ObserverPtr )
111  throw ( NullPointerException ) = 0 ;
112 
119  virtual void removeObserver( ObserverPtr, Event<Identifier> * )
120  throw ( NullPointerException ) = 0 ;
121 
122  //
123  // Iterator Factory methods
124  //
130  virtual Iterator<ObserverPtr> *createIterator( void ) = 0;
131 
140  throw ( NullPointerException ) = 0 ;
141 
148  virtual void destroyIterator( Iterator<ObserverPtr> * )
149  throw ( NullPointerException ) = 0 ;
150 
151  protected:
152 
153  //
154  // Activity
155  //
156 
164  virtual void notifyObservers( Event<Identifier> * )
165  throw ( NullPointerException ) ;
166 
174  virtual void notifyAllObservers( Event<Identifier> * )
175  throw ( NullPointerException ) ;
176  private:
177 
178  };
179 }
180 
181 #endif // if !defined(__SUBJECT_HPP)
182 
183 /*
184  Common rcs information do not modify
185  $Author: frankc $
186  $Revision: 1.1 $
187  $Date: 2000/05/07 14:53:13 $
188  $Locker: $
189 */
190 
191 
Subject(void)
Default constructor.
Definition: Subject.cpp:39
virtual Iterator< ObserverPtr > * createIterator(void)=0
Create a iterator for all observers.
Observer observes Subjets and supports the event interface for recieving subject event notifications...
Definition: Observer.hpp:44
virtual void destroyIterator(Iterator< ObserverPtr > *)=0
Deletes the iterator instance.
virtual ~Subject(void)
Virtual destructor.
Definition: Subject.cpp:57
SubjectRef operator=(SubjectCref)
Assignment operator.
Definition: Subject.cpp:66
bool operator==(SubjectCref) const
Equality operator.
Definition: Subject.cpp:75
NullPointerException is the base exception type for NullPointer.
Definition: NullPointerException.hpp:40
Subject knows its Observer objects, communicates with its observers through event notification...
Definition: Subject.hpp:46
virtual void notifyAllObservers(Event< Identifier > *)
Performs the notification of ALL observers for a with a specific event.
Definition: Subject.cpp:121
virtual void addObserver(ObserverPtr, Event< Identifier > *)=0
Add an observer for a specific event.
bool operator!=(SubjectCref) const
In-Equality operator.
Definition: Subject.cpp:94
The Iterator provides a way to access the elements of an collection type sequentially without exposin...
Definition: Iterator.hpp:44
virtual void removeObserver(ObserverPtr)=0
Remove an observer from all event notifications.
virtual void notifyObservers(Event< Identifier > *)
Performs the notification of observers for a specific event.
Definition: Subject.cpp:101
Event provides a type basis for event ontologies.
Definition: Event.hpp:35

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium