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 }
void setName(QString newname)
Set the name of Updatable.
Definition: updatable.cpp:48
Updatable(QString name="unnamed")
Constructor.
Definition: updatable.cpp:24
virtual ~Updatable()
Destructor.
Definition: updatable.cpp:45
virtual void save(ConfigurationParameters &params, QString prefix)
Save the actual status of parameters into the ConfigurationParameters object passed.
Definition: updatable.cpp:56
bool startObjectParameters(QString groupPath, QString typeName, ParameterSettable *object)
static Descriptor addTypeDescription(QString type, QString shortHelp, QString longHelp=QString(""))
static void describe(QString type)
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
Definition: updatable.cpp:61
QString name() const
Return its name.
Definition: updatable.cpp:52
static QString GroupSeparator()