Sirikata
liboh/plugins/environment/Environment.hpp
Go to the documentation of this file.
00001 // Copyright (c) 2011 Sirikata Authors. All rights reserved.
00002 // Use of this source code is governed by a BSD-style license that can
00003 // be found in the LICENSE file.
00004 
00005 #ifndef _SIRIKATA_ENVIRONMENT_CLIENT_SIMULATION_HPP_
00006 #define _SIRIKATA_ENVIRONMENT_CLIENT_SIMULATION_HPP_
00007 
00008 #include <sirikata/oh/Simulation.hpp>
00009 #include <sirikata/core/service/Context.hpp>
00010 
00011 #include <json_spirit/value.h>
00012 
00013 #include <sirikata/core/odp/SST.hpp>
00014 #include <sirikata/core/network/RecordSSTStream.hpp>
00015 
00016 namespace Sirikata {
00017 
00018 class HostedObject;
00019 typedef std::tr1::shared_ptr<HostedObject> HostedObjectPtr;
00020 
00024 class EnvironmentSimulation : public Simulation {
00025 public:
00026     EnvironmentSimulation(HostedObjectPtr ho, const SpaceObjectReference& pres);
00027 
00028     // Service Interface
00029     virtual void start();
00030     virtual void stop();
00031 
00032     // Invokable Interface
00033     virtual boost::any invoke(std::vector<boost::any>& params);
00034 
00035 private:
00036     void handleCreatedStream(int err, ODPSST::Stream::Ptr strm);
00037     void handleMessage(MemoryReference data);
00038 
00039     void notifyListener();
00040 
00041     void sendUpdate();
00042 
00043     HostedObjectPtr mParent;
00044     SpaceObjectReference mPresence;
00045 
00046     // The environment data
00047     json_spirit::Value mEnvironment;
00048 
00049     // Communication with the space
00050     ODPSST::Stream::Ptr mStream;
00051     RecordSSTStream<ODPSST::Stream::Ptr> mRecordStream;
00052 
00053     // Listener for updates
00054     Invokable* mListener;
00055 };
00056 
00057 } // namespace Sirikata
00058 
00059 #endif //_SIRIKATA_ENVIRONMENT_CLIENT_SIMULATION_HPP_