CSingletonDocApplicationComp.h
Go to the documentation of this file.
1 #ifndef iqtdoc_CSingletonDocApplicationComp_included
2 #define iqtdoc_CSingletonDocApplicationComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QSharedMemory>
7 #include <QtCore/QObject>
8 #include <QtCore/QTimer>
9 #include <QtCore/QString>
10 #include <QtCore/QStringList>
11 
12 // ACF includes
14 #include <icomp/CComponentBase.h>
15 #include <ibase/IApplicationInfo.h>
17 #include <idoc/IDocumentManager.h>
18 #include <iqtgui/IGuiApplication.h>
19 
20 
21 namespace iqtdoc
22 {
23 
24 
30  public QObject,
31  public icomp::CComponentBase,
32  protected imod::TSingleModelObserverBase<ibase::IRuntimeStatusProvider>,
33  virtual public ibase::IApplication
34 {
35  Q_OBJECT
36 public:
39 
40  I_BEGIN_COMPONENT(CSingletonDocApplicationComp);
41  I_REGISTER_INTERFACE(ibase::IApplication);
42  I_ASSIGN(m_applicationInfoCompPtr, "ApplicationInfo", "Application info used to identify the application in the system", false, "ApplicationInfo");
43  I_ASSIGN(m_slaveApplicationCompPtr, "Application", "Application component to be executed", true, "Application");
44  I_ASSIGN_TO(m_slaveGuiApplicationCompPtr, m_slaveApplicationCompPtr, false);
45  I_ASSIGN(m_documentManagerCompPtr, "DocumentManager", "Document manager used for opening of documents triggered by the shell", false, "DocumentManager");
46  I_ASSIGN(m_runtimeStatusProviderCompPtr, "RuntimeStatus", "Runtime status of the application", false, "RuntimeStatus");
47  I_ASSIGN_TO(m_runtimeStatusProviderModelCompPtr, m_runtimeStatusProviderCompPtr, false);
48  I_END_COMPONENT;
49 
51 
52  // reimplemented (ibase::IApplication)
53  virtual bool InitializeApplication(int argc, char** argv);
54  virtual int Execute(int argc, char** argv);
55  virtual QString GetHelpText() const;
56  virtual QStringList GetApplicationArguments() const;
57 
58 protected:
59  // reimplemented (imod::CSingleModelObserverBase)
60  virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet);
61 
62  // reimplemented (icomp::CComponentBase)
63  virtual void OnComponentCreated();
64  virtual void OnComponentDestroyed();
65 
66 private:
67  void ShareDocumentsForOpening(int argc, char** argv);
68  QStringList PopDocumentsForOpening() const;
69 
70 private Q_SLOTS:
71  void OnUpdateDocumentList();
72 
73 private:
74  enum{
78  MAX_DOCUMENT_PATH_LENGTH = 1024,
82  MAX_DOCUMENTS_COUNT = 100
83  };
84 
88  struct RunningProcessInfo
89  {
90  qint64 processId;
91  char requestedDocuments[MAX_DOCUMENTS_COUNT][MAX_DOCUMENT_PATH_LENGTH];
92  };
93 
94  I_REF(ibase::IApplicationInfo, m_applicationInfoCompPtr);
95  I_REF(ibase::IApplication, m_slaveApplicationCompPtr);
96  I_REF(iqtgui::IGuiApplication, m_slaveGuiApplicationCompPtr);
97 
98  istd::TDelPtr<QSharedMemory> m_processDataPtr;
99  bool m_isAlreadyRunning;
100  QTimer m_documentUpdateTimer;
101 
102  bool m_isApplicationInitialized;
103 
104  I_REF(idoc::IDocumentManager, m_documentManagerCompPtr);
105  I_REF(ibase::IRuntimeStatusProvider, m_runtimeStatusProviderCompPtr);
106  I_REF(imod::IModel, m_runtimeStatusProviderModelCompPtr);
107 };
108 
109 
110 } // namespace iqtdoc
111 
112 
113 #endif // !iqtdoc_CSingletonDocApplicationComp_included
114 
Interface for Qt based application with GUI.
imod::TSingleModelObserverBase< ibase::IRuntimeStatusProvider > BaseClass2
virtual QStringList GetApplicationArguments() const
Get the command line arguments of this application.
virtual int Execute(int argc, char **argv)
Start execution loop of the application.
Base class for component implementation.
Provider of the run-time status.
virtual void OnUpdate(const istd::IChangeable::ChangeSet &changeSet)
Called on update of observed model.
Basic implementation for a single model observer with binding to concrete data object interface...
virtual bool InitializeApplication(int argc, char **argv)
Initialize the application object.
Provide set of user actions needed to manage documents in MVC (Model View Controller) concept...
This interface provides some information about the application.
Common interface for model objects, that supports Model/Observer design pattern.
Definition: IModel.h:23
Set of change flags (its IDs).
Definition: IChangeable.h:30
virtual QString GetHelpText() const
Get information about the possible command line arguments of this application.
Interface for the main entry point of a component-based application.
Definition: IApplication.h:22

© 2007-2017 Witold Gantzke and Kirill Lepskiy