updatable.cpp
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 #include "updatable.h"
21 
22 namespace farsa {
23 
24 Updatable::Updatable( QString name )
26 {
27  setName( name );
28 }
29 
30 Updatable::Updatable( ConfigurationParameters& params, QString prefix ) :
31  ParameterSettableInConstructor(params, prefix)
32 {
33  QString upname = prefix;
34  // remove from the name the GroupSeparator() at the start and at the end
35  // because they create problem when referencing the object using NeuralNet::byName
36  if ( upname.startsWith( ConfigurationParameters::GroupSeparator() ) ) {
37  upname.remove( 0, 1 );
38  }
39  if ( upname.endsWith( ConfigurationParameters::GroupSeparator() ) ) {
40  upname.chop( 1 );
41  }
42  setName( upname );
43 }
44 
46 }
47 
48 void Updatable::setName( QString newname ) {
49  namev = newname;
50 }
51 
52 QString Updatable::name() const {
53  return namev;
54 }
55 
56 void Updatable::save(ConfigurationParameters& params, QString prefix)
57 {
58  params.startObjectParameters(prefix, "Updatable", this);
59 }
60 
61 void Updatable::describe( QString type ) {
62  addTypeDescription( type, "an Updatable" );
63 }
64 
65 }