• R/O
  • SSH
  • HTTPS

toy-open-ps: 提交


Commit MetaInfo

修订版21 (tree)
时间2011-05-15 21:31:10
作者(del#42492)

Log Message

実装内容が消えてしまっていたのを戻した。

更改概述

差异

--- trunk/main/core/src/tops/action/AddAttributeAction.cpp (revision 20)
+++ trunk/main/core/src/tops/action/AddAttributeAction.cpp (revision 21)
@@ -5,3 +5,47 @@
55 * ライセンス:: CPL(Common Public Licence)
66 */
77
8+#include "tops/action/AddAttributeAction.hpp"
9+
10+#include "tops/Instance.hpp"
11+#include "tops/ProductionSystem.hpp"
12+
13+#include "tops/attribute/AttributesOfFact.hpp"
14+
15+namespace tops {
16+
17+ using namespace std;
18+
19+ void AddAttributeAction::print(ostream& stream) const {
20+ stream << "(add_attr " << m_label << ":(" << m_attributes << " ))";
21+ }
22+
23+ void FireableAddAttributeAction::print(ostream& stream) const {
24+ stream << "(add_attr " << m_label << ":(" << *m_attributes << " ))";
25+ }
26+
27+ FireableActionPtr AddAttributeAction::instantiate(const Variables& variables) const {
28+ return FireableActionPtr(new FireableAddAttributeAction(m_label, m_attributes.instantiate(variables)));
29+ }
30+
31+ bool FireableAddAttributeAction::fire(ProductionSystem& system, const Instance& instance) {
32+ WMElement* element = instance[m_label];
33+
34+ if (element) {
35+ bool result = true;
36+
37+ for (AttributesOfFact::MapIterator i = m_attributes->begin(); i != m_attributes->end(); ++i) {
38+ AttributeOfFact* attribute=system.add(*element, (*i)->getName(), (*i)->getValue(), &instance);
39+
40+ if (!attribute) {
41+ result = false;
42+ }
43+ }
44+
45+ return result;
46+ } else {
47+ return false;
48+ }
49+ }
50+
51+} // namespace tops
Show on old repository browser