paragui-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paragui-cvs] CVS: paragui/include pgfactory.h,1.4,1.5


From: Alexander Pipelka <address@hidden>
Subject: [paragui-cvs] CVS: paragui/include pgfactory.h,1.4,1.5
Date: Wed, 26 Jun 2002 08:21:05 -0400

Update of /cvsroot/paragui/paragui/include
In directory subversions:/tmp/cvs-serv17281/include

Modified Files:
        pgfactory.h 
Log Message:
changed PG_Factory to singleton class



Index: pgfactory.h
===================================================================
RCS file: /cvsroot/paragui/paragui/include/pgfactory.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** pgfactory.h 26 Jun 2002 12:10:20 -0000      1.4
--- pgfactory.h 26 Jun 2002 12:21:02 -0000      1.5
***************
*** 2,7 ****
--- 2,10 ----
  #define PG_FACTORY_H
  
+ #include <map>
  #include <string>
  
+ #include "pgsingleton.h"
+ 
  class PG_Widget;
  
***************
*** 13,29 ****
  };
  
! namespace PG_Factory {
! 
!       typedef PG_Widget* (*CREATEFN)(PG_Widget* parent);
        
!       void RegisterCreateFn(const std::string& classname, CREATEFN fn);
        
!       template<class T> void RegisterClass(const std::string& classname) {
!               RegisterCreateFn(classname, 
(CREATEFN)&PG_FactoryObject<T>::CreateObject);
        }
                
!       PG_Widget* CreateObject(const std::string& classname, PG_Widget* parent 
= NULL);
        
! } // namespace PG_Factory
  
  #endif // PG_FACTORY_H
--- 16,39 ----
  };
  
! class PG_Factory : public PG_Singleton<PG_Factory> {
! public:
        
!       typedef PG_Widget* (*CREATEFN)(PG_Widget* parent);
        
!       template<class T> static void RegisterClass(const std::string& 
classname) {
!               GetInstance().RegisterCreateFn(classname, 
(CREATEFN)&PG_FactoryObject<T>::CreateObject);
        }
                
!       static PG_Widget* CreateObject(const std::string& classname, PG_Widget* 
parent = NULL);
! 
! protected:
!       
!       void RegisterCreateFn(const std::string& classname, CREATEFN fn);
        
!       std::map<std::string, PG_Factory::CREATEFN> creator_map;
!       
!       friend class PG_Singleton<PG_Factory>;
!       
! };
  
  #endif // PG_FACTORY_H




reply via email to

[Prev in Thread] Current Thread [Next in Thread]