map-dynamics.h

Go to the documentation of this file.
00001 /*
00002  * map-dynamics.h
00003  *
00004  * Copyright (C) 2008,2009  Thomas A. Vaughan
00005  * All rights reserved.
00006  *
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *     * Redistributions of source code must retain the above copyright
00011  *       notice, this list of conditions and the following disclaimer.
00012  *     * Redistributions in binary form must reproduce the above copyright
00013  *       notice, this list of conditions and the following disclaimer in the
00014  *       documentation and/or other materials provided with the distribution.
00015  *     * Neither the name of the <organization> nor the
00016  *       names of its contributors may be used to endorse or promote products
00017  *       derived from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THOMAS A. VAUGHAN ''AS IS'' AND ANY
00020  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00021  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00022  * DISCLAIMED. IN NO EVENT SHALL THOMAS A. VAUGHAN BE LIABLE FOR ANY
00023  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00024  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00026  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *
00030  */
00031 
00032 #ifndef AESOP_MAP_DYNAMICS_H__
00033 #define AESOP_MAP_DYNAMICS_H__
00034 
00035 
00036 // includes --------------------------------------------------------------------
00037 #include "aesop-map/map.h"
00038 #include "aesop-physics/aesop-physics.h"
00039 
00040 
00041 // forward decl
00042 class Datahash;
00043 
00044 
00045 namespace aesop {
00046 
00047 
00070 
00073 
00074 typedef void (*zone_obj_iteration_fn)(
00075                                 IN smart_ptr<Instance>& instance,
00076                                 IN smart_ptr<PhysicsObject>& obj,
00077                                 IN void * context);
00078 
00079 
00081 class ObjectContext {
00082 public:
00083         // virtual destructor --------------------------------------------------
00084         virtual ~ObjectContext(void) throw();
00085 };
00086 
00087 
00088 
00090 class MapDynamics {
00091 public:
00092         // virtual destructor --------------------------------------------------
00093         virtual ~MapDynamics(void) throw();
00094 
00095         // aesop::MapDynamics class interface methods -------------------------
00096         virtual smart_ptr<Map> getMap(void) = 0;
00097         virtual smart_ptr<PhysicsWorld> getPhysics(void) = 0;
00098         virtual smart_ptr<PhysicsObject> addInstance(
00099                                 IN smart_ptr<Instance>& instance) = 0;
00100         virtual void removeObject(IN smart_ptr<PhysicsObject>& obj) = 0;
00101         virtual void tickMap(IN float seconds) = 0;
00102 
00105         virtual void iterateInstancesInZone(IN Zone * zone,
00106                                 IN zone_obj_iteration_fn fn,
00107                                 IN void * context) = 0;
00108 
00109         // static factory methods ----------------------------------------------
00110         static smart_ptr<MapDynamics> create(IN smart_ptr<Map>& map,
00111                                 IN const Datahash * params);
00112 };
00113 
00114 
00115 
00117 smart_ptr<Instance> getInstanceFromPhysicsObject(IN smart_ptr<PhysicsObject>& obj);
00118 
00119 
00121 MapDynamics * getMapDynamicsFromPhysicsObject(IN smart_ptr<PhysicsObject>& obj);
00122 
00123 
00124 };      // aesop namespace
00125 
00126 #endif  // AESOP_MAP_DYNAMICS_H__
00127