iSpike  2.1
Spike conversion library for robotics
D:/Home/Programs/iSpike/src/Channel/InputChannel/InputChannelFactory.cpp
Go to the documentation of this file.
00001 //iSpike includes
00002 #include "iSpike/Channel/InputChannel/InputChannelFactory.hpp"
00003 #include <iSpike/Channel/InputChannel/JointInputChannel.hpp>
00004 #include <iSpike/Channel/InputChannel/VisualInputChannel.hpp>
00005 #include <iSpike/Reader/AngleReader.hpp>
00006 #include "iSpike/ISpikeException.hpp"
00007 #include "iSpike/Log/Log.hpp"
00008 using namespace ispike;
00009 
00010 
00013 InputChannelFactory::InputChannelFactory(){
00014         channelList.push_back(JointInputChannel().getChannelDescription());
00015         channelList.push_back(VisualInputChannel().getChannelDescription());
00016         printInputChannels();
00017 }
00018 
00019 
00021 vector<Description> InputChannelFactory::getAllChannels() {
00022         return channelList;
00023 }
00024 
00025 
00027 InputChannel* InputChannelFactory::create(Description& desc, Reader* reader, map<string, Property>& channelProperties) {
00028         if(desc.getName() == "Joint Input Channel"){
00029                 JointInputChannel* channel = new JointInputChannel();
00030                 channel->initialize((AngleReader*)reader, channelProperties);
00031                 return channel;
00032         }
00033         else if(desc.getName() == "Visual Input Channel"){
00034                 VisualInputChannel* channel = new VisualInputChannel();
00035                 channel->initialize((VisualReader*)reader, channelProperties);
00036                 return channel;
00037         }
00038         throw ISpikeException("Invalid channel name");
00039 }
00040 
00041 
00042 
00044 map<string, Property> InputChannelFactory::getDefaultProperties(Description& desc){
00045         if(desc.getName() == "Joint Input Channel") {
00046                 return JointInputChannel().getProperties();
00047         }
00048         else if(desc.getName() == "Visual Input Channel") {
00049                 return VisualInputChannel().getProperties();
00050         }
00051         throw ISpikeException("Invalid input channel");
00052 }
00053 
00054 
00056 void InputChannelFactory::printInputChannels(){
00057         for(size_t i=0; i<channelList.size(); ++i)
00058                 LOG(LOG_DEBUG)<<"Input Channel: "<<channelList[i].getName()<<", "<<channelList[i].getDescription();
00059 }
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines