CrystalSpace

Public API Reference

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

csutil/binder.h

00001 /*
00002     Copyright (C) 2003 by Mathew Sutcliffe <oktal@gmx.co.uk>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_UTIL_BINDER_H__
00020 #define __CS_UTIL_BINDER_H__
00021 
00022 #include "iutil/binder.h"
00023 #include "iutil/eventh.h"
00024 #include "hashmap.h"
00025 
00030 csHashKey csHashComputeEvent (iEvent* const);
00031 
00036 class csInputBinder : public iInputBinder
00037 {
00038 private:
00039   csHashMap Hash;
00040 
00041 protected:
00042   bool HandleEvent (iEvent&);
00043 
00044 public:
00045   SCF_DECLARE_IBASE;
00046 
00051   csInputBinder (iBase *parent = 0, int size = 127);
00052 
00056   virtual ~csInputBinder ();
00057 
00058   struct eiEventHandler : public iEventHandler
00059   {
00060     SCF_DECLARE_EMBEDDED_IBASE (csInputBinder);
00061     bool HandleEvent (iEvent &ev) { return scfParent->HandleEvent (ev); }
00062   } scfiEventHandler;
00063   friend struct eiEventHandler;
00064 
00070   virtual iEventHandler* QueryHandler () { return &scfiEventHandler; }
00071 
00077   virtual void Bind (iEvent&, iInputBinderBoolean*, bool toggle = false);
00078 
00082   virtual void Bind (iEvent&, iInputBinderPosition*);
00083 
00087   virtual bool Unbind (iEvent&);
00088 
00092   virtual bool UnbindAll();
00093 };
00094 
00098 class csInputBinderPosition : public iInputBinderPosition
00099 {
00100 private:
00102   int p;
00103 
00104 public:
00105   SCF_DECLARE_IBASE;
00106 
00108   csInputBinderPosition (int pp) : p (pp)
00109   { SCF_CONSTRUCT_IBASE (0); }
00111   csInputBinderPosition () : p (0)
00112   { SCF_CONSTRUCT_IBASE (0); }
00114   csInputBinderPosition (iInputBinderPosition *pp) : p (pp->Get ())
00115   { SCF_CONSTRUCT_IBASE (0); }
00117   virtual ~csInputBinderPosition ()
00118   { SCF_DESTRUCT_IBASE(); }
00119 
00121   virtual void Set (int pp) { p = pp; }
00123   virtual int Get () const { return p; }
00124 };
00125 
00130 class csInputBinderBoolean : public iInputBinderBoolean
00131 {
00132 private:
00134   bool s;
00135 
00136 public:
00137   SCF_DECLARE_IBASE;
00138 
00140   csInputBinderBoolean (bool ss) : s (ss)
00141   { SCF_CONSTRUCT_IBASE (0); }
00143   csInputBinderBoolean () : s (0)
00144   { SCF_CONSTRUCT_IBASE (0); }
00146   csInputBinderBoolean (iInputBinderBoolean *ss) : s (ss->Get ())
00147   { SCF_CONSTRUCT_IBASE (0); }
00149   virtual ~csInputBinderBoolean ()
00150   { SCF_DESTRUCT_IBASE(); }
00151 
00153   virtual void Set (bool ss) { s = ss; }
00155   virtual bool Get () const { return s; }
00156 };
00157 
00158 #endif // __CS_UTIL_BINDER_H__

Generated for Crystal Space by doxygen 1.2.18