Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef RVE_RENDER_CLIENT_SCENE_OBJECT_H
00031 #define RVE_RENDER_CLIENT_SCENE_OBJECT_H
00032
00033 #include "forwards.h"
00034
00035 #include <rve_common/uuid.h>
00036 #include <rve_common/forwards.h>
00037
00038 #include <vector>
00039 #include <string>
00040
00041 namespace rve_render_client
00042 {
00043
00044 class Scene;
00045
00046 class SceneObject
00047 {
00048 protected:
00049 struct ContextInfo
00050 {
00051 Scene* scene;
00052 ClientContext* context;
00053 std::vector<InterfaceHandle> interfaces;
00054
00055 bool operator==(const ContextInfo& rhs)
00056 {
00057 return scene == rhs.scene && context == rhs.context;
00058 }
00059 };
00060 typedef std::vector<ContextInfo> V_ContextInfo;
00061
00062 public:
00063 void create(Scene* scene, ClientContext* context);
00064 void destroy(Scene* scene, ClientContext* context);
00065
00066 virtual void doCreate(ContextInfo& context) = 0;
00067 virtual void doDestroy(ContextInfo& context) = 0;
00068
00069 typedef std::vector<rve_common::UUID> V_UUID;
00070 virtual void getContextDependencies(V_UUID& deps) = 0;
00071
00072 void removeFromAll();
00073
00074 virtual bool addToRegistry( rve_common::RegistryPtr registry, rve_common::RegistrantWPtr registrant ) = 0;
00075 virtual bool removeFromRegistry( rve_common::RegistryPtr registry, rve_common::RegistrantWPtr registrant ) = 0;
00076
00077 protected:
00078
00079 const rve_common::UUID& getSceneID(Scene* scene);
00080
00081 template<typename T>
00082 T* getProxy(const ContextInfo& info, uint32_t proxy_index)
00083 {
00084 return static_cast<T*>(getProxy(info, proxy_index));
00085 }
00086
00087 V_ContextInfo& getContexts() { return contexts_; }
00088
00089 uint32_t addProxy(const std::string& name);
00090
00091 template<typename F>
00092 void forEachContext(F f)
00093 {
00094 V_ContextInfo::iterator it = contexts_.begin();
00095 V_ContextInfo::iterator end = contexts_.end();
00096 for (; it != end; ++it)
00097 {
00098 ContextInfo& info = *it;
00099 f(info);
00100 }
00101 }
00102
00103 template<typename P, typename F>
00104 void multiplex(F f, uint32_t proxy_index)
00105 {
00106 V_ContextInfo::iterator it = contexts_.begin();
00107 V_ContextInfo::iterator end = contexts_.end();
00108 for (; it != end; ++it)
00109 {
00110 ContextInfo& info = *it;
00111 P* proxy = getProxy<P>(info, proxy_index);
00112 f(proxy, getSceneID(info.scene));
00113 }
00114 }
00115
00116 private:
00117
00118 void* getProxy(const ContextInfo& info, uint32_t proxy_index);
00119 void lookupProxy(ContextInfo& info, const std::string& name);
00120
00121 V_ContextInfo contexts_;
00122 std::vector<std::string> proxies_;
00123 };
00124
00125 void destroySceneObject(SceneObject* obj);
00126
00127 }
00128
00129 #endif // RVE_RENDER_CLIENT_SCENE_OBJECT_H