SpikeStream Library  0.2
Network.h
Go to the documentation of this file.
00001 #ifndef NETWORK_H
00002 #define NETWORK_H
00003 
00004 //SpikeStream includes
00005 #include "ArchiveDao.h"
00006 #include "Box.h"
00007 #include "NetworkDao.h"
00008 #include "NetworkDaoThread.h"
00009 #include "NetworkInfo.h"
00010 #include "NeuronGroup.h"
00011 #include "NeuronGroupInfo.h"
00012 #include "ConnectionGroup.h"
00013 #include "ConnectionGroupInfo.h"
00014 #include "RGBColor.h"
00015 using namespace spikestream;
00016 
00017 namespace spikestream {
00018 
00021     class Network : public QObject {
00022                 Q_OBJECT
00023 
00024                 public:
00025                         Network(const QString& name, const QString& description, const DBInfo& networkDBInfo, const DBInfo& archiveDBInfo);
00026                         Network(const NetworkInfo& networkInfo, const DBInfo& networkDBInfo, const DBInfo& archiveDBInfo);
00027                         ~Network();
00028 
00029                         void addConnectionGroups(QList<ConnectionGroup*>& connectionGroupList);
00030                         void addNeuronGroups(QList<NeuronGroup*>& neuronGroupList);
00031                         void cancel();
00032                         void clearError();
00033                         bool containsNeuron(unsigned int neurID);
00034                         bool containsNeuronGroup(unsigned int neuronGroupID);//UNTESTED
00035                         void copyTempWeightsToWeights(unsigned conGrpID);//UNTESTED
00036                         void deleteConnectionGroups(QList<unsigned int>& deleteConGrpIDList);
00037                         void deleteNeuronGroups(QList<unsigned int>& deleteNeurGrpIDList);
00038                         Box getBoundingBox();
00039                         unsigned int getID() { return info.getID(); }
00040                         QString getErrorMessage();
00041                         int getConnectionCount(unsigned conGrpID);
00042                         int getConnectionGroupCount() { return connGrpMap.size(); }
00043                         QList<ConnectionGroup*> getConnectionGroups();
00044                         ConnectionGroup* getConnectionGroup(unsigned int id);
00045                         ConnectionGroupInfo getConnectionGroupInfo(unsigned int id);
00046                         QList<ConnectionGroupInfo> getConnectionGroupsInfo(unsigned int synapseTypeID);
00047                         QList<ConnectionGroupInfo> getConnectionGroupsInfo();
00048                         int getNeuronGroupCount() { return neurGrpMap.size(); }
00049                         Box getNeuronGroupBoundingBox(unsigned int neurGrpID);
00050                         NeuronGroup* getNeuronGroupFromNeuronID(unsigned neuronID);
00051                         QList<unsigned int> getNeuronGroupIDs();
00052                         QString getProgressMessage();
00053                         QList<unsigned int> getConnectionGroupIDs();
00054                         NeuronGroup* getNeuronGroup(unsigned int id);
00055                         QList<NeuronGroup*> getNeuronGroups();
00056                         NeuronGroupInfo getNeuronGroupInfo(unsigned int id);
00057                         QList<NeuronGroupInfo> getNeuronGroupsInfo();
00058                         QList<NeuronGroupInfo> getNeuronGroupsInfo(unsigned int neuronTypeID);
00059                         int getNumberOfCompletedSteps();
00060                         int getTotalNumberOfSteps();
00061                         bool isBusy();
00062                         bool isError() { return error; }
00063                         bool isPrototypeMode() { return prototypeMode; }
00064                         bool isSaved();
00065                         bool isTransient() { return transient; }
00066                         bool hasArchives();
00067                         void load();
00068                         void loadWait();
00069                         bool overlaps(const Box& box);
00070                         void save();
00071                         void setError(const QString& errorMsg);
00072                         void setConnectionGroupProperties(unsigned conGrpID, const QString& description);
00073                         void setNeuronGroupParameters(unsigned neurGrpID, QHash<QString, double> paramMap);
00074                         void setNeuronGroupProperties(unsigned neurGrpID, const QString& name, const QString& description);
00075                         void setPrototypeMode(bool mode);
00076                         void setTransient(bool transient) { this->transient = transient; }
00077                         int size();
00078 
00079                 signals:
00080                         void taskFinished();
00081 
00082                 private slots:
00083                         void connectionThreadFinished();
00084                         void neuronThreadFinished();
00085 
00086                 private:
00087                         //===========================  VARIABLES  ===========================
00089                         NetworkInfo info;
00090 
00092                         QHash<unsigned int, NeuronGroup*> neurGrpMap;
00093 
00095                         DBInfo networkDBInfo;
00096 
00098                         DBInfo archiveDBInfo;
00099 
00101                         QHash<unsigned int, ConnectionGroup*> connGrpMap;
00102 
00105                         QHash<unsigned int, RGBColor*> neuronColorMap;
00106 
00108                         bool threadRunning;     
00109 
00111                         NetworkDaoThread* neuronNetworkDaoThread;
00112 
00114                         NetworkDaoThread* connectionNetworkDaoThread;
00115 
00117                         bool error;
00118 
00120                         QString errorMessage;
00121 
00123                         QString progressMessage;
00124 
00126                         QHash<unsigned, NeuronGroup*> newNeuronGroupMap;
00127 
00129                         QHash<unsigned, ConnectionGroup*> newConnectionGroupMap;
00130 
00132                         QList<unsigned> deleteNeuronGroupIDs;
00133 
00135                         QList<unsigned> deleteConnectionGroupIDs;
00136 
00138                         int currentNeuronTask;
00139 
00141                         int currentConnectionTask;
00142 
00147                         bool prototypeMode;
00148 
00152                         bool transient;
00153 
00155                         bool neuronGroupParametersChanged;
00156 
00158                         bool connectionGroupParametersChanged;
00159 
00161                         QHash<unsigned, bool> volatileConnectionGroupMap;
00162 
00163                         static const int ADD_NEURONS_TASK = 1;
00164                         static const int DELETE_CONNECTIONS_TASK = 2;
00165                         static const int DELETE_NEURONS_TASK = 3;
00166                         static const int LOAD_NEURONS_TASK = 4;
00167                         static const int ADD_CONNECTIONS_TASK = 5;
00168                         static const int LOAD_CONNECTIONS_TASK = 6;
00169                         static const int SAVE_NETWORK_TASK = 7;
00170 
00172                         bool connectionTaskCancelled;
00173 
00175                         bool neuronTaskCancelled;
00176 
00177 
00178                         //============================  METHODS  ==============================
00179                         void checkConnectionGroupID(unsigned int id);
00180                         void checkNeuronGroupID(unsigned int id);
00181                         void checkThread();
00182                         void clearConnectionGroups();
00183                         void clearNeuronGroups();
00184                         void deleteConnectionGroupFromMemory(unsigned conGrpID);
00185                         void deleteNeuronGroupFromMemory(unsigned neurGrpID);
00186                         bool filterConnection(Connection* connection, unsigned connectionMode);
00187                         unsigned getTemporaryConGrpID();
00188                         unsigned getTemporaryNeurGrpID();
00189                         void initializeVariables();
00190                         void loadConnectionGroupsInfo();
00191                         void loadNeuronGroupsInfo();
00192                         void startAddConnectionGroups();
00193                         void startAddNeuronGroups();
00194                         void startDeleteConnectionGroups(QList<unsigned>& deleteConGrpIDList);
00195                         void startDeleteNeuronGroups(QList<unsigned>& deleteNeurGrpIDList);
00196                         void updateConnectionGroupsAfterSave();
00197                         void updateNeuronGroupsAfterSave();
00198 
00199     };
00200 
00201 }
00202 
00203 #endif//NETWORK_H
00204 
 All Classes Files Functions Variables Typedefs Defines