The Battle for Wesnoth  1.19.0-dev
instance.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2024
3  by Mark de Wever <koraq@xs4all.nl>
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 #define GETTEXT_DOMAIN "wesnoth-lib"
17 
19 
20 #include "gui/widgets/spacer.hpp"
21 
22 namespace gui2
23 {
24 
25 namespace implementation
26 {
27 
29  : builder_widget(cfg), configuration(cfg)
30 {
31 }
32 
33 std::unique_ptr<widget> builder_instance::build() const
34 {
35  return build(replacements_map());
36 }
37 
38 std::unique_ptr<widget> builder_instance::build(const replacements_map& replacements) const
39 {
40  const replacements_map::const_iterator itor = replacements.find(id);
41  if(itor != replacements.end()) {
42  return itor->second->build();
43  } else {
45  return builder.build();
46  }
47 }
48 
49 } // namespace implementation
50 
51 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
Generic file dialog.
Contains the implementation details for lexical_cast and shouldn't be used directly.
Contains the info needed to instantiate a widget.
std::map< std::string, std::shared_ptr< builder_widget > > replacements_map
The replacements type is used to define replacement types.
virtual std::unique_ptr< widget > build() const override
Definition: instance.cpp:33
config configuration
Holds a copy of the cfg parameter in the constructor.
Definition: instance.hpp:42
virtual std::unique_ptr< widget > build() const override
Definition: spacer.cpp:129