/* ****************************************************************************** * INTERPEAK SOURCE FILE * * Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_observer.c,v $ $Revision: 1.1 $ * $Source: /home/interpeak/CVSRoot/ipcom/src/ipcom_observer.c,v $ * $Author: kenneth $ * $State: Exp $ $Locker: $ * * INTERPEAK_COPYRIGHT_STRING * Design and implementation by Kenneth Jonsson ****************************************************************************** */ /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ #ifndef IPCOM_KERNEL #define IPCOM_KERNEL #endif #include "ipcom_config.h" /* **************************************************************************** * 3 INCLUDE FILES **************************************************************************** */ #define IPCOM_USE_CLIB_PROTO #include "ipcom_cstyle.h" #include "ipcom_observer.h" #include "ipcom_type.h" /* **************************************************************************** * 4 DEFINES **************************************************************************** */ /* **************************************************************************** * 5 TYPES **************************************************************************** */ /* **************************************************************************** * 6 EXTERN PROTOTYPES **************************************************************************** */ /* **************************************************************************** * 7 LOCAL PROTOTYPES **************************************************************************** */ /* **************************************************************************** * 8 DATA **************************************************************************** */ /* **************************************************************************** * 9 STATIC FUNCTIONS **************************************************************************** */ /* **************************************************************************** * 10 GLOBAL FUNCTIONS **************************************************************************** */ /* *=========================================================================== * ipcom_observer_notify *=========================================================================== * Description: Notifies all observer to the specified subject * Parameters: observers - collection of observers to the subject * subject - the subject being observed. * subject_ctx - data accosiated with the change that happend * to the subject * Returns: * */ IP_GLOBAL void ipcom_observer_notify(Ipcom_observer_collection *observers, void *subject, void *subject_ctx) { Ipcom_observer *observer; /* * Iterate over the observers in a way so an observer can remove * itself from the list in "action" */ observer = IPCOM_LIST_FIRST((Ipcom_list *)observers); while (observer != IP_NULL) { Ipcom_observer *next = IPCOM_LIST_NEXT(&observer->list); observer->action(subject, subject_ctx, observer->ctx); observer = next; } } /* **************************************************************************** * 11 PUBLIC FUNCTIONS **************************************************************************** */ /* **************************************************************************** * END OF FILE **************************************************************************** */