00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_CSEVENT_H__
00021 #define __CS_CSEVENT_H__
00022
00023 #include "iutil/event.h"
00024 #include "csutil/hashmapr.h"
00025 #include "cssys/csendian.h"
00026
00028 enum
00029 {
00030 CS_DATATYPE_INT8 = 0x00,
00031 CS_DATATYPE_UINT8,
00032 CS_DATATYPE_INT16,
00033 CS_DATATYPE_UINT16,
00034 CS_DATATYPE_INT32,
00035 CS_DATATYPE_UINT32,
00036 CS_DATATYPE_INT64,
00037 CS_DATATYPE_UINT64,
00038 CS_DATATYPE_FLOAT,
00039 CS_DATATYPE_DOUBLE,
00040 CS_DATATYPE_BOOL,
00041 CS_DATATYPE_STRING,
00042 CS_DATATYPE_DATABUFFER,
00043 CS_DATATYPE_EVENT
00044 };
00045
00053 class csEvent : public iEvent
00054 {
00055 private:
00056 csHashMapReversible attributes;
00057
00058 uint32 count;
00059
00060 bool CheckForLoops(csEvent *current, csEvent *e);
00061
00062 bool FlattenCrystal(char *buffer);
00063 bool FlattenMuscle(char *buffer);
00064 bool FlattenXML(char *buffer);
00065
00066 uint32 FlattenSizeCrystal();
00067 uint32 FlattenSizeMuscle();
00068 uint32 FlattenSizeXML();
00069
00070 bool UnflattenCrystal(const char *buffer, uint32 length);
00071 bool UnflattenMuscle(const char *buffer, uint32 length);
00072 bool UnflattenXML(const char *buffer, uint32 length);
00073
00074 public:
00076 csEvent ();
00077
00082 csEvent (csEvent const&);
00083
00085 csEvent (csTicks, int type, int kcode, int kchar, int modifiers);
00086
00088 csEvent (csTicks, int type, int x, int y, int button, int modifiers);
00089
00091 csEvent (csTicks, int type, int n, int x, int y, int button, int modifiers);
00092
00094 csEvent (csTicks, int type, int code, void* info = 0);
00095
00097 virtual ~csEvent ();
00098
00100 virtual bool Add (const char *name, int8 v);
00101 virtual bool Add (const char *name, uint8 v);
00102 virtual bool Add (const char *name, int16 v);
00103 virtual bool Add (const char *name, uint16 v);
00104 virtual bool Add (const char *name, int32 v, bool force_boolean = false);
00105 virtual bool Add (const char *name, uint32 v);
00106 virtual bool Add (const char *name, int64 v);
00107 virtual bool Add (const char *name, uint64 v);
00108 virtual bool Add (const char *name, float v);
00109 virtual bool Add (const char *name, double v);
00110 virtual bool Add (const char *name, char *v);
00111 virtual bool Add (const char *name, void *v, uint32 size);
00112 #ifndef CS_USE_FAKE_BOOL_TYPE
00113 virtual bool Add (const char *name, bool v, bool force_boolean = true);
00114 #endif
00115 virtual bool Add (const char *name, iEvent *v);
00116
00118 virtual bool Find (const char *name, int8 &v, int index = 0);
00119 virtual bool Find (const char *name, uint8 &v, int index = 0);
00120 virtual bool Find (const char *name, int16 &v, int index = 0);
00121 virtual bool Find (const char *name, uint16 &v, int index = 0);
00122 virtual bool Find (const char *name, int32 &v, int index = 0);
00123 virtual bool Find (const char *name, uint32 &v, int index = 0);
00124 virtual bool Find (const char *name, int64 &v, int index = 0);
00125 virtual bool Find (const char *name, uint64 &v, int index = 0);
00126 virtual bool Find (const char *name, float &v, int index = 0);
00127 virtual bool Find (const char *name, double &v, int index = 0);
00128 virtual bool Find (const char *name, char **v, int index = 0);
00129 virtual bool Find (const char *name, void **v, uint32 &size, int index = 0);
00130 #ifndef CS_USE_FAKE_BOOL_TYPE
00131 virtual bool Find (const char *name, bool &v, int index = 0);
00132 #endif
00133 virtual bool Find (const char *name, iEvent **v, int index = 0);
00134
00135 virtual bool Remove (const char *name, int index = -1);
00136 virtual bool RemoveAll ();
00137
00138 virtual uint32 FlattenSize (int format = CS_CRYSTAL_PROTOCOL);
00139 virtual bool Flatten (char *buffer, int format = CS_CRYSTAL_PROTOCOL);
00140 virtual bool Unflatten (const char *buffer, uint32 length);
00141
00142 virtual bool Print (int level = 0);
00143
00144 SCF_DECLARE_IBASE;
00145 };
00146
00154 class csPoolEvent : public csEvent
00155 {
00156
00157 friend class csEventQueue;
00158 friend class csEvent;
00159
00160 private:
00161
00162
00163
00164 csRef<csEventQueue> pool;
00165
00166
00167 csPoolEvent *next;
00168
00169
00170
00171 void Free () { csEvent::DecRef(); }
00172
00173 public:
00175 csPoolEvent (csEventQueue *q);
00176
00178 void DecRef ();
00179 };
00180
00181 #endif // __CS_CSEVENT_H__