Loading...
Searching...
No Matches
ApplicationContext.hpp
1#pragma once
2#include <score/application/ApplicationComponents.hpp>
3
4namespace score
5{
6class ApplicationComponents;
7struct ApplicationSettings;
8class SettingsDelegateModel;
9class DocumentManager;
10class MenuManager;
11class ToolbarManager;
12class ActionManager;
13struct DocumentList;
14struct DocumentContext;
23struct SCORE_LIB_BASE_EXPORT ApplicationContext
24{
25 explicit ApplicationContext(
27 const std::vector<std::unique_ptr<score::SettingsDelegateModel>>&);
30 ApplicationContext& operator=(const ApplicationContext&) = delete;
31
33
39 template <typename T>
40 T& settings() const
41 {
42 for(auto& elt : this->m_settings)
43 {
44 if(auto c = dynamic_cast<T*>(elt.get()))
45 {
46 return *c;
47 }
48 }
49
50 SCORE_ABORT;
51 throw;
52 }
53
59 const auto& addons() const { return components.addons(); }
60
66 template <typename T>
67 const T& interfaces() const
68 {
69 return components.interfaces<T>();
70 }
71
83 auto instantiateUndoCommand(const CommandData& cmd) const
84 {
85 return components.instantiateUndoCommand(cmd);
86 }
87
88 const score::DocumentContext* currentDocument() const noexcept;
89
91 const score::ApplicationSettings& applicationSettings;
92
93 const score::ApplicationComponents& components;
94
95 DocumentList& documents;
96
97private:
98 const std::vector<std::unique_ptr<score::SettingsDelegateModel>>& m_settings;
99};
100
101// By default this is defined in score::Application
102SCORE_LIB_BASE_EXPORT const ApplicationContext& AppContext();
103}
Definition ApplicationComponents.hpp:68
Definition SettingsDelegateModel.hpp:16
Base toolkit upon which the software is built.
Definition Application.cpp:90
STL namespace.
Used to access all the application-wide state and structures.
Definition ApplicationContext.hpp:24
T & settings() const
Access a specific Settings model instance.
Definition ApplicationContext.hpp:40
const auto & addons() const
List of all the registered addons.
Definition ApplicationContext.hpp:59
auto instantiateUndoCommand(const CommandData &cmd) const
instantiateUndoCommand Is used to generate a Command from its serialized data.
Definition ApplicationContext.hpp:83
const T & interfaces() const
Access to a specific interface list.
Definition ApplicationContext.hpp:67
Load-time settings.
Definition ApplicationSettings.hpp:17
Utility class for the serialization and deserialization of commands.
Definition CommandData.hpp:14
Definition DocumentContext.hpp:18
Definition DocumentManager.hpp:28