4
Copyright (C) 2005-2010 Julien Jorge, Sebastien Angibaud
6
This program is free software; you can redistribute it and/or modify it
7
under the terms of the GNU General Public License as published by the
8
Free Software Foundation; either version 2 of the License, or (at your
9
option) any later version.
11
This program is distributed in the hope that it will be useful, but WITHOUT
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16
You should have received a copy of the GNU General Public License along
17
with this program; if not, write to the Free Software Foundation, Inc.,
18
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
contact: plee-the-bear@gamned.org
22
Please add the tag [Bear] in the subject of your mails.
26
* \brief Implementation of the template methods of the
27
* bear::engine::variable class.
28
* \author Julien Jorge
31
#include <claw/assert.hpp>
33
/*----------------------------------------------------------------------------*/
36
* \param name The name of the variable.
39
bear::engine::variable<T>::variable( const std::string& name )
43
} // variable::variable()
45
/*----------------------------------------------------------------------------*/
48
* \param name The name of the variable.
49
* \param val The value of the variable.
52
bear::engine::variable<T>::variable( const std::string& name, const T& val )
53
: base_variable(name), m_value(val)
56
} // variable::variable()
58
/*----------------------------------------------------------------------------*/
60
* \brief Get the value of the variable.
63
const T& bear::engine::variable<T>::get_value() const
66
} // variable::get_value()
68
/*----------------------------------------------------------------------------*/
70
* \brief Assign the value to the variable in a var_map.
71
* \param m The var_map in which the value is to be set.
74
void bear::engine::variable<T>::assign_value_to( var_map& m ) const
76
m.set<T>( this->get_name(), m_value );
77
} // variable::assign_value_to()
79
/*----------------------------------------------------------------------------*/
81
* \brief Get the value to the variable from a var_map.
82
* \param m The var_map in which the value is taken.
85
void bear::engine::variable<T>::get_value_from( const var_map& m )
87
CLAW_PRECOND( exists(m) );
89
m_value = m.get<T>( this->get_name() );
90
} // variable::get_value_from()
92
/*----------------------------------------------------------------------------*/
94
* \brief Tell if there is a value associated with the variable's name in a
96
* \param m The var_map in which the value is checked.
99
bool bear::engine::variable<T>::exists( const var_map& m ) const
101
return m.exists<T>( this->get_name() );
102
} // variable::exists()