4
Copyright (C) 2005-2009 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.
25
* \file applied_boolean_expression.cpp
26
* \brief Implementation of the bear::applied_boolean_expression class.
27
* \author Julien Jorge
29
#include "generic_items/expr/applied_boolean_expression.hpp"
31
#include "engine/expr/base_boolean_expression.hpp"
33
#include "engine/export.hpp"
35
#include <claw/logger.hpp>
37
BASE_ITEM_EXPORT( applied_boolean_expression, bear )
39
/*----------------------------------------------------------------------------*/
43
bear::applied_boolean_expression::applied_boolean_expression()
47
} // applied_boolean_expression::applied_boolean_expression()
49
/*----------------------------------------------------------------------------*/
51
* \brief Set a field of type <item>.
52
* \param name The name of the field.
53
* \param value The value of the field.
55
bool bear::applied_boolean_expression::set_item_field
56
( const std::string& name, engine::base_item* value )
60
if ( name == "applied_boolean_expression.expression" )
62
engine::base_boolean_expression* e
63
( dynamic_cast<engine::base_boolean_expression*>(value) );
68
claw::logger << claw::log_error << name << ": item is not of type "
69
<< "'engine::base_boolean_expression'." << std::endl;
72
result = super::set_item_field(name, value);
75
} // applied_boolean_expression::set_item_field()
77
/*----------------------------------------------------------------------------*/
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.
83
bool bear::applied_boolean_expression::set_item_list_field
84
( const std::string& name, const std::vector<engine::base_item*>& value )
88
if ( name == "applied_boolean_expression.trigger" )
89
for ( std::size_t i=0; i!=value.size(); ++i )
91
engine::with_trigger* t
92
( dynamic_cast<engine::with_trigger*>(value[i]) );
95
m_trigger.push_back(t);
97
claw::logger << claw::log_error << name
99
<< " is not of type 'engine::with_trigger'."
103
result = super::set_item_list_field(name, value);
106
} // applied_boolean_expression::set_item_list_field()
108
/*----------------------------------------------------------------------------*/
110
* \brief Tell if all required fields are initialized.
112
bool bear::applied_boolean_expression::is_valid() const
114
return !m_trigger.empty() && (m_expression != NULL);
115
} // applied_boolean_expression::is_valid()
117
/*----------------------------------------------------------------------------*/
119
* \brief Initialize the item.
121
void bear::applied_boolean_expression::build()
123
for (unsigned int i=0; i!=m_trigger.size(); ++i)
124
m_trigger[i]->set_condition(*m_expression);
127
} // applied_boolean_expression::build()