76 typedef std::shared_ptr<T>
ptr;
79 template<
typename Factory>
105 if (!cfg[
"id"].empty()) {
107 with_same_id.
id = cfg[
"id"].str();
120 if (child.
id ==
"*") {
135 std::vector<component*> children;
137 children.push_back(&*v);
175 template<
typename Factory>
185 if (child.
id ==
"default_facet") {
194 if (child.
id ==
"default_facet") {
217 typedef std::shared_ptr<T>
ptr;
220 template<
typename Factory>
228 typename aspect_map::const_iterator a =
aspects_.find(child.
id);
241 cfg[
"name"] =
"composite_aspect";
243 cfg[
"id"] = child.
id;
256 if (child.
id ==
"*") {
258 for (
typename aspect_map::value_type a :
aspects_) {
259 b |= a.second->delete_all_facets();
268 std::vector<component*> children;
269 for (
typename aspect_map::value_type a :
aspects_) {
270 children.push_back(&*a.second);
283 template<
typename X,
typename Factory>
285 std::vector<std::shared_ptr<X>>&
values, Factory&& construction_factory)
287 property_handlers.emplace(property,
291 template<
typename X,
typename Factory>
293 std::vector<std::shared_ptr<X>>&
values, std::shared_ptr<X>& def, Factory&& construction_factory)
295 property_handlers.emplace(property,
299 template<
typename X,
typename Factory>
301 std::map<std::string, std::shared_ptr<X>>& aspects, Factory&& construction_factory)
303 property_handlers.emplace(property,
bool handle_add(const path_element &, const config &)
const std::string & property_
std::function< void(aspect_map &, const config &, std::string)> factory_
component * handle_get(const path_element &child) const
std::map< std::string, ptr > aspect_map
std::vector< component * > handle_get_children() const
bool handle_change(const path_element &child, config cfg)
bool handle_delete(const path_element &child)
aspect_property_handler(const std::string &property, aspect_map &aspects, Factory &&construction_factory)
virtual bool handle_delete(const path_element &child)=0
virtual component * handle_get(const path_element &child) const =0
virtual bool handle_add(const path_element &child, const config &cfg)=0
virtual bool handle_change(const path_element &child, config cfg)=0
virtual std::vector< component * > handle_get_children() const =0
virtual ~base_property_handler()
std::vector< component * > handle_get_children() const
vector_property_handler< T >::ptr ptr
bool handle_change(const path_element &child, config cfg)
facets_property_handler(const std::string &property, ptr_vector &values, ptr &def, Factory &&construction_factory)
component * handle_get(const path_element &child) const
vector_property_handler< T >::ptr_vector ptr_vector
bool operator()(const T &t)
virtual ~path_element_matches()
path_element_matches(const path_element &element)
void call_factory(ptr_vector &vec, const config &cfg)
std::function< void(ptr_vector &, const config &)> factory_
const std::string property_
component * handle_get(const path_element &child) const
bool handle_add(const path_element &child, const config &cfg)
vector_property_handler(const std::string &property, ptr_vector &values, Factory &&construction_factory)
bool do_add(int pos, const config &cfg)
std::vector< std::shared_ptr< T > > ptr_vector
std::vector< component * > handle_get_children() const
bool handle_change(const path_element &child, config cfg)
bool handle_delete(const path_element &child)
A config object defines a single node in a WML file, with access to child nodes.
bool has_attribute(config_key_type key) const
A component of the AI framework.
Definitions for the interface to Wesnoth Markup Language (WML).
A small explanation about what's going on here: Each action has access to two game_info objects First...
static void register_facets_property(property_handler_map &property_handlers, const std::string &property, std::vector< std::shared_ptr< X >> &values, std::shared_ptr< X > &def, Factory &&construction_factory)
std::shared_ptr< base_property_handler > property_handler_ptr
static void register_vector_property(property_handler_map &property_handlers, const std::string &property, std::vector< std::shared_ptr< X >> &values, Factory &&construction_factory)
std::map< std::string, property_handler_ptr > property_handler_map
static void register_aspect_property(property_handler_map &property_handlers, const std::string &property, std::map< std::string, std::shared_ptr< X >> &aspects, Factory &&construction_factory)
std::string::const_iterator iterator