The Battle for Wesnoth  1.17.0-dev
formula_manager.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2021
3  by Chris Beck <render787@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include "formula/callable.hpp"
19 
20 #include<string>
21 
22 class config;
23 class unit;
24 
26 public:
32  formula_vars_(o.formula_vars_ ? std::make_shared<wfl::map_formula_callable>(*o.formula_vars_) : o.formula_vars_)
33  {}
34 
36  void add_formula_var(std::string str, wfl::variant var);
37  bool has_formula() const { return !unit_formula_.empty(); }
38  bool has_loop_formula() const { return !unit_loop_formula_.empty(); }
39  bool has_priority_formula() const { return !unit_priority_formula_.empty(); }
40  const std::string& get_formula() const { return unit_formula_; }
41  const std::string& get_loop_formula() const { return unit_loop_formula_; }
42  const std::string& get_priority_formula() const { return unit_priority_formula_; }
43 
44  void read(const config & ai);
45  void write(config & cfg);
46 
47 private:
48  std::string unit_formula_;
49  std::string unit_loop_formula_;
52 };
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:121
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:61
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:44
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
std::shared_ptr< map_formula_callable > map_formula_callable_ptr
Definition: callable.hpp:312