CHotfolderTaskManagerComp.h
Go to the documentation of this file.
1 #ifndef ihotfgui_CHotfolderTaskManagerComp_included
2 #define ihotfgui_CHotfolderTaskManagerComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QThread>
7 #include <QtCore/QTimer>
8 #include <QtCore/QList>
9 #include <QtCore/QDateTime>
10 
11 // ACF includes
12 #include "istd/TPointerVector.h"
13 
14 #include "imod/TModelWrap.h"
17 
18 #include "ilog/TLoggerCompWrap.h"
19 
20 #include "iprm/IParamsSet.h"
21 #include "iprm/IParamsManager.h"
22 
23 
24 // AcfSln includes
25 #include "ifileproc/IFileNaming.h"
30 
31 
32 namespace ihotfgui
33 {
34 
35 
44  virtual public ihotf::IHotfolderTaskManager
45 {
46 public:
48 
49  I_BEGIN_COMPONENT(CHotfolderTaskManagerComp);
50  I_REGISTER_INTERFACE(ihotf::IHotfolderTaskManager);
51  I_ASSIGN(m_fileNamingCompPtr, "FileNamingStrategy", "Strategy for naming of the output file", true, "FileNamingStrategy");
52  I_ASSIGN(m_monitorFactCompPtr, "DirectoryMontorFactory", "Factory for creation of a directory monitor", true, "DirectoryMontorFactory");
53  I_ASSIGN(m_hotfolderProcessingInfoCompPtr, "HotfolderProcessingInfo", "State data model of the hotfolder", true, "HotfolderProcessingInfo");
54  I_ASSIGN_TO(m_hotfolderProcessingModelCompPtr, m_hotfolderProcessingInfoCompPtr, true);
55  I_ASSIGN(m_inputDirectoriesManagerCompPtr, "InputDirectoriesManager", "Parameter's manageer for the hotfolder's input directories", true, "InputDirectoriesManager");
56  I_ASSIGN(m_hotfolderSettingsModelCompPtr, "HotfolderSettingsModel", "Hotfolder settings", true, "HotfolderSettingsModel");
57  I_ASSIGN(m_fileSystemChangeStorageCompPtr, "FileSystemChangeStorage", "File storage used by directory monitor", true, "FileSystemChangeStorage");
58  I_ASSIGN_TO(m_fileSystemChangeStorageModelCompPtr, m_fileSystemChangeStorageCompPtr, true);
59  I_END_COMPONENT;
60 
62 
63  // reimplemented (ihotf::IHotfolderTaskManager)
65 
66 protected:
67  // reimplemented (icomp::CComponentBase)
68  virtual void OnComponentCreated();
69  virtual void OnComponentDestroyed();
70 
71 private:
72  QStringList GetFilesFromStorage(const ihotf::IFileSystemChangeStorage& storage, int fileState) const;
73 
74  void OnFilesAddedEvent(const ihotf::IFileSystemChangeStorage& storage);
75  void OnFilesRemovedEvent(const ihotf::IFileSystemChangeStorage& storage);
76  void OnFilesModifiedEvent(const ihotf::IFileSystemChangeStorage& storage);
77 
78  void AddFilesToProcessingQueue(const QStringList& files);
79  void RemoveFilesFromProcessingQueue(const QStringList& files);
80  void RestartProcessingQueueFiles(const QStringList& files);
81 
87  void SynchronizeWithModel(bool applyToPendingTasks = false);
88 
92  QStringList GetInputDirectories() const;
93 
97  const iprm::IParamsSet* GetMonitoringParamsSet(const QString& directoryPath) const;
98 
102  QStringList GetAddedInputDirectories() const;
103 
107  QStringList GetRemovedInputDirectories() const;
108 
112  ihotf::IDirectoryMonitor* AddDirectoryMonitor(const QString& directoryPath, const iprm::IParamsSet* monitoringParamsPtr);
113 
117  void RemoveDirectoryMonitor(const QString& directoryPath);
118 
122  void RemoveDirectoryItems(const QString& directoryPath);
123 
127  ihotf::IHotfolderProcessingItem* FindProcessingItem(const QString& fileName) const;
128 
132  ihotf::IHotfolderProcessingItem* GetItemFromId(const QByteArray& itemUuid) const;
133 
134 private:
138  class FileSystemChangeStorageObserver: public imod::CMultiModelObserverBase
139  {
140  public:
141  FileSystemChangeStorageObserver(CHotfolderTaskManagerComp& parent);
142 
143  // reimplemented (imod::IObserver)
144  virtual void AfterUpdate(imod::IModel* modelPtr, int updateFlags, istd::IPolymorphic* updateParamsPtr);
145 
146  private:
147  CHotfolderTaskManagerComp& m_parent;
148  };
149 
150 
154  class ParametersObserver: public imod::CSingleModelObserverBase
155  {
156  public:
157  ParametersObserver(CHotfolderTaskManagerComp& parent);
158 
159  // reimplemented (imod::IObserver)
160  virtual void AfterUpdate(imod::IModel* modelPtr, int updateFlags, istd::IPolymorphic* updateParamsPtr);
161  private:
162  CHotfolderTaskManagerComp& m_parent;
163  };
164 
165 private:
166  I_REF(ifileproc::IFileNaming, m_fileNamingCompPtr);
167  I_REF(ihotf::IHotfolderProcessingInfo, m_hotfolderProcessingInfoCompPtr);
168  I_REF(imod::IModel, m_hotfolderProcessingModelCompPtr);
169  I_REF(iprm::IParamsManager, m_inputDirectoriesManagerCompPtr);
170  I_REF(imod::IModel, m_hotfolderSettingsModelCompPtr);
171  I_FACT(ihotf::IDirectoryMonitor, m_monitorFactCompPtr);
172  I_REF(ihotf::IFileSystemChangeStorage, m_fileSystemChangeStorageCompPtr);
173  I_REF(imod::IModel, m_fileSystemChangeStorageModelCompPtr);
174 
175  typedef QMap<QString, istd::TDelPtr<ihotf::IDirectoryMonitor> > DirectoryMonitorsMap;
176  DirectoryMonitorsMap m_directoryMonitorsMap;
177 
178  FileSystemChangeStorageObserver m_fileSystemChangeStorageObserver;
179  ParametersObserver m_parametersObserver;
180 
181  bool m_isInitialized;
182 };
183 
184 
185 } // namespace ihotfgui
186 
187 
188 #endif // !ihotfgui_CHotfolderTaskManagerComp_included
189 
Interface for a single processing item in the hotfolder.
virtual ihotf::IHotfolderProcessingItem * GetNextProcessingTask() const
Get the next processing task, if available, other.
Interface for calculation of the new file path for an existing file.
Definition: IFileNaming.h:16
I_ASSIGN_TO(m_hotfolderProcessingModelCompPtr, m_hotfolderProcessingInfoCompPtr, true)
Common interface for a storage of files.
Interface for a hotfolder's processing data model.
Common interface for a hotfolder processing trask mananger.
Interface for a folder monitor.

© 2007-2011 Witold Gantzke and Kirill Lepskiy