CHotfolderProcessingComp.h
Go to the documentation of this file.
1 #ifndef ihotfgui_CHotfolderProcessingComp_included
2 #define ihotfgui_CHotfolderProcessingComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QThread>
7 #include <QtCore/QTimer>
8 #include <QtCore/QDateTime>
9 
10 // ACF includes
11 #include "istd/TPointerVector.h"
12 #include "imod/IModel.h"
15 #include "ilog/TLoggerCompWrap.h"
16 
17 // AcfSln includes
20 
21 
22 namespace ihotfgui
23 {
24 
25 
30 {
31  Q_OBJECT
32 public:
34 
35  I_BEGIN_COMPONENT(CHotfolderProcessingComp);
36  I_ASSIGN(m_fileConvertCompPtr, "FileConverter", "File converter", true, "FileConverter");
37  I_ASSIGN(m_hotfolderProcessingInfoCompPtr, "HotfolderProcessingInfo", "State data model of the hotfolder", true, "HotfolderProcessingInfo");
38  I_ASSIGN_TO(m_hotfolderProcessingModelCompPtr, m_hotfolderProcessingInfoCompPtr, true);
39  I_ASSIGN(m_taskManagerCompPtr, "TaskManager", "Hotfolder task manager", true, "TaskManager");
40  I_END_COMPONENT;
41 
43 
44 protected:
48  class ItemProcessor: public QThread
49  {
50  public:
51  typedef QThread BaseClass;
52 
55  const QString& inputFilePath,
56  const QString& outputFilePath,
57  const QByteArray& itemUuid);
58 
59  int GetProcessingState() const;
60  QByteArray GetItemUuid() const;
61  QDateTime GetStartTime() const;
62  double GetProcessingTime() const;
63  void Cancel();
64 
65  protected:
66  // reimplemented (QThread)
67  virtual void run();
68 
69  private:
70  CHotfolderProcessingComp& m_parent;
71  QString m_inputFilePath;
72  QString m_outputFilePath;
73  QByteArray m_itemUuid;
74  int m_processingState;
75  double m_processingTime;
76  QDateTime m_startTime;
77  };
78 
79  // reimplemented (icomp::CComponentBase)
80  virtual void OnComponentCreated();
81  virtual void OnComponentDestroyed();
82 
83 protected Q_SLOTS:
84  void OnProcessingTimer();
85  void OnProcessingItemFinished(const ItemProcessor& processor);
86 
87 private:
91  void OnCancelProcessingItem(const ihotf::IHotfolderProcessingItem* processingItemPtr);
92 
96  void CancelAllProcessingItems();
97 
101  ihotf::IHotfolderProcessingItem* GetItemFromId(const QByteArray& itemUuid) const;
102 
103 private:
107  class StateObserver: public imod::CSingleModelObserverBase
108  {
109  public:
111 
112  StateObserver(CHotfolderProcessingComp& parent);
113 
114  // reimplemented (imod::IObserver)
115  virtual void AfterUpdate(imod::IModel* modelPtr, int updateFlags, istd::IPolymorphic* updateParamsPtr);
116  private:
117  CHotfolderProcessingComp& m_parent;
118  };
119 
120 private:
121  I_REF(ifileproc::IFileConvertCopy, m_fileConvertCompPtr);
122  I_REF(ihotf::IHotfolderProcessingInfo, m_hotfolderProcessingInfoCompPtr);
123  I_REF(imod::IModel, m_hotfolderProcessingModelCompPtr);
124  I_REF(ihotf::IHotfolderTaskManager, m_taskManagerCompPtr);
125 
126  StateObserver m_stateObserver;
127 
128  QTimer m_processingTimer;
129 
130  typedef istd::TPointerVector<ItemProcessor> PendingProcessors;
131  PendingProcessors m_pendingProcessors;
132 
133  bool m_isInitialized;
134 };
135 
136 
137 } // namespace ihotfgui
138 
139 
140 #endif // !ihotfgui_CHotfolderProcessingComp_included
141 
Interface for a single processing item in the hotfolder.
ItemProcessor(CHotfolderProcessingComp &parent, const QString &inputFilePath, const QString &outputFilePath, const QByteArray &itemUuid)
Common interface for file copying.
Interface for a hotfolder's processing data model.
void OnProcessingItemFinished(const ItemProcessor &processor)
Common interface for a hotfolder processing trask mananger.
I_ASSIGN_TO(m_hotfolderProcessingModelCompPtr, m_hotfolderProcessingInfoCompPtr, true)

© 2007-2011 Witold Gantzke and Kirill Lepskiy