depend.c File Reference

Support for updater functions for dependent events. More...

#include <stdio.h>
#include <stdlib.h>
#include "data.h"
#include "depend.h"
#include "gettext.h"
#include "assert.h"

Functions

static int updater_dependent (updaterfunc *updater)
 Checks if the source event of the updater function itself depends on another event or not.
static void updater_movetoend (updaterfunc **list, updaterfunc *updater)
 Moves an updaterfunc structure to the end of a linked list.
int updater_reorder ()
 Reorders dep_updaterlist linked list.
int updater_check (int dst)
 Checks if an updater function can be registered for a dependent event.
updaterfuncupdater_new (int src, int dst, updater_f func)
 Register a new updater function.
void updater_call (table *tab)
 Calls all registered updater functions.

Variables

static updaterfuncdep_updaterlist = NULL
 Linked list of all updater functions for dependent events.


Detailed Description

Support for updater functions for dependent events.


Function Documentation

void updater_call table tab  ) 
 

Calls all registered updater functions.

Functions are called in the order of the linked list. updater_reorder() must be called before the first call to updater_call() to properly reorder the linked list.

Parameters:
tab Pointer to the timetable structure.

int updater_check int  dst  ) 
 

Checks if an updater function can be registered for a dependent event.

Parameters:
dst Tuple ID of the dependent event.
Returns:
0 if an updater function can be registered or -1 if an updater function can not be registered for this event.

static int updater_dependent updaterfunc updater  )  [static]
 

Checks if the source event of the updater function itself depends on another event or not.

Helper function for updater_reorder().

This function walks the dat_updatelist linked list and searches for an updater function that has a destination event equal to the source event of the updater function in the argument.

Parameters:
updater Pointer to the updaterfunc structure to be checked.
Returns:
0 if the source event is independent or -1 if it is dependent.

static void updater_movetoend updaterfunc **  list,
updaterfunc updater
[static]
 

Moves an updaterfunc structure to the end of a linked list.

Helper function for updater_reorder().

Parameters:
list Pointer to a linked list of updaterfunc structures.
updater Pointer to the updaterfunc structure to be moved to the end of the list.

updaterfunc* updater_new int  src,
int  dst,
updater_f  func
 

Register a new updater function.

It is recommended that updater_check() is called before calling this function to verify if there isn't another updater function registered for this dependent event.

Parameters:
src Tuple ID of the independent event.
dst Tuple ID of the dependent event.
func Pointer to the updater function.
Returns:
Pointer to the updaterfunc structure or NULL on error.

int updater_reorder  ) 
 

Reorders dep_updaterlist linked list.

A source (independent) event for an updater function can infact be a destination (dependent) event of another updater function. This means that updater functions must be called in the correct order.

Example: Function A has a source event 2 and destination event 3. Function B has a source event 1 and destination event 2. In this case updater_reorder() puts function B in front of A.

Returns:
0 on success or -1 on error (there was a circular dependency and the correct order of calling can not be determined.


Generated on Thu Feb 9 17:18:31 2006 for Tablix by  doxygen 1.4.6