~ubuntu-branches/ubuntu/trusty/plee-the-bear/trusty-proposed

« back to all changes in this revision

Viewing changes to bear-engine/lib/src/generic_items/expr/code/applied_boolean_expression.cpp

  • 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-2009 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 applied_boolean_expression.cpp
26
 
 * \brief Implementation of the bear::applied_boolean_expression class.
27
 
 * \author Julien Jorge
28
 
 */
29
 
#include "generic_items/expr/applied_boolean_expression.hpp"
30
 
 
31
 
#include "engine/expr/base_boolean_expression.hpp"
32
 
 
33
 
#include "engine/export.hpp"
34
 
 
35
 
#include <claw/logger.hpp>
36
 
 
37
 
BASE_ITEM_EXPORT( applied_boolean_expression, bear )
38
 
 
39
 
/*----------------------------------------------------------------------------*/
40
 
/**
41
 
 * \brief Constructor.
42
 
 */
43
 
bear::applied_boolean_expression::applied_boolean_expression()
44
 
  : m_expression(NULL)
45
 
{
46
 
 
47
 
} // applied_boolean_expression::applied_boolean_expression()
48
 
 
49
 
/*----------------------------------------------------------------------------*/
50
 
/**
51
 
 * \brief Set a field of type <item>.
52
 
 * \param name The name of the field.
53
 
 * \param value The value of the field.
54
 
 */
55
 
bool bear::applied_boolean_expression::set_item_field
56
 
( const std::string& name, engine::base_item* value )
57
 
{
58
 
  bool result = true;
59
 
 
60
 
  if ( name == "applied_boolean_expression.expression" )
61
 
    {
62
 
      engine::base_boolean_expression* e
63
 
        ( dynamic_cast<engine::base_boolean_expression*>(value) );
64
 
 
65
 
      if ( e != NULL )
66
 
        m_expression = e;
67
 
      else
68
 
        claw::logger << claw::log_error << name << ": item is not of type "
69
 
                     << "'engine::base_boolean_expression'." << std::endl;
70
 
    }
71
 
  else
72
 
    result = super::set_item_field(name, value);
73
 
 
74
 
  return result;
75
 
} // applied_boolean_expression::set_item_field()
76
 
 
77
 
/*----------------------------------------------------------------------------*/
78
 
/**
79
 
 * \brief Set a field of type <list of item>.
80
 
 * \param name The name of the field.
81
 
 * \param value The value of the field.
82
 
 */
83
 
bool bear::applied_boolean_expression::set_item_list_field
84
 
( const std::string& name, const std::vector<engine::base_item*>& value )
85
 
{
86
 
  bool result = true;
87
 
 
88
 
  if ( name == "applied_boolean_expression.trigger" )
89
 
    for ( std::size_t i=0; i!=value.size(); ++i )
90
 
      {
91
 
        engine::with_trigger* t
92
 
          ( dynamic_cast<engine::with_trigger*>(value[i]) );
93
 
 
94
 
        if ( t != NULL )
95
 
          m_trigger.push_back(t);
96
 
        else
97
 
          claw::logger << claw::log_error << name
98
 
                       << ": item #" << i
99
 
                       << " is not of type 'engine::with_trigger'."
100
 
                       << std::endl;
101
 
      }
102
 
  else
103
 
    result = super::set_item_list_field(name, value);
104
 
 
105
 
  return result;
106
 
} // applied_boolean_expression::set_item_list_field()
107
 
 
108
 
/*----------------------------------------------------------------------------*/
109
 
/**
110
 
 * \brief Tell if all required fields are initialized.
111
 
 */
112
 
bool bear::applied_boolean_expression::is_valid() const
113
 
{
114
 
  return !m_trigger.empty() && (m_expression != NULL);
115
 
} // applied_boolean_expression::is_valid()
116
 
 
117
 
/*----------------------------------------------------------------------------*/
118
 
/**
119
 
 * \brief Initialize the item.
120
 
 */
121
 
void bear::applied_boolean_expression::build()
122
 
{
123
 
  for (unsigned int i=0; i!=m_trigger.size(); ++i)
124
 
    m_trigger[i]->set_condition(*m_expression);
125
 
 
126
 
  kill();
127
 
} // applied_boolean_expression::build()