CrystalSpace

Public API Reference

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

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 
00027 enum {
00028   CS_DATATYPE_INT8 = 0x00,
00029   CS_DATATYPE_UINT8,
00030   CS_DATATYPE_INT16,
00031   CS_DATATYPE_UINT16,
00032   CS_DATATYPE_INT32,
00033   CS_DATATYPE_UINT32,
00034   CS_DATATYPE_INT64,
00035   CS_DATATYPE_UINT64,
00036   CS_DATATYPE_FLOAT,
00037   CS_DATATYPE_DOUBLE,
00038   CS_DATATYPE_BOOL,
00039   CS_DATATYPE_STRING,
00040   CS_DATATYPE_DATABUFFER,
00041   CS_DATATYPE_EVENT
00042 };
00043 
00051 class csEvent : public iEvent
00052 {
00053 private:
00054   csHashMapReversible attributes;
00055   
00056   uint32 count;
00057 
00058   bool CheckForLoops(csEvent *current, csEvent *e);
00059 
00060   bool FlattenCrystal(char *buffer);
00061   bool FlattenMuscle(char *buffer);
00062   bool FlattenXML(char *buffer);
00063 
00064   uint32 FlattenSizeCrystal();
00065   uint32 FlattenSizeMuscle();
00066   uint32 FlattenSizeXML();
00067   
00068   bool UnflattenCrystal(const char *buffer, uint32 length);
00069   bool UnflattenMuscle(const char *buffer, uint32 length);
00070   bool UnflattenXML(const char *buffer, uint32 length);
00071 public:
00073   csEvent ();
00074 
00079   csEvent (csEvent const&);
00080 
00082   csEvent (csTicks, int type, int kcode, int kchar, int modifiers);
00083 
00085   csEvent (csTicks, int type, int x, int y, int button, int modifiers);
00086 
00088   csEvent (csTicks, int type, int n, int x, int y, int button, int modifiers);
00089 
00091   csEvent (csTicks, int type, int code, void* info = NULL);
00092 
00094   virtual ~csEvent ();
00095 
00096   virtual bool Add(const char *name, int8 v);
00097   virtual bool Add(const char *name, uint8 v);
00098   virtual bool Add(const char *name, int16 v);
00099   virtual bool Add(const char *name, uint16 v);
00100   virtual bool Add(const char *name, int32 v, bool force_boolean = false);
00101   virtual bool Add(const char *name, uint32 v);
00102   virtual bool Add(const char *name, int64 v);
00103   virtual bool Add(const char *name, uint64 v);
00104   virtual bool Add(const char *name, float v);
00105   virtual bool Add(const char *name, double v);
00106   virtual bool Add(const char *name, char *v);
00107   virtual bool Add(const char *name, void *v, uint32 size);
00108 #ifndef CS_USE_FAKE_BOOL_TYPE
00109   virtual bool Add(const char *name, bool v, bool force_boolean = true);
00110 #endif
00111   virtual bool Add(const char *name, iEvent *v);
00112 
00113   virtual bool Find(const char *name, int8 &v, int index = 0);
00114   virtual bool Find(const char *name, uint8 &v, int index = 0);
00115   virtual bool Find(const char *name, int16 &v, int index = 0);
00116   virtual bool Find(const char *name, uint16 &v, int index = 0);
00117   virtual bool Find(const char *name, int32 &v, int index = 0);
00118   virtual bool Find(const char *name, uint32 &v, int index = 0);
00119   virtual bool Find(const char *name, int64 &v, int index = 0);
00120   virtual bool Find(const char *name, uint64 &v, int index = 0);
00121   virtual bool Find(const char *name, float &v, int index = 0);
00122   virtual bool Find(const char *name, double &v, int index = 0);
00123   virtual bool Find(const char *name, char **v, int index = 0);
00124   virtual bool Find(const char *name, void **v, uint32 &size, int index = 0);
00125 #ifndef CS_USE_FAKE_BOOL_TYPE
00126   virtual bool Find(const char *name, bool &v, int index = 0);
00127 #endif
00128   virtual bool Find(const char *name, iEvent **v, int index = 0);
00129 
00130   virtual bool Remove(const char *name, int index = -1);
00131   virtual bool RemoveAll();
00132 
00133   virtual uint32 FlattenSize(int format = CS_CRYSTAL_PROTOCOL);
00134   virtual bool Flatten(char *buffer, int format = CS_CRYSTAL_PROTOCOL);
00135   virtual bool Unflatten(const char *buffer, uint32 length);
00136   
00137   virtual bool Print(int level = 0);
00138   
00139   SCF_DECLARE_IBASE;
00140 };
00141 
00149 class csPoolEvent : public csEvent
00150 {
00151   // make csEventQueue and csEvent as a friend class
00152   friend class csEventQueue;
00153   friend class csEvent;
00154 
00155 private:
00156   // As per the XML pool, keep a reference to the pool container obejct
00157   // and this also allows our overridden DecRef() to place the event back
00158   // into the pool when users are done with it.
00159   csRef<csEventQueue> pool;
00160  
00161   // The next event in the pool, or null if the event is in use.
00162   csPoolEvent *next;
00163  
00164   // The 'real' DecRef() call that deletes the event, should in theory only be 
00165   // called from the csEventQueue;
00166   void Free() { csEvent::DecRef(); }
00167  
00168 public:
00170   csPoolEvent(csEventQueue *q);
00171  
00173   void DecRef();
00174 };
00175 
00176 #endif // __CS_CSEVENT_H__

Generated for Crystal Space by doxygen 1.2.14