SpikeStream Library
0.2
|
00001 #include "NeuronGroupInfo.h" 00002 #include "GlobalVariables.h" 00003 #include "SpikeStreamException.h" 00004 using namespace spikestream; 00005 00007 NeuronGroupInfo::NeuronGroupInfo(){ 00008 this->id = 0; 00009 this->name = "undefined"; 00010 this->description = "undefined"; 00011 } 00012 00013 00015 NeuronGroupInfo::NeuronGroupInfo(unsigned int id, const QString& name, const QString& desc, const QHash<QString, double>& paramMap, const NeuronType& neuronType){ 00016 //Check that name and description will fit in the database 00017 if(name.size() > MAX_DATABASE_NAME_LENGTH || desc.size() > MAX_DATABASE_DESCRIPTION_LENGTH) 00018 throw SpikeStreamException("NeuronGroup: Name and/or description length exceeds maximum possible size in database."); 00019 00020 this->id = id; 00021 this->name = name; 00022 this->description = desc; 00023 this->parameterMap = paramMap; 00024 this->neuronType = neuronType; 00025 } 00026 00027 00029 NeuronGroupInfo::NeuronGroupInfo(const NeuronGroupInfo& neurGrpInfo){ 00030 this->id = neurGrpInfo.id; 00031 this->name = neurGrpInfo.name; 00032 this->description = neurGrpInfo.description; 00033 this->parameterMap = neurGrpInfo.parameterMap; 00034 this->neuronType = neurGrpInfo.neuronType; 00035 } 00036 00037 00039 NeuronGroupInfo::~NeuronGroupInfo(){ 00040 } 00041 00042 00043 /*--------------------------------------------------------- */ 00044 /*----- PUBLIC METHODS ----- */ 00045 /*--------------------------------------------------------- */ 00046 00048 NeuronGroupInfo& NeuronGroupInfo::operator=(const NeuronGroupInfo& rhs) { 00049 // Check for self-assignment! 00050 if (this == &rhs) // Same object? 00051 return *this; // Yes, so skip assignment, and just return *this. 00052 00053 this->id = rhs.id; 00054 this->name = rhs.name; 00055 this->description = rhs.description; 00056 this->parameterMap = rhs.parameterMap; 00057 this->neuronType = rhs.neuronType; 00058 00059 return *this; 00060 } 00061 00062 00064 QString NeuronGroupInfo::getParameterXML(){ 00065 QString tmpStr = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"; 00066 tmpStr += "<neuron_group_parameters>"; 00067 for(QHash<QString, double>::iterator iter = parameterMap.begin(); iter != parameterMap.end(); ++iter){ 00068 tmpStr +="<parameter>"; 00069 tmpStr += "<name>" + iter.key() + "</name>"; 00070 tmpStr += "<value>" + QString::number(iter.value()) + "</value>"; 00071 tmpStr += "</parameter>"; 00072 } 00073 tmpStr += "</neuron_group_parameters>"; 00074 return tmpStr; 00075 } 00076 00077