~ubuntu-branches/ubuntu/natty/plee-the-bear/natty

« back to all changes in this revision

Viewing changes to bear-engine/core/src/engine/variable/impl/variable.tpp

  • Committer: Bazaar Package Importer
  • Author(s): Julien Jorge, Julien Jorge
  • Date: 2010-11-17 20:13:34 UTC
  • mfrom: (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20101117201334-o4dp7uq437to7oxb
Tags: 0.5.1-1
[ Julien Jorge ]
* New upstream release (Closes: #565062, #546514).
* Add armhf architecture (Closes: #604689).
* Remove patches integrated upstream: rpath-editors.diff, rpath-game.diff,
  editors-menu-section.diff.
* Bump the Standard-Version, no changes.
* Update my email address.
* Set build dependency of libclaw to 1.6.0.
* Add the missing ${misc:Depends} in debian/control.
* List gettext translations in bear-factory.install and plee-the-bear.install.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Bear Engine
 
3
 
 
4
  Copyright (C) 2005-2010 Julien Jorge, Sebastien Angibaud
 
5
 
 
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.
 
10
 
 
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
 
14
  more details.
 
15
 
 
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
 
19
 
 
20
  contact: plee-the-bear@gamned.org
 
21
 
 
22
  Please add the tag [Bear] in the subject of your mails.
 
23
*/
 
24
/**
 
25
 * \file variable.tpp
 
26
 * \brief Implementation of the template methods of the
 
27
 *        bear::engine::variable class.
 
28
 * \author Julien Jorge
 
29
 */
 
30
 
 
31
#include <claw/assert.hpp>
 
32
 
 
33
/*----------------------------------------------------------------------------*/
 
34
/**
 
35
 * \brief Constructor
 
36
 * \param name The name of the variable.
 
37
 */
 
38
template<class T>
 
39
bear::engine::variable<T>::variable( const std::string& name )
 
40
  : base_variable(name)
 
41
{
 
42
 
 
43
} // variable::variable()
 
44
 
 
45
/*----------------------------------------------------------------------------*/
 
46
/**
 
47
 * \brief Constructor
 
48
 * \param name The name of the variable.
 
49
 * \param val The value of the variable.
 
50
 */
 
51
template<class T>
 
52
bear::engine::variable<T>::variable( const std::string& name, const T& val )
 
53
  : base_variable(name), m_value(val)
 
54
{
 
55
 
 
56
} // variable::variable()
 
57
 
 
58
/*----------------------------------------------------------------------------*/
 
59
/**
 
60
 * \brief Get the value of the variable.
 
61
 */
 
62
template<class T>
 
63
const T& bear::engine::variable<T>::get_value() const
 
64
{
 
65
  return m_value;
 
66
} // variable::get_value()
 
67
 
 
68
/*----------------------------------------------------------------------------*/
 
69
/**
 
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.
 
72
 */
 
73
template<class T>
 
74
void bear::engine::variable<T>::assign_value_to( var_map& m ) const
 
75
{
 
76
  m.set<T>( this->get_name(), m_value );
 
77
} // variable::assign_value_to()
 
78
 
 
79
/*----------------------------------------------------------------------------*/
 
80
/**
 
81
 * \brief Get the value to the variable from a var_map.
 
82
 * \param m The var_map in which the value is taken.
 
83
 */
 
84
template<class T>
 
85
void bear::engine::variable<T>::get_value_from( const var_map& m )
 
86
{
 
87
  CLAW_PRECOND( exists(m) );
 
88
 
 
89
  m_value = m.get<T>( this->get_name() );
 
90
} // variable::get_value_from()
 
91
 
 
92
/*----------------------------------------------------------------------------*/
 
93
/**
 
94
 * \brief Tell if there is a value associated with the variable's name in a
 
95
 *        var_map.
 
96
 * \param m The var_map in which the value is checked.
 
97
 */
 
98
template<class T>
 
99
bool bear::engine::variable<T>::exists( const var_map& m ) const
 
100
{
 
101
  return m.exists<T>( this->get_name() );
 
102
} // variable::exists()