![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /******************************************************************************* 00002 ** Copyright (c) 2009 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: DtAgentFactory.h,v $ $Revision: 1.13 $ $State: Exp $ 00007 *******************************************************************************/ 00008 00012 00013 #pragma once 00014 00015 #include <vrvCore/vrvCore.h> 00016 #include <vrvUtil/DtVirtualBaseClass.h> 00017 #include <vrvCore/DtUniqueID.h> 00018 00019 #include <boost/unordered_map.hpp> 00020 #include <string> 00021 #include <list> 00022 00023 namespace makVrv 00024 { 00025 00026 class DtDe; 00027 class DtAgentManagerInterface; 00028 class DtAgentUpdateResolverInterface; 00029 class DtAgentCreator; 00030 class DtAgent; 00031 00036 class DT_DLL_VRVCORE DtAgentFactory : public DtVirtualBaseClass 00037 { 00038 public: 00039 00040 class DtAutoUnregistrar 00041 { 00042 public: 00043 DtAutoUnregistrar( const std::string& className ) 00044 : myClassName( className ) 00045 { 00046 }; 00047 00048 ~DtAutoUnregistrar() 00049 { 00050 DtAgentFactory::autoUnregister( myClassName ); 00051 } 00052 private: 00053 std::string myClassName; 00054 }; 00055 00056 typedef DtAgentCreator* (*AutoRegisterFunction)(); 00057 00059 static DtAgentFactory& instance(DtDe& de); 00060 00062 virtual ~DtAgentFactory(); 00063 00066 virtual void registerAgentCreator(const std::string& className, 00067 DtAgentCreator* creator); 00068 00072 virtual DtAgent* createAgent(const std::string& className, 00073 DtAgentManagerInterface& sceneInterface) const; 00074 00078 virtual DtAgentUpdateResolverInterface* createResolver(const std::string& className, DtUniqueID id) const; 00079 00081 virtual void processAutoUnregisters(); 00082 00084 static bool autoRegister(const std::string& className,AutoRegisterFunction function ); 00085 static void autoUnregister( const std::string& className ); 00086 00087 protected: 00090 DtAgentFactory(DtDe& de); 00091 00092 00093 protected: 00094 typedef boost::unordered_map<std::string,DtAgentCreator*> RegistrationMap; 00095 typedef boost::unordered_map<std::string,AutoRegisterFunction> AutoRegistrationMap; 00096 typedef std::list<std::string> RemoveList; 00097 00098 DtDe& myDe; 00099 RegistrationMap myTypes; 00100 00102 static AutoRegistrationMap& autoTypes(); 00103 static RemoveList& removeTypes(); 00104 static bool& destructed(); 00105 }; 00106 }