SpikeStream Library  0.2
AnalysisInfo.cpp
Go to the documentation of this file.
00001 #include "AnalysisInfo.h"
00002 #include "SpikeStreamAnalysisException.h"
00003 using namespace spikestream;
00004 
00006 #define DEFAULT_NUMBER_OF_THREADS 5
00007 
00008 
00010 AnalysisInfo::AnalysisInfo(){
00011         reset();
00012 }
00013 
00014 
00016 AnalysisInfo::AnalysisInfo(unsigned int analysisID, unsigned int networkID, unsigned int archiveID, const QDateTime& startDateTime, const QString& description, const QHash<QString, double>& parameterMap, unsigned int analysisType){
00017         this->id = analysisID;
00018         this->networkID = networkID;
00019         this->archiveID = archiveID;
00020         this->startDateTime = startDateTime;
00021         this->parameterMap = parameterMap;
00022         this->description = description;
00023         this->analysisType = analysisType;
00024         this->numberOfThreads = DEFAULT_NUMBER_OF_THREADS;
00025 }
00026 
00027 
00029 AnalysisInfo::AnalysisInfo(const AnalysisInfo& analysisInfo){
00030         this->id = analysisInfo.id;
00031         this->networkID = analysisInfo.networkID;
00032         this->archiveID = analysisInfo.archiveID;
00033         this->startDateTime = analysisInfo.startDateTime;
00034         this->parameterMap = analysisInfo.parameterMap;
00035         this->description = analysisInfo.description;
00036         this->analysisType = analysisInfo.analysisType;
00037         this->numberOfThreads = analysisInfo.numberOfThreads;
00038 }
00039 
00040 
00041 /*----------------------------------------------------------*/
00042 /*-----                PUBLIC METHODS                  -----*/
00043 /*----------------------------------------------------------*/
00044 
00046 AnalysisInfo& AnalysisInfo::operator=(const AnalysisInfo& rhs){
00047         //Check for self assignment
00048         if(this == &rhs)
00049                 return *this;
00050 
00051         this->id = rhs.id;
00052         this->networkID = rhs.networkID;
00053         this->archiveID = rhs.archiveID;
00054         this->startDateTime = rhs.startDateTime;
00055         this->parameterMap = rhs.parameterMap;
00056         this->description = rhs.description;
00057         this->analysisType = rhs.analysisType;
00058         this->numberOfThreads = rhs.numberOfThreads;
00059 
00060         return *this;
00061 }
00062 
00063 
00065 double AnalysisInfo::getParameter(const QString& paramKey){
00066         if(!parameterMap.contains(paramKey))
00067                 throw SpikeStreamAnalysisException("Parameter key '" + paramKey + "' is not present in the parameter map.");
00068         return parameterMap[paramKey];
00069 }
00070 
00071 
00073 QString AnalysisInfo::getParameterXML() const{
00074         QString tmpStr = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
00075         tmpStr += "<analysis_parameters>";
00076         for(QHash<QString, double>::const_iterator iter = parameterMap.begin(); iter != parameterMap.end(); ++iter){
00077                 tmpStr +="<parameter>";
00078                 tmpStr += "<name>" + iter.key() + "</name>";
00079                 tmpStr += "<value>" + QString::number(iter.value()) + "</value>";
00080                 tmpStr += "</parameter>";
00081         }
00082         tmpStr += "</analysis_parameters>";
00083         return tmpStr;
00084 }
00085 
00086 
00088 void AnalysisInfo::reset(){
00089         this->id = 0;
00090         this->networkID = 0;
00091         this->archiveID = 0;
00092         this->startDateTime = QDateTime::currentDateTime();
00093         this->description = "Untitled";
00094         this->analysisType = 0;
00095         this->parameterMap.clear();
00096         this->numberOfThreads = DEFAULT_NUMBER_OF_THREADS;
00097 }
00098 
00099 
00101 void AnalysisInfo::setParameter(const QString& paramKey, double paramValue){
00102         parameterMap[paramKey] = paramValue;
00103 }
00104 
 All Classes Files Functions Variables Typedefs Defines