~charon-developers/charon-core/trunk

« back to all changes in this revision

Viewing changes to src/ParameteredObject.hxx

  • Committer: jmgottfried
  • Date: 2010-03-16 15:18:38 UTC
  • Revision ID: svn-v4:7d56a235-2f8b-4627-957e-5f30cc86da59:charon-core/trunk:680
moved header files to seperate include directory

this makes e.g. Compile and Load test work even if charon-core is not yet installed
and gives a chance to get charon-meta working

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  This file is part of Charon.
2
 
 
3
 
 Charon is free software: you can redistribute it and/or modify
4
 
 it under the terms of the GNU Lesser General Public License as published by
5
 
 the Free Software Foundation, either version 3 of the License, or
6
 
 (at your option) any later version.
7
 
 
8
 
 Charon is distributed in the hope that it will be useful,
9
 
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 GNU Lesser General Public License for more details.
12
 
 
13
 
 You should have received a copy of the GNU Lesser General Public License
14
 
 along with Charon.  If not, see <http://www.gnu.org/licenses/>.
15
 
 */
16
 
/** @file ParameteredObject.hxx
17
 
 *  Convenience file to iclude all ParameteredObject dependencies and
18
 
 *  Template functions.
19
 
 *  Include this file when you want to derive from ParameteredObject.
20
 
 *
21
 
 *  @author <a href="mailto:jmgottfried@web.de">Jens-Malte Gottfried</a>
22
 
 *  @author <a href="mailto:bc002@ix.urz.uni-heidelberg.de">Cornelius Ratsch</a>
23
 
 *
24
 
 *  @date 11.12.2008
25
 
 *
26
 
 */
27
 
 
28
 
#ifndef _PARAMETERED_OBJECT_HXX_
29
 
#define _PARAMETERED_OBJECT_HXX_
30
 
 
31
 
#include "ParameteredObject.h"
32
 
#include "Parameter.hxx"
33
 
#include "Slots.hxx"
34
 
 
35
 
template<class T>
36
 
void ParameteredObject::_addParameter(Parameter<T>& param,
37
 
                const std::string& name, const std::string& doc, const T& defVal,
38
 
                const std::string& type) {
39
 
        param.setDefault(defVal);
40
 
        param() = defVal;
41
 
        ParameteredObject::_addParameter(param, name, doc, type.c_str());
42
 
}
43
 
 
44
 
template <typename T>
45
 
void ParameteredObject::setParameter(std::string name, T value) {
46
 
        if(_parameters.find(name) != _parameters.end()) {
47
 
                *((Parameter<T>*)_parameters[name]) = value;
48
 
        }
49
 
}
50
 
 
51
 
template<typename T>
52
 
TemplatedParameteredObject<T>::TemplatedParameteredObject(
53
 
                const std::string& className, const std::string& name,
54
 
                const std::string& doc) :
55
 
        ParameteredObject(className, name, doc) {
56
 
                _addSomething("parameters", "templatetype", "template type", "string", "double");
57
 
 
58
 
}
59
 
 
60
 
template<typename T>
61
 
const std::string TemplatedParameteredObject<T>::getTemplateType() const {
62
 
        return TypeDetector::instance().type(typeid(T).name());
63
 
}
64
 
 
65
 
#endif // _PARAMETERED_OBJECT_HXX_