SpikeStream Nemo Plugin  0.2
STDPFunctions.cpp
Go to the documentation of this file.
00001 //SpikeStream includes
00002 #include "SpikeStreamException.h"
00003 #include "StandardSTDPFunction.h"
00004 #include "StepSTDPFunction.h"
00005 #include "STDPFunctions.h"
00006 using namespace spikestream;
00007 
00008 //Declare static variables
00009 unsigned STDPFunctions::STANDARD_STDP = 0;
00010 unsigned STDPFunctions::STEP_STDP = 1;
00011 bool STDPFunctions::initialized = false;
00012 QHash<unsigned, AbstractSTDPFunction*> STDPFunctions::functionMap;
00013 
00014 
00015 /*----------------------------------------------------------*/
00016 /*-----                 PUBLIC METHODS                 -----*/
00017 /*----------------------------------------------------------*/
00018 
00020 void STDPFunctions::cleanup(){
00021         for(QHash<unsigned, AbstractSTDPFunction*>::iterator iter = functionMap.begin(); iter != functionMap.end(); ++iter)
00022                 delete iter.value();
00023         functionMap.clear();
00024         initialized = false;
00025 }
00026 
00027 
00029 timestep_t STDPFunctions::getApplySTDPInterval(unsigned functionID){
00030         checkFunctionID(functionID);
00031         return functionMap[functionID]->getApplySTDPInterval();
00032 }
00033 
00034 
00036 QHash<QString, double> STDPFunctions::getParameters(unsigned functionID){
00037         checkInitialization();
00038         checkFunctionID(functionID);
00039         return functionMap[functionID]->getParameters();
00040 }
00041 
00042 
00044 void STDPFunctions::setParameters(unsigned functionID, QHash<QString, double>& newParameterMap){
00045         checkInitialization();
00046         checkFunctionID(functionID);
00047         functionMap[functionID]->setParameters(newParameterMap);
00048 }
00049 
00050 
00052 QHash<QString, double> STDPFunctions::getDefaultParameters(unsigned functionID){
00053         checkInitialization();
00054         checkFunctionID(functionID);
00055         return functionMap[functionID]->getDefaultParameters();
00056 }
00057 
00058 
00060 QList<ParameterInfo> STDPFunctions::getParameterInfoList(unsigned functionID){
00061         checkInitialization();
00062         checkFunctionID(functionID);
00063         return functionMap[functionID]->getParameterInfoList();
00064 }
00065 
00066 
00069 QString STDPFunctions::getFunctionDescription(unsigned functionID){
00070         if(functionID == STANDARD_STDP)
00071                 return "Standard STDP function.";
00072         else if(functionID == STEP_STDP)
00073                 return "Step STDP function.";
00074         throw SpikeStreamException("STDP Function ID not recognized: " + QString::number(functionID));
00075 }
00076 
00077 
00079 QList<unsigned> STDPFunctions::getFunctionIDs(){
00080         QList<unsigned> tmpList;
00081         tmpList.append(STANDARD_STDP);
00082         tmpList.append(STEP_STDP);
00083         return tmpList;
00084 }
00085 
00086 
00090 float* STDPFunctions::getPreArray(unsigned functionID){
00091         checkInitialization();
00092         checkFunctionID(functionID);
00093         return functionMap[functionID]->getPreArray();
00094 }
00095 
00096 
00100 int STDPFunctions::getPreLength(unsigned functionID){
00101         checkInitialization();
00102         checkFunctionID(functionID);
00103         return functionMap[functionID]->getPreLength();
00104 }
00105 
00106 
00110 float* STDPFunctions::getPostArray(unsigned functionID){
00111         checkInitialization();
00112         checkFunctionID(functionID);
00113         return functionMap[functionID]->getPostArray();
00114 }
00115 
00116 
00120 int STDPFunctions::getPostLength(unsigned functionID){
00121         checkInitialization();
00122         checkFunctionID(functionID);
00123         return functionMap[functionID]->getPostLength();
00124 }
00125 
00126 
00130 float STDPFunctions::getMinExcitatoryWeight(unsigned functionID){
00131         checkInitialization();
00132         checkFunctionID(functionID);
00133         return functionMap[functionID]->getMinExcitatoryWeight();
00134 }
00135 
00136 
00140 float STDPFunctions::getMaxExcitatoryWeight(unsigned functionID){
00141         checkInitialization();
00142         checkFunctionID(functionID);
00143         return functionMap[functionID]->getMaxExcitatoryWeight();
00144 }
00145 
00146 
00150 float STDPFunctions::getMinInhibitoryWeight(unsigned functionID){
00151         checkInitialization();
00152         checkFunctionID(functionID);
00153         return functionMap[functionID]->getMinInhibitoryWeight();
00154 }
00155 
00156 
00160 float STDPFunctions::getMaxInhibitoryWeight(unsigned functionID){
00161         checkInitialization();
00162         checkFunctionID(functionID);
00163         return functionMap[functionID]->getMaxInhibitoryWeight();
00164 }
00165 
00166 
00168 float STDPFunctions::getReward(unsigned functionID){
00169         checkInitialization();
00170         checkFunctionID(functionID);
00171         return functionMap[functionID]->getReward();
00172 }
00173 
00174 
00176 void STDPFunctions::print(unsigned functionID){
00177         checkInitialization();
00178         checkFunctionID(functionID);
00179         functionMap[functionID]->print();
00180 }
00181 
00182 /*----------------------------------------------------------*/
00183 /*-----                PRIVATE METHODS                 -----*/
00184 /*----------------------------------------------------------*/
00185 
00187 void STDPFunctions::checkFunctionID(unsigned functionID){
00188         if(!functionMap.contains(functionID))
00189                 throw SpikeStreamException("Function ID not recognized: " + QString::number(functionID));
00190 }
00191 
00192 
00194 void STDPFunctions::checkInitialization(){
00195         if(initialized)
00196                 return;
00197         initialize();
00198 }
00199 
00200 
00203 void STDPFunctions::initialize(){
00204         //Create a class for each STDP function
00205         functionMap[STANDARD_STDP] = new StandardSTDPFunction();
00206         functionMap[STEP_STDP] = new StepSTDPFunction();
00207 
00208         //Record the fact that initialization has now been carried out.
00209         initialized = true;
00210 }
00211 
00212 
 All Classes Files Functions Variables Typedefs Defines