mapper_factory.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __PLUGINS_PLAYER_MAPPER_FACTORY_H_
00024 #define __PLUGINS_PLAYER_MAPPER_FACTORY_H_
00025
00026 #include "mapper.h"
00027
00028 namespace fawkes {
00029 class Interface;
00030 class ObjectPositionInterface;
00031 }
00032
00033 namespace PlayerCc {
00034 class ClientProxy;
00035 class Position2dProxy;
00036 }
00037
00038 class PlayerMapperFactory
00039 {
00040 public:
00041 static PlayerProxyFawkesInterfaceMapper *create_mapper(std::string varname,
00042 fawkes::Interface *interface,
00043 PlayerCc::ClientProxy *proxy);
00044
00045
00046 private:
00047 PlayerMapperFactory() {}
00048
00049 template <class FawkesInterfaceType, class PlayerProxyType, class MapperType>
00050 static PlayerProxyFawkesInterfaceMapper * try_create(std::string varname,
00051 fawkes::Interface *interface,
00052 PlayerCc::ClientProxy *proxy);
00053 };
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 template <class FawkesInterfaceType, class PlayerProxyType, class MapperType>
00066 PlayerProxyFawkesInterfaceMapper *
00067 PlayerMapperFactory::try_create(std::string varname,
00068 fawkes::Interface *interface,
00069 PlayerCc::ClientProxy *proxy)
00070 {
00071 FawkesInterfaceType *fi;
00072 if ( (fi = dynamic_cast<FawkesInterfaceType *>(interface)) != NULL ) {
00073 PlayerProxyType *pp;
00074 if ( (pp = dynamic_cast<PlayerProxyType *>(proxy)) != NULL ) {
00075 return new MapperType(varname, fi, pp);
00076 } else {
00077 return NULL;
00078 }
00079 } else {
00080 return NULL;
00081 }
00082 }
00083
00084
00085 #endif