CrystalSpace

Public API Reference

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

objwatch.h

00001 /*
00002     Copyright (C) 2003 by Jorrit Tyberghein
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_OBJWATCH_H__
00020 #define __CS_OBJWATCH_H__
00021 
00022 #include "csutil/refarr.h"
00023 #include "csutil/array.h"
00024 #include "iengine/objwatch.h"
00025 
00026 struct iLight;
00027 struct iMovable;
00028 class csLightCallback;
00029 class csMovableListener;
00030 
00035 class csObjectWatcher : public iObjectWatcher
00036 {
00037 private:
00038   // Lights we are watching.
00039   csArray<iLight*> lights;
00040   // Movables we are watching.
00041   csArray<iMovable*> movables;
00042   // Our light listener.
00043   csLightCallback* light_callback;
00044   // Our movable listener.
00045   csMovableListener* movable_listener;
00046   // Listeners that are listening to this object watcher.
00047   csRefArray<iObjectWatcherListener> listeners;
00048 
00049   // Update number.
00050   long updatenr;
00051 
00052   // Last operation.
00053   int last_op;
00054   // Last light (or 0 if last operation has nothing to do with lights).
00055   iLight* last_light;
00056   // Last movable (or 0 if last operation has nothing to do with movables).
00057   iMovable* last_movable;
00058 
00059 public:
00063   csObjectWatcher ();
00064 
00066   virtual ~csObjectWatcher ();
00067 
00068   void ReportOperation (int op, iMovable* movable, iLight* light);
00069 
00070   SCF_DECLARE_IBASE;
00071 
00072   virtual void WatchLight (iLight* light);
00073   virtual void RemoveLight (iLight* light);
00074   virtual int GetWatchedLightCount () const { return lights.Length (); }
00075   virtual iLight* GetLight (int idx);
00076 
00077   virtual void WatchMovable (iMovable* movable);
00078   virtual void RemoveMovable (iMovable* movable);
00079   virtual int GetWatchedMovableCount () const { return movables.Length (); }
00080   virtual iMovable* GetMovable (int idx);
00081 
00082   virtual void Reset ();
00083 
00084   virtual uint32 GetWatchNumber () const { return updatenr; }
00085   virtual int GetLastOperation () const { return last_op; }
00086   virtual iLight* GetLastLight () const { return last_light; }
00087   virtual iMovable* GetLastMovable () const { return last_movable; }
00088 
00089   virtual void AddListener (iObjectWatcherListener* cb)
00090   {
00091     listeners.Push (cb);
00092   }
00093 
00094   virtual void RemoveListener (iObjectWatcherListener* cb)
00095   {
00096     listeners.Delete (cb);
00097   }
00098 };
00099 
00100 #endif // __CS_OBJWATCH_H__
00101 

Generated for Crystal Space by doxygen 1.2.14