Clean up pointer use:

* Use unique_ptr for Actions instead of manual memory management
 * Use unique_ptr in KeywordDatabase
 * Use unique_ptr instead of shared_ptr for file formats
 * Don't pass shared_ptr to Reader/Writer, use references instead
Also
 * Switch to C++17 so we can use map::try_emplace
This commit is contained in:
Twan van Laarhoven
2020-04-25 21:30:05 +02:00
parent 708b4389a0
commit 64ea1d7322
57 changed files with 363 additions and 385 deletions
+6 -7
View File
@@ -28,21 +28,20 @@ DECLARE_POINTER_TYPE(Style);
/// Manager of the script context for a set
class SetScriptContext {
public:
public:
SetScriptContext(Set& set);
virtual ~SetScriptContext();
/// Get a context to use for the set, for a given stylesheet
Context& getContext(const StyleSheetP&);
/// Get a context to use for the set, for a given card
Context& getContext(const CardP&);
protected:
Set& set; ///< Set for which we are managing scripts
map<const StyleSheet*,Context*> contexts; ///< Context for evaluating scripts that use a given stylesheet
protected:
Set& set; ///< Set for which we are managing scripts
map<const StyleSheet*,Context> contexts; ///< Context for evaluating scripts that use a given stylesheet
/// Called when a new context for a stylesheet is initialized
virtual void onInit(const StyleSheetP& stylesheet, Context* ctx) {}
virtual void onInit(const StyleSheetP& stylesheet, Context& ctx) {}
};
@@ -73,7 +72,7 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
void updateAll();
private:
virtual void onInit(const StyleSheetP& stylesheet, Context* ctx);
void onInit(const StyleSheetP& stylesheet, Context& ctx) override;
void initDependencies(Context&, Game&);
void initDependencies(Context&, StyleSheet&);