CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csevent.h

00001 /*
00002     Crystal Space 3D engine: Event class interface
00003     Written by Andrew Zabolotny <bit@eltech.ru>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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   // make csEventQueue and csEvent as a friend class
00157   friend class csEventQueue;
00158   friend class csEvent;
00159 
00160 private:
00161   // As per the XML pool, keep a reference to the pool container obejct
00162   // and this also allows our overridden DecRef() to place the event back
00163   // into the pool when users are done with it.
00164   csRef<csEventQueue> pool;
00165 
00166   // The next event in the pool, or null if the event is in use.
00167   csPoolEvent *next;
00168 
00169   // The 'real' DecRef() call that deletes the event, should in theory only be
00170   // called from the csEventQueue;
00171   void Free () { csEvent::DecRef(); }
00172 
00173 public:
00175   csPoolEvent (csEventQueue *q);
00176 
00178   void DecRef ();
00179 };
00180 
00181 #endif // __CS_CSEVENT_H__

Generated for Crystal Space by doxygen 1.2.14