resource.h
Go to the documentation of this file.
00001 
00063 #ifndef COB_3D_MAPPING_TOOLS_GUI_RESOURCE_H_
00064 #define COB_3D_MAPPING_TOOLS_GUI_RESOURCE_H_
00065 
00066 #include <map>
00067 
00068 #include "cob_3d_mapping_tools/gui/view.h"
00069 
00070 namespace Gui
00071 {
00072   /* ------------------------*/
00073  /* --------- Base ---------*/
00074 /* ------------------------*/
00075   class ResourceBase
00076   {
00077   public:
00078     virtual void releaseView(const std::string&)=0;
00079     virtual void resourceChanged()=0;
00080   };
00081 
00082 
00083   /* ----------------------------*/
00084  /* --------- Resource ---------*/
00085 /* ----------------------------*/
00086   template<typename RT>
00087   class Resource : public ResourceBase
00088   {
00089   public:
00090     Resource(const std::string& name, const typename RT::DataTypePtr& data) : name_(name), data_(data) { }
00091     ~Resource() { std::cout << "resource destroyed" << std::endl; }
00092 
00093     // --- delegated construction ---
00094     template<typename VT> View<RT, VT>* createView(const std::string& name) {return createView<VT>(name,VT());}
00095 
00096     inline typename RT::DataTypePtr& getData() { return data_; }
00097     void releaseView(const std::string& name) { views_.erase(name); }
00098     void resourceChanged();
00099 
00100   private:
00101     // --- specializations ---
00102     template<typename VT> View<RT, VT>* createView(const std::string& name,ViewTypes::View2D);
00103     template<typename VT> View<RT, VT>* createView(const std::string& name,ViewTypes::ViewText);
00104 
00105     std::string name_;
00106     typename RT::DataTypePtr data_;
00107     std::map<std::string, ViewBase*> views_;
00108   };
00109 }
00110 
00111 #endif


cob_3d_mapping_tools
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:04:27