map-manager.h

Go to the documentation of this file.
00001 /*
00002  * map-manager.h
00003  *
00004  * Copyright (C) 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  * Server-side map management.
00031  */
00032 
00033 #ifndef AESOP_MAP_MANAGER_H__
00034 #define AESOP_MAP_MANAGER_H__
00035 
00036 // includes --------------------------------------------------------------------
00037 #include "map-dynamics/map-dynamics.h"
00038 #include "story/story.h"
00039 
00040 
00041 namespace aesop {
00042 
00043 /// \ingroup aesop_map_mgmt
00044 /// \defgroup map_manager Map Manager
00045 ///
00046 /// This library helps to maintain lists of active (in-memory) maps.
00047 /*@{*/
00048 
00049 
00050 /// Object that helps the server (and rules engine) manage loaded maps,
00051 /// including the dynamics.
00052 ///
00053 /// This map manager is used on the client and the server.  So there is no
00054 /// dependency on specific rendering engines or input allowed, \e etc. 
00055 ///
00056 /// NOTE: (to implementers) these calls must be threadsafe!
00057 ///
00058 /// Loading maps is *very* expensive and must be on separate threads without
00059 /// locking mutex's for a long time etc.
00060 class MapManager {
00061 public:
00062         // public typedefs -----------------------------------------------------
00063         struct iterator_t {
00064         private:
00065                 byte_t          opaque[8 * sizeof(long)];
00066         };
00067 
00068         // virtual destructor --------------------------------------------------
00069         virtual ~MapManager(void) throw();
00070 
00071         // aesop::MapManager class interface methods ---------------------------
00072         virtual void clear(void) = 0;
00073         virtual void requestLoad(IN const char * id) = 0;
00074         virtual smart_ptr<MapDynamics> getMap(IN const char * id) = 0;
00075         virtual void tickMaps(IN float seconds) = 0;
00076         virtual void getIterator(OUT iterator_t& i) = 0;
00077         virtual bool getNextMap(IO iterator_t& i,
00078                                 OUT smart_ptr<MapDynamics>& map) = 0;
00079 
00080         // static factory methods ----------------------------------------------
00081         static smart_ptr<MapManager> create(IN smart_ptr<Datahash>& params,
00082                                 IN smart_ptr<story::Story>& story);
00083 };
00084 
00085 
00086 
00087 };      // aesop namespace
00088 
00089 #endif  // AESOP_MAP_MANAGER_H__
00090