[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paragui-cvs] CVS: paragui/include pgfactory.h,1.5,1.6
From: |
Alexander Pipelka <address@hidden> |
Subject: |
[paragui-cvs] CVS: paragui/include pgfactory.h,1.5,1.6 |
Date: |
Wed, 26 Jun 2002 08:36:45 -0400 |
Update of /cvsroot/paragui/paragui/include
In directory subversions:/tmp/cvs-serv18523/include
Modified Files:
pgfactory.h
Log Message:
bit more of abstraction on PG_Factory :))
Index: pgfactory.h
===================================================================
RCS file: /cvsroot/paragui/paragui/include/pgfactory.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** pgfactory.h 26 Jun 2002 12:21:02 -0000 1.5
--- pgfactory.h 26 Jun 2002 12:36:42 -0000 1.6
***************
*** 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
--- 16,52 ----
};
! template<class H>
! class PG_FactoryHolder : public PG_Singleton< PG_FactoryHolder<H> > {
public:
typedef PG_Widget* (*CREATEFN)(PG_Widget* parent);
! template<class T> static void RegisterClass(H classname) {
GetInstance().RegisterCreateFn(classname,
(CREATEFN)&PG_FactoryObject<T>::CreateObject);
}
! static PG_Widget* CreateObject(H classname, PG_Widget* parent = NULL) {
! CREATEFN create = GetInstance().creator_map[classname];
!
! if(create == NULL) {
! return NULL;
! }
!
! return create(parent);
! }
!
protected:
! void RegisterCreateFn(H classname, CREATEFN fn) {
! creator_map[classname] = fn;
! }
! std::map< H, PG_FactoryHolder<H>::CREATEFN > creator_map;
! friend class PG_Singleton< PG_FactoryHolder<H> >;
};
+
+ typedef PG_FactoryHolder<std::string> PG_Factory;
#endif // PG_FACTORY_H
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paragui-cvs] CVS: paragui/include pgfactory.h,1.5,1.6,
Alexander Pipelka <address@hidden> <=