Debian Codegraph @

include/iradiant.h

raw
1 #pragma once
2
3 #include "imodule.h"
4
5 #include <sigc++/signal.h>
6 #include <functional>
7
8 const char* const MODULE_RADIANT_CORE("RadiantCore");
9
10 namespace applog { class ILogWriter; }
11 namespace language { class ILanguageManager; } // see "i18n.h"
12
13 namespace radiant
14 {
15
16 class IMessageBus; // see imessagebus.h
17
18 /**
19 * Main application host, offering access to the Module Registry
20 * and the logging infrastructure.
21 *
22 * As it implements the RegisterableModule interface, an instance
23 * can be acquired through the GlobalModuleRegistry at runtime.
24 * Module Registration doesn't need to be performed explicitly,
25 * the IRadiant module will register itself.
26 */
27 class IRadiant :
28 public RegisterableModule
29 {
30 public:
31 typedef std::shared_ptr<IRadiant> Ptr;
32
33 /**
34 * Central logging class of the module. Use this to
35 * attach your own ILogDevices to receive logging output.
36 */
37 virtual applog::ILogWriter& getLogWriter() = 0;
38
39 /**
40 * Returns the central module registry instance.
41 */
42 virtual IModuleRegistry& getModuleRegistry() = 0;
43
44 /**
45 * Get a reference to the central message handler.
46 */
47 virtual IMessageBus& getMessageBus() = 0;
48
49 /**
50 * Get a reference to the Language Manager instance
51 * used to resolve localised string resources.
52 */
53 virtual language::ILanguageManager& getLanguageManager() = 0;
54
55 /**
56 * Loads and initialises all modules, starting up the
57 * application. Might throw a StartupFailure exception
58 * on unrecoverable errors.
59 */
60 virtual void startup() = 0;
61
62 virtual ~IRadiant() {}
63
64 // Exception thrown during Radiant startup
65 class StartupFailure :
66 public std::runtime_error
67 {
68 public:
69 StartupFailure(const std::string& msg) :
70 runtime_error(msg)
71 {}
72 };
73 };
74
75 }
76
77 inline radiant::IRadiant& GlobalRadiantCore()
78 {
79 static module::InstanceReference<radiant::IRadiant> _reference(MODULE_RADIANT_CORE);
80 return _reference;
81 }