nnfw/include/linker.h
Go to the documentation of this file.
00001 /******************************************************************************** 00002 * Neural Network Framework. * 00003 * Copyright (C) 2005-2011 Gianluca Massera <emmegian@yahoo.it> * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the Free Software * 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * 00018 ********************************************************************************/ 00019 00020 #ifndef LINKERS_H 00021 #define LINKERS_H 00022 00028 #include "nnfwconfig.h" 00029 #include "cluster.h" 00030 #include "updatable.h" 00031 #include <exception> 00032 00033 namespace farsa { 00034 00038 class FARSA_NNFW_API Linker : public Updatable { 00039 public: 00041 Linker( Cluster* from, Cluster* to, QString name = "unnamed" ); 00043 Linker( ConfigurationParameters& params, QString prefix ); 00045 Cluster* from() const { 00046 return fromc; 00047 }; 00049 Cluster* to() const { 00050 return toc; 00051 }; 00056 void configureFromVector( QString vectorName ) { 00057 getFromVector = fromc->getDelegateFor( vectorName ); 00058 fromVectorName = vectorName; 00059 } 00064 void configureToVector( QString vectorName ) { 00065 getToVector = toc->getDelegateFor( vectorName ); 00066 toVectorName = vectorName; 00067 } 00071 virtual unsigned int size() const = 0; 00075 virtual void randomize( double min, double max ) = 0; 00084 virtual void save(ConfigurationParameters& params, QString prefix); 00086 static void describe( QString type ); 00087 protected: 00089 DoubleVector& fromVector() const { 00090 return (*getFromVector)(fromc); 00091 }; 00093 DoubleVector& toVector() const { 00094 return (*getToVector)(toc); 00095 }; 00096 private: 00098 Cluster* fromc; 00100 Cluster::getStateVectorFuncPtr getFromVector; 00102 QString fromVectorName; 00104 Cluster* toc; 00106 Cluster::getStateVectorFuncPtr getToVector; 00108 QString toVectorName; 00109 }; 00110 00111 } 00112 00113 #endif