The Battle for Wesnoth  1.15.1+dev
formula_manager.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2018 by Chris Beck <render787@gmail.com>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include "formula/callable.hpp"
18 
19 #include<string>
20 
21 class config;
22 class unit;
23 
25 public:
31  formula_vars_(o.formula_vars_ ? std::make_shared<wfl::map_formula_callable>(*o.formula_vars_) : o.formula_vars_)
32  {}
33 
35  void add_formula_var(std::string str, wfl::variant var);
36  bool has_formula() const { return !unit_formula_.empty(); }
37  bool has_loop_formula() const { return !unit_loop_formula_.empty(); }
38  bool has_priority_formula() const { return !unit_priority_formula_.empty(); }
39  const std::string& get_formula() const { return unit_formula_; }
40  const std::string& get_loop_formula() const { return unit_loop_formula_; }
41  const std::string& get_priority_formula() const { return unit_priority_formula_; }
42 
43  void read(const config & ai);
44  void write(config & cfg);
45 
46 private:
47  std::string unit_formula_;
48  std::string unit_loop_formula_;
51 };
const std::string & get_loop_formula() const
unit_formula_manager(const unit_formula_manager &o)
This class represents a single unit of a specific type.
Definition: unit.hpp:99
const std::string & get_priority_formula() const
void add_formula_var(std::string str, wfl::variant var)
const wfl::map_formula_callable_ptr & formula_vars() const
const std::string & get_formula() const
STL namespace.
void write(config &cfg)
std::string unit_loop_formula_
std::string unit_priority_formula_
A small explanation about what&#39;s going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:58
void read(const config &ai)
wfl::map_formula_callable_ptr formula_vars_
bool has_priority_formula() const
bool has_loop_formula() const
Definition: contexts.hpp:42
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:92
std::shared_ptr< map_formula_callable > map_formula_callable_ptr
Definition: callable.hpp:305