Sirikata
libspace/include/sirikata/space/SpaceContext.hpp
Go to the documentation of this file.
00001 /*  Sirikata
00002  *  SpaceContext.hpp
00003  *
00004  *  Copyright (c) 2009, Ewen Cheslack-Postava
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions are
00009  *  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
00014  *    the documentation and/or other materials provided with the
00015  *    distribution.
00016  *  * Neither the name of Sirikata nor the names of its contributors may
00017  *    be used to endorse or promote products derived from this software
00018  *    without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00021  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00022  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00023  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00024  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00025  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00026  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00027  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00028  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00029  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031  */
00032 
00033 #ifndef _SIRIKATA_SPACE_CONTEXT_HPP_
00034 #define _SIRIKATA_SPACE_CONTEXT_HPP_
00035 
00036 #include <sirikata/space/Platform.hpp>
00037 #include <sirikata/core/service/Context.hpp>
00038 #include <sirikata/core/util/SpaceObjectReference.hpp>
00039 #include <sirikata/space/Trace.hpp>
00040 #include <sirikata/core/odp/SST.hpp>
00041 #include <sirikata/core/ohdp/SST.hpp>
00042 
00043 namespace Sirikata {
00044 
00045 class ServerMessageRouter;
00046 class ServerMessageDispatcher;
00047 
00048 class Forwarder;
00049 class MockForwarder;
00050 
00051 class CoordinateSegmentation;
00052 
00053 class ObjectHostSessionManager;
00054 class ObjectSessionManager;
00055 
00056 
00062 class SIRIKATA_SPACE_EXPORT SpaceContext : public Context {
00063 public:
00064     SpaceContext(const String& name, ServerID _id, ODPSST::ConnectionManager* sstConnMgr, OHDPSST::ConnectionManager* ohsstConnMgr, Network::IOService* ios, Network::IOStrand* strand, const Time& epoch, Trace::Trace* _trace, const Duration& duration = Duration::zero());
00065     ~SpaceContext();
00066 
00067     const String& name() { return mName; }
00068 
00069     ServerID id() const {
00070         return mID.read();
00071     }
00072 
00073     ServerMessageRouter* serverRouter() const {
00074         return mServerRouter.read();
00075     }
00076 
00077     ServerMessageDispatcher* serverDispatcher() const {
00078         return mServerDispatcher.read();
00079     }
00080 
00081     CoordinateSegmentation* cseg() const {
00082         return mCSeg.read();
00083     }
00084 
00085     ObjectSessionManager* objectSessionManager() const {
00086         return mObjectSessionManager;
00087     }
00088 
00089     ObjectHostSessionManager* ohSessionManager() const {
00090         return mObjectHostSessionManager;
00091     }
00092 
00093     ODPSST::ConnectionManager* sstConnectionManager() const {
00094         return mSSTConnMgr;
00095     }
00096 
00097     OHDPSST::ConnectionManager* ohSSTConnectionManager() const {
00098         return mOHSSTConnMgr;
00099     }
00100 
00101     SpaceTrace* spacetrace() const { return mSpaceTrace; }
00102 
00103 private:
00104     // Allow these classes to set their corresponding fields in SpaceContext
00105     friend class ServerMessageRouter;
00106     friend class ServerMessageDispatcher;
00107     friend class ObjectSessionManager;
00108     friend class ObjectHostSessionManager;
00109     friend class CoordinateSegmentation;
00110 
00111     const String mName;
00112 
00113     Sirikata::AtomicValue<ServerID> mID;
00114 
00115     Sirikata::AtomicValue<ServerMessageRouter*> mServerRouter;
00116     Sirikata::AtomicValue<ServerMessageDispatcher*> mServerDispatcher;
00117 
00118     Sirikata::AtomicValue<CoordinateSegmentation*> mCSeg;
00119 
00120     Sirikata::AtomicValue<ObjectHostSessionManager*> mObjectHostSessionManager;
00121     Sirikata::AtomicValue<ObjectSessionManager*> mObjectSessionManager;
00122 
00123     Sirikata::AtomicValue<ODPSST::ConnectionManager*> mSSTConnMgr;
00124 
00125     Sirikata::AtomicValue<OHDPSST::ConnectionManager*> mOHSSTConnMgr;
00126 
00127     SpaceTrace* mSpaceTrace;
00128 }; // class SpaceContext
00129 
00130 } // namespace Sirikata
00131 
00132 #endif //_SIRIKATA_SPACE_CONTEXT_HPP_