CServiceApplicationComp.h
Go to the documentation of this file.
1 #ifndef iabc_CServiceApplicationComp_included
2 #define iabc_CServiceApplicationComp_included
3 
4 
5 // Qt includes
6 #include <QtGui/QSystemTrayIcon>
7 
8 // Qt Solutions
9 #include "QtService.h"
10 
11 // ACF includes
12 #include "ibase/IApplication.h"
13 #include "ilog/TLoggerCompWrap.h"
14 
15 #include "icomp/TAttribute.h"
16 #include "icomp/CComponentBase.h"
17 
18 // IACF includes
19 #include "iabc/iabc.h"
20 
21 
22 namespace iabc
23 {
24 
25 
30  public QObject,
32  public ibase::IApplication
33 {
34  Q_OBJECT
35 public:
37 
38  I_BEGIN_COMPONENT(CServiceApplicationComp);
39  I_REGISTER_INTERFACE(ibase::IApplication);
40  I_ASSIGN(m_applicationCompPtr, "ApplicationInstance", "Service application object", true, "Application");
41  I_ASSIGN(m_serviceDescriptionAttrPtr, "SeriviceDescription", "Service description", true, "This services provides...");
42  I_ASSIGN(m_serviceNameAttrPtr, "ServiceName", "The name of the service", true, "MyService");
43  I_ASSIGN(m_manualStartupAttrPtr, "ManualStartup", "If enabled, the service is registered with manual start up", false, false);
44  I_END_COMPONENT;
45 
46  QStringList GetApplicationArguments(int argc, char** argv) const;
47 
48  // reimplemented (ibase::IApplication)
49  virtual bool InitializeApplication(int argc, char** argv);
50  virtual int Execute(int argc, char** argv);
51  virtual QString GetHelpText() const;
52  virtual QStringList GetApplicationArguments() const;
53 
54  // reimplemented (QObject)
55  virtual bool eventFilter(QObject* sourcePtr, QEvent* eventPtr);
56 
57 protected Q_SLOTS:
58  void OnTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
59 
60 protected:
61  class CService: public QtServiceBase
62  {
63  public:
64  typedef QtServiceBase BaseClass;
65 
67  ibase::IApplication& application,
68  int serviceArgc,
69  char** serviceArgv,
70  const QString &name);
71 
72  protected:
73  // reimplemented (QtServiceBase)
74  virtual void start();
75  virtual void stop();
76  virtual void pause();
77  virtual void resume();
78  virtual void createApplication(int &argc, char **argv);
79  virtual int executeApplication();
80 
81  private:
82  QVector<char*> GetApplicationArguments() const;
83 
84  private:
85  CServiceApplicationComp& m_parent;
86  ibase::IApplication& m_application;
87  QStringList m_applicationArguments;
88  };
89 
90 private:
91  I_REF(ibase::IApplication, m_applicationCompPtr);
92  I_ATTR(QString, m_serviceDescriptionAttrPtr);
93  I_ATTR(QString, m_serviceNameAttrPtr);
94  I_ATTR(bool, m_manualStartupAttrPtr);
95 
96  istd::TDelPtr<CService> m_servicePtr;
97 };
98 
99 
100 } // namespace iabc
101 
102 
103 #endif // iabc_CServiceApplicationComp_included
104 
virtual void createApplication(int &argc, char **argv)
virtual bool eventFilter(QObject *sourcePtr, QEvent *eventPtr)
CService(CServiceApplicationComp &parent, ibase::IApplication &application, int serviceArgc, char **serviceArgv, const QString &name)
virtual bool InitializeApplication(int argc, char **argv)
virtual QStringList GetApplicationArguments() const
void OnTrayIconActivated(QSystemTrayIcon::ActivationReason reason)
virtual QString GetHelpText() const
virtual int Execute(int argc, char **argv)
ilog::CLoggerComponentBase BaseClass
Qt based component for service-based application.

© 2007-2011 Witold Gantzke and Kirill Lepskiy