SpikeStream Library  0.2
ConnectionGroupInfo.cpp
Go to the documentation of this file.
00001 //SpikeStream includes
00002 #include "ConnectionGroupInfo.h"
00003 #include "GlobalVariables.h"
00004 #include "SpikeStreamException.h"
00005 using namespace spikestream;
00006 
00007 
00009 ConnectionGroupInfo::ConnectionGroupInfo(){
00010     id = 0;
00011     description = "undefined";
00012     fromNeuronGroupID = 0;
00013     toNeuronGroupID = 0;
00014 }
00015 
00016 
00018 ConnectionGroupInfo::ConnectionGroupInfo(unsigned int id, const QString& desc, unsigned int fromID, unsigned int toID, QHash<QString, double> paramMap, const SynapseType& synapseType){
00019         //Check that name and description will fit in the database
00020     if(desc.size() > MAX_DATABASE_DESCRIPTION_LENGTH)
00021         throw SpikeStreamException("ConnectionGroup: Description length exceeds maximum possible size in database.");
00022 
00023     this->id = id;
00024     this->description = desc;
00025     this->fromNeuronGroupID = fromID;
00026     this->toNeuronGroupID = toID;
00027         this->synapseType = synapseType;
00028     this->parameterMap = paramMap;
00029 }
00030 
00031 
00033 ConnectionGroupInfo::ConnectionGroupInfo(const ConnectionGroupInfo& conGrpInfo){
00034     this->id = conGrpInfo.id;
00035     this->description = conGrpInfo.description;
00036     this->fromNeuronGroupID = conGrpInfo.fromNeuronGroupID;
00037     this->toNeuronGroupID = conGrpInfo.toNeuronGroupID;
00038         this->synapseType = conGrpInfo.synapseType;
00039     this->parameterMap = conGrpInfo.parameterMap;
00040 }
00041 
00042 
00044 ConnectionGroupInfo::~ConnectionGroupInfo(){
00045 }
00046 
00047 
00048 /*--------------------------------------------------------- */
00049 /*-----                PUBLIC METHODS                 ----- */
00050 /*--------------------------------------------------------- */
00051 
00053 ConnectionGroupInfo& ConnectionGroupInfo::operator=(const ConnectionGroupInfo& rhs){
00054     //Check for self assignment
00055     if(this == &rhs)
00056         return *this;
00057 
00058     this->id = rhs.id;
00059     this->description = rhs.description;
00060     this->fromNeuronGroupID = rhs.fromNeuronGroupID;
00061     this->toNeuronGroupID = rhs.toNeuronGroupID;
00062         this->synapseType = rhs.synapseType;
00063     this->parameterMap = rhs.parameterMap;
00064 
00065     return *this;
00066 }
00067 
00068 
00070 double ConnectionGroupInfo::getParameter(const QString &parameterName){
00071         if(parameterMap.contains(parameterName))
00072                 return parameterMap[parameterName];
00073         throw SpikeStreamException("Parameter '" + parameterName + "' not found in parameter map.");
00074 }
00075 
00076 
00078 QString ConnectionGroupInfo::getParameterXML(){
00079     QString tmpStr = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
00080     tmpStr += "<connection_group_parameters>";
00081     for(QHash<QString, double>::iterator iter = parameterMap.begin(); iter != parameterMap.end(); ++iter){
00082         tmpStr +="<parameter>";
00083         tmpStr += "<name>" + iter.key() + "</name>";
00084         tmpStr += "<value>" + QString::number(iter.value()) + "</value>";
00085         tmpStr += "</parameter>";
00086     }
00087     tmpStr += "</connection_group_parameters>";
00088     return tmpStr;
00089 }
00090 
00091 
00093 bool ConnectionGroupInfo::hasParameter(const QString &parameterName){
00094         return parameterMap.contains(parameterName);
00095 }
00096 
00097 
 All Classes Files Functions Variables Typedefs Defines