00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __PEEKABOT_FACTORY_INFORMER_HH
00019 #define __PEEKABOT_FACTORY_INFORMER_HH
00020
00021
00022 #include <boost/function.hpp>
00023
00024 #include "Types.hh"
00025 #include "Factory.hh"
00026 #include "Singleton.hh"
00027
00028
00029 namespace peekabot
00030 {
00031
00032
00033
00034 template<class FactorySingleton>
00035 class FactoryInformer
00036 {
00037 public:
00038 typedef typename FactorySingleton::InstanceType FactoryType;
00039 typedef typename FactoryType::IdentifierTypeType GUIDType;
00040 typedef typename FactoryType::AbstractProductType AbstractProduct;
00041 typedef typename FactoryType::ProductCreatorType ProductCreatorType;
00042
00043 FactoryInformer(
00044 GUIDType guid,
00045 ProductCreatorType creator) throw()
00046 : m_guid(guid)
00047 {
00048 FactorySingleton::instance().register_product(m_guid, creator);
00049 }
00050
00051 ~FactoryInformer() throw()
00052 {
00053 FactorySingleton::instance().deregister_product(m_guid);
00054 }
00055
00056 GUIDType get_guid() const throw()
00057 {
00058 return m_guid;
00059 }
00060
00061 private:
00062 GUIDType m_guid;
00063 };
00064
00065
00066
00067 }
00068
00069
00070 #endif // __PEEKABOT_FACTORY_INFORMER_HH