00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "linker.h"
00021 #include "neuralnet.h"
00022
00023 namespace farsa {
00024
00025 Linker::Linker( Cluster* from, Cluster* to, QString name )
00026 : Updatable(name) {
00027 this->fromc = from;
00028 getFromVector = fromc->getDelegateFor( "outputs" );
00029 fromVectorName = "outputs";
00030 this->toc = to;
00031 getToVector = toc->getDelegateFor( "inputs" );
00032 toVectorName = "inputs";
00033 }
00034
00035 Linker::Linker( ConfigurationParameters& params, QString prefix )
00036 : Updatable( params, prefix ) {
00037 fromc = params.getObjectFromParameter<Cluster>( prefix + "from", true );
00038 toc = params.getObjectFromParameter<Cluster>( prefix + "to", true );
00039 if ( !fromc || !toc ) throw ClusterFromOrToMissing();
00040 QString str = params.getValue( prefix + "fromVector" );
00041 if ( str.isEmpty() ) {
00042 getFromVector = fromc->getDelegateFor( "outputs" );
00043 fromVectorName = "outputs";
00044 } else {
00045 getFromVector = fromc->getDelegateFor( str );
00046 fromVectorName = str;
00047 }
00048 str = params.getValue( prefix + "toVector" );
00049 if ( str.isEmpty() ) {
00050 getToVector = toc->getDelegateFor( "inputs" );
00051 toVectorName = "inputs";
00052 } else {
00053 getToVector = toc->getDelegateFor( str );
00054 toVectorName = str;
00055 }
00056 }
00057
00058 void Linker::save(ConfigurationParameters& params, QString prefix)
00059 {
00060 Updatable::save( params, prefix );
00061 params.startObjectParameters(prefix, "Linker", this);
00062 params.createParameter(prefix, "from", fromc );
00063 if ( fromVectorName != "outputs" ) {
00064 params.createParameter( prefix, "fromVector", fromVectorName );
00065 }
00066 params.createParameter(prefix, "to", toc );
00067 if ( toVectorName != "inputs" ) {
00068 params.createParameter( prefix, "toVector", toVectorName );
00069 }
00070 }
00071
00072 void Linker::describe( QString type ) {
00073 Updatable::describe( type );
00074 Descriptor d = addTypeDescription( type, "The Linker connect two Cluster" );
00075 d.describeObject( "from" ).type( "Cluster" ).props( IsMandatory ).help( "The Linker will get values from this Cluster" );
00076 d.describeString( "fromVector" ).def( "outputs" ).help( "The vector on which the Linker will get values from" );
00077 d.describeObject( "to" ).type( "Cluster" ).props( IsMandatory ).help( "The Linker will write values to this Cluster" );
00078 d.describeString( "toVector" ).def( "inputs" ).help( "The vector on which the Linker will write values to" );
00079 }
00080
00081 }