summaryrefslogtreecommitdiff
path: root/dnn/Trigger.h
blob: 884496309cac2474e92d09f0f78ee87a0e8828d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 *	DNN - Data News Network
 *
 *	by Stephane Chatty
 *
 *	Copyright 1993-1995
 *	Centre d'Etudes de la Navigation Aerienne (CENA)
 *
 *	Event triggers.
 *
 *	$Id$
 *	$CurLog$
 */

#ifndef IvlTrigger_H_
#define IvlTrigger_H_

#include "cplus_bugs.h"
#include "ivl/List.h"
#include "ivl/bool.h"

class IvlEvent;
class IvlBaseCriterion;

class IvlTrigger {
friend	class	IvlBaseReaction;

public:
enum	REL_PRIORITY { isFirstPriority, isNormalPriority, isLastPriority };

private:
		IvlTrigger (const IvlTrigger&);
	IvlTrigger&	operator = (const IvlTrigger&);

protected:
	IvlListOf <IvlBaseReaction>	FirstSubscribers;
	IvlListOf <IvlBaseReaction>	Subscribers;
	IvlListOf <IvlBaseReaction>	LastSubscribers;
	IvlListOf <IvlBaseReaction>	Grabs;
	IvlListOf <IvlBaseCriterion>	Criteria;
	void	Subscribe (IvlBaseReaction&, REL_PRIORITY);
	void	Unsubscribe (IvlBaseReaction&);
	void	Grab (IvlBaseReaction&);
	void	Release (IvlBaseReaction&);

public:
		IvlTrigger ();
		~IvlTrigger ();
inline	bool	IsUnused () const	{ return bool (Subscribers.IsEmpty () && FirstSubscribers.IsEmpty () && LastSubscribers.IsEmpty ()); }
	void	Dispatch (IvlEvent&);
	bool	Check (IvlEvent&);
inline	void	AddCriterion    (IvlBaseCriterion& c) { Criteria.Append (&c); }
inline	void	RemoveCriterion (IvlBaseCriterion& c) { Criteria.Remove (&c); }
};

#endif	/* IvlTrigger_H_ */