This is a mixin class. Any class can inherit CK_Subject to become a subject. When an object is a subject, it is capable of being observed by any object that is an observer (CK_Observer). The subject/observer design pattern is described in more detail here: Subjects & Observers.
A CK_Subject should never exist on its own. It should always be mixed-in to another class. In other words, a class in the user's application should inherit CK_Subject. No member functions CK_Subject need to be overridden or implemented (i.e. there are no pure virtual functions in CK_Subject).
Makes an observer start observing the subject. When the subject is deleted, the observer's subjectDeleted() method will be called. When the subject calls notifyObservers(), the observer's subjectUpdate() method will be called.
Parameters
- observer
- The observer that will watch the subject.
Stops an observer from observing the subject. No harm is done if the observer is not already watching the subject.
Parameters
- observer
- The observer that will stop observing the subject.
Returns the user-defined subject id. CK_Subject allows the user to set a subject id that will be passed to the observers' subjectUpdate() and subjectDeleted() member functions. The provides a way for a parameter to be passed from subject to observer.
Calls the subjectUpdate() method of each CK_Observer observing this subject.
Sets a user-defined id that is passed to each observer's subjectUpdate() and subjectDeleted() method. This provides a way for the application to pass a parameter from subject to observer.