linker.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Neural Network Framework. *
3  * Copyright (C) 2005-2011 Gianluca Massera <emmegian@yahoo.it> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18  ********************************************************************************/
19 
20 #ifndef LINKERS_H
21 #define LINKERS_H
22 
28 #include "nnfwconfig.h"
29 #include "cluster.h"
30 #include "updatable.h"
31 #include <exception>
32 
33 namespace farsa {
34 
38 class FARSA_NNFW_API Linker : public Updatable {
39 public:
41  Linker( Cluster* from, Cluster* to, QString name = "unnamed" );
43  Linker( ConfigurationParameters& params, QString prefix );
45  Cluster* from() const {
46  return fromc;
47  };
49  Cluster* to() const {
50  return toc;
51  };
56  void configureFromVector( QString vectorName ) {
57  getFromVector = fromc->getDelegateFor( vectorName );
58  fromVectorName = vectorName;
59  }
64  void configureToVector( QString vectorName ) {
65  getToVector = toc->getDelegateFor( vectorName );
66  toVectorName = vectorName;
67  }
71  virtual unsigned int size() const = 0;
75  virtual void randomize( double min, double max ) = 0;
84  virtual void save(ConfigurationParameters& params, QString prefix);
86  static void describe( QString type );
87 protected:
89  DoubleVector& fromVector() const {
90  return (*getFromVector)(fromc);
91  };
93  DoubleVector& toVector() const {
94  return (*getToVector)(toc);
95  };
96 private:
98  Cluster* fromc;
100  Cluster::getStateVectorFuncPtr getFromVector;
102  QString fromVectorName;
104  Cluster* toc;
106  Cluster::getStateVectorFuncPtr getToVector;
108  QString toVectorName;
109 };
110 
111 }
112 
113 #endif
This file contains the common type defitions used on the whole framework.
Cluster * to() const
Return the Cluster to.
Definition: linker.h:49
FARSA_UTIL_TEMPLATE const T max(const T &t1, const U &t2)
Cluster * from() const
Return the Cluster From.
Definition: linker.h:45
Updatables objects.
Definition: updatable.h:37
void configureToVector(QString vectorName)
Configure on which state vector of 'to' Cluster this Linker is attached to.
Definition: linker.h:64
Define the common interface among Clusters.
Definition: cluster.h:73
DoubleVector & toVector() const
Return a reference to the DoubleVector of 'to' on which this is attached to.
Definition: linker.h:93
Abstract Linker Class.
Definition: linker.h:38
This file contains the declarations of the Cluster class.
DoubleVector &(* getStateVectorFuncPtr)(Cluster *)
Delegate type for retrieving a vector by name (pointer to function) It works in this way: ...
Definition: cluster.h:175
FARSA_UTIL_TEMPLATE const T min(const T &t1, const U &t2)
void configureFromVector(QString vectorName)
Configure on which state vector of 'from' Cluster this Linker is attached to.
Definition: linker.h:56
DoubleVector & fromVector() const
Return a reference to the DoubleVector of 'from' on which this is attached to.
Definition: linker.h:89