Main.h
1 
27 #ifndef COSMO_MAIN_COMPONENT_H
28 #define COSMO_MAIN_COMPONENT_H
29 
30 #include <Pt/Cosmo/Api.h>
31 #include <Pt/Cosmo/Component.h>
32 #include <Pt/Cosmo/ComponentPlugin.h>
33 
34 namespace Pt {
35 
36 namespace Cosmo {
37 
38 class MainImpl;
39 class MainPlugin;
40 class ComponentManager;
41 
50 class PT_COSMO_API Main : public Component
51 {
52  public:
53  template <typename I>
54  I* getInterface();
55 
56  public:
63  Main(int& argc, char** argv, ComponentManager& cm);
64 
67  virtual ~Main();
68 
73  void run();
74 
75  MainImpl& impl();
76 
77  private:
78  MainPlugin* _mainPlugin;
79  MainImpl* _impl;
80 };
81 
84 class MainFactory
85 {
86  public:
89  explicit MainFactory(Main& main)
90  : _main(&main)
91  {}
92 
93  Component* create()
94  { return _main; }
95 
96  void destroy(Component* instance)
97  { }
98 
99  private:
100  Main* _main;
101 };
102 
105 class MainPlugin : public ComponentPlugin<Main, MainFactory>
106 {
107  public:
108  static const char* FeatureId()
109  { return "Cosmo.Main"; }
110 
111  static const char* ClassId()
112  { return "Cosmo.Main"; }
113 
114  static const char* Info()
115  { return "Cosmo.Default"; }
116 
117  public:
118  MainPlugin(Main& m);
119 };
120 
121 } // namespace Cosmo
122 
123 } // namespace Pt
124 
125 #endif // include guard
Core module.
Definition: Allocator.h:33
Main component.
Definition: Main.h:51
Component base class.
Definition: Component.h:52
Main(int &argc, char **argv, ComponentManager &cm)
Constructs the main component.
void run()
Launches the application.
@ Info
Infos and more severe messages.
Definition: LogLevel.h:46
Default component manager.
Definition: ComponentManager.h:53
virtual ~Main()
Destructor.