1998-03-28 05:44:41 +03:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-03-28 05:44:41 +03:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-03-28 05:44:41 +03:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-03-28 05:44:41 +03:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:43:54 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-03-28 05:44:41 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _xp_observer_h_
|
|
|
|
#define _xp_observer_h_
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#include "platform.h"
|
|
|
|
#else
|
|
|
|
#ifndef _platform_h_
|
|
|
|
typedef int NS_Error;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "prtypes.h"
|
1998-07-27 20:14:32 +04:00
|
|
|
#include "prlog.h"
|
1998-03-28 05:44:41 +03:00
|
|
|
|
|
|
|
typedef struct OpaqueObserverList *XP_ObserverList;
|
|
|
|
typedef void* XP_Observable;
|
|
|
|
typedef long XP_ObservableMsg;
|
|
|
|
|
|
|
|
|
|
|
|
typedef void (*XP_ObserverProc) (
|
|
|
|
XP_Observable inSource,
|
|
|
|
XP_ObservableMsg inMsg,
|
|
|
|
void* ioMsgData,
|
|
|
|
void* ioClosure );
|
|
|
|
|
|
|
|
|
|
|
|
|
1998-07-27 20:14:32 +04:00
|
|
|
PR_BEGIN_EXTERN_C
|
1998-03-28 05:44:41 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
Creates a new XP_ObserverList, with an assoicated XP_Observabe,
|
|
|
|
to which you can add observers, who are notified when
|
|
|
|
XP_NotifyObservers is called.
|
|
|
|
|
|
|
|
Observerer notification is enabled by default.
|
|
|
|
*/
|
|
|
|
extern NS_Error
|
|
|
|
XP_NewObserverList(
|
|
|
|
XP_Observable inObservable,
|
|
|
|
XP_ObserverList* outObserverList );
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Disposes of an XP_ObserverList. Does nothing with
|
|
|
|
its observers.
|
|
|
|
*/
|
|
|
|
extern void
|
|
|
|
XP_DisposeObserverList(
|
|
|
|
XP_ObserverList inObserverList );
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Returns the XP_Observable associated with an XP_ObserverList
|
|
|
|
*/
|
|
|
|
extern XP_Observable
|
|
|
|
XP_GetObserverListObservable(
|
|
|
|
XP_ObserverList inObserverList);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Change the observable associated with an observerlist
|
|
|
|
*/
|
|
|
|
extern void
|
|
|
|
XP_SetObserverListObservable(
|
|
|
|
XP_ObserverList inObserverList,
|
|
|
|
XP_Observable inObservable);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Registers a function pointer and void* closure
|
|
|
|
as an "observer", which will be called whenever
|
|
|
|
XP_NotifyObservers is called an observer notification
|
|
|
|
is enabled.
|
|
|
|
*/
|
|
|
|
extern int
|
|
|
|
XP_AddObserver(
|
|
|
|
XP_ObserverList inObserverList,
|
|
|
|
XP_ObserverProc inObserver,
|
|
|
|
void* inClosure );
|
|
|
|
|
|
|
|
/*
|
|
|
|
Removes a registered observer. If there are duplicate
|
|
|
|
(XP_ObserverProc/void* closure) pairs registered,
|
|
|
|
it is undefined which one will be removed.
|
|
|
|
|
|
|
|
Returns false if the observer is not registered.
|
|
|
|
*/
|
|
|
|
extern PRBool
|
|
|
|
XP_RemoveObserver(
|
|
|
|
XP_ObserverList inObserverList,
|
|
|
|
XP_ObserverProc inObserver,
|
|
|
|
void* inClosure );
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
If observer notification is enabled for this XP_Observable,
|
|
|
|
this will call each registered observer proc, passing it
|
|
|
|
the given message and void* ioData, in addition to the
|
|
|
|
observer's closure void*.
|
|
|
|
|
|
|
|
There is no defined order in which observers are called.
|
|
|
|
*/
|
|
|
|
extern void
|
|
|
|
XP_NotifyObservers(
|
|
|
|
XP_ObserverList inObserverList,
|
|
|
|
XP_ObservableMsg inMessage,
|
|
|
|
void* ioData );
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
When called, subsequent calls to XP_NotifyObservers
|
|
|
|
will do nothing until XP_EnableObserverNotification
|
|
|
|
is called.
|
|
|
|
*/
|
|
|
|
extern void
|
|
|
|
XP_DisableObserverNotification(
|
|
|
|
XP_ObserverList inObserverList );
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Enables calling observers when XP_NotifyObservers
|
|
|
|
is invoked.
|
|
|
|
*/
|
|
|
|
extern void
|
|
|
|
XP_EnableObserverNotification(
|
|
|
|
XP_ObserverList inObserverList );
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Returns true if observer notification is enabled.
|
|
|
|
*/
|
|
|
|
extern PRBool
|
|
|
|
XP_IsObserverNotificationEnabled(
|
|
|
|
XP_ObserverList inObserverList );
|
|
|
|
|
|
|
|
|
1998-07-27 20:14:32 +04:00
|
|
|
PR_END_EXTERN_C
|
1998-03-28 05:44:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* #ifdef _xp_observer_h_ */
|