summaryrefslogtreecommitdiff
path: root/comm/OLD/Event.h
blob: 5f5019da15b7f4fcbf2dad2de091a2f6527ca859 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
 *	The Unix Channel
 *
 *	by Michel Beaudouin-Lafon
 *
 *	Copyright 1993
 *	Centre d'Etudes de la Navigation Aerienne (CENA)
 *
 *	Events, by Stephane Chatty
 *
 *	$Id$
 *	$CurLog$
 */

#ifndef UchEvent_H_
#define UchEvent_H_

#include "cplus_bugs.h"
#include "global.h"
#include "ccu/String.h"
#include "ccu/List.h"

#include "Message.h"
class UchIOS;

#if 0
class UchEventFeature {
protected:
	CcuString	Name;
	UchEventFeatureType&	Type;

public:
inline		UchEventFeature (const char* n, UchEventFeatureType& t) : Name (n), Type (t)	{}
inline		~UchEventFeature ()	{}
};
#endif

struct UchEventFeature {
	const char*	Name;
	int	Size;
};


class UchEventFeatureList : public CcuListOf <UchEventFeature> {
private:
	void	Load (int, UchEventFeature*);

public:
		UchEventFeatureList (int, UchEventFeature*);
		UchEventFeatureList (const UchEventFeatureList&, int, UchEventFeature*);
		~UchEventFeatureList ();
};


class UchEventType {
private:
static	void	ClassInit ();

protected:
static	CcuListOf <UchEventType>*	AllTypes;
	CcuString	Name;
#if 0
	CcuListOf <UchEventFeature>	Features;
#endif
	int	NbFeatures;
	int*	FeaturesOffsets;

public:
		UchEventType (const char*, int, UchEventFeature []);
		UchEventType (const char*, const UchEventFeatureList&);
		~UchEventType ();
inline	int	operator == (const UchEventType& evt) const	{ return (this == &evt); }
inline	int	GetTotalSize () const	{ return FeaturesOffsets [NbFeatures - 1]; }
inline	int	GetOffset (int i) const	{ return i ? FeaturesOffsets [i-1] : 0; }
inline	int	GetSize (int i) const	{ return FeaturesOffsets [i] - (i ? FeaturesOffsets [i-1] : 0); }
#if 0
inline	void	AddFeature (const char* fn, UchEventFeatureType& t)	{ Features->Append (new UchEventFeature (fn, t); }
inline	void	RemoveFeature ()	{ }
#endif
};

class UchEvent : public UchMessage {
protected:
	const UchEventType&	Type;
	char*	Data;

	void	ReadFrom (UchIOS&, lword);
	void	WriteTo (UchIOS&);

public:
		UchEvent (const UchEventType*);
		~UchEvent ();
	void	SetFeature (int, const void*);
	void	GetFeature (int, void*);
inline	const UchEventType&	GetType () const	{ return Type; }
};

#endif	/* UchEvent_H_ */