view_factory.h

Go to the documentation of this file.
00001 //--------------------------------------------------
00011 //---------------------------------------------------
00012 
00013 #ifndef IMEDGINEVIEWFACTORY_H
00014 #define IMEDGINEVIEWFACTORY_H
00015 
00016 #include "view.h"
00017 #include "../global/global_definitions.h"
00018 
00019 #include <map>
00020 
00021 namespace imedgine 
00022 {
00023 
00024   template <class ViewType>
00025       view_pointer_type createView()
00026   {
00027     return(view_pointer_type(new ViewType));  
00028   }
00029 
00030   //--------------------------------------------------
00042   //---------------------------------------------------
00043 
00044   class ViewFactory
00045   {
00046   public:
00047      
00048     //--------------------------------------------------
00051 
00052     ViewFactory();
00053     
00054     //--------------------------------------------------
00057 
00058     virtual ~ViewFactory();
00059 
00060     //--------------------------------------------------
00065 
00066     view_pointer_type getView(view_type requested_view); 
00067 
00068     //--------------------------------------------------
00076 
00077     template <class ViewType> 
00078     void registerViewType(view_type key) 
00079     {   
00080       view_map_.insert(std::make_pair(key, createView<ViewType>));
00081     }
00082       
00083   protected:
00084      
00085     typedef view_pointer_type (*creatorFunctionType)();  
00086     typedef std::map<view_type, creatorFunctionType> view_map_type;
00087     
00088     //--------------------------------------------
00091     
00092     view_map_type view_map_;
00093   };
00094 
00095 }
00096 
00097 #endif

Generated on Sun Aug 13 18:19:41 2006 for iMEDgine by  doxygen 1.4.6