CFileSystemInfoProviderComp.h
Go to the documentation of this file.
1 #ifndef ifile_CFileSystemInfoProviderComp_included
2 #define ifile_CFileSystemInfoProviderComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QThread>
7 #include <QtCore/QMutex>
8 
9 // ACF includes
10 #include <ilog/TLoggerCompWrap.h>
14 
15 
16 namespace ifile
17 {
18 
19 
21  protected QThread,
23  virtual public ifile::IFileSystemInfoProvider,
24  virtual public iprm::IOptionsList,
26 {
27  Q_OBJECT
28 public:
30 
31  enum ModelId
32  {
34  };
35 
36  I_BEGIN_COMPONENT(CFileSystemInfoProviderComp);
37  I_REGISTER_INTERFACE(ifile::IFileSystemInfoProvider);
38  I_REGISTER_INTERFACE(iprm::IOptionsList);
39  I_ASSIGN(m_autoUpdatePeriodAttr, "AutomaticUpdatePeriod", "Automatic updates period, s", false, 10);
40  I_ASSIGN(m_runtimeStatusCompPtr, "RuntimeStatus", "Application's runtime status", false, "RuntimeStatus");
41  I_ASSIGN_TO(m_runtimeStatusModelCompPtr, m_runtimeStatusCompPtr, false);
42  I_END_COMPONENT;
43 
45 
46  // reimplemented (ifile::IFileSystemInfoProvider)
47  virtual const iprm::IOptionsList& GetDriveList() const;
48  virtual const istd::CSystem::FileDriveInfo* GetFileDriveInfo(int driveIndex = -1) const;
49 
50  // reimplemented (iprm::IOptionsList)
51  virtual int GetOptionsFlags() const;
52  virtual int GetOptionsCount() const;
53  virtual QString GetOptionName(int index) const;
54  virtual QString GetOptionDescription(int index) const;
55  virtual QByteArray GetOptionId(int index) const;
56  virtual bool IsOptionEnabled(int index) const;
57 
58 protected:
59  // reimplemented (icomp::CComponentBase)
60  virtual void OnComponentCreated();
61  virtual void OnComponentDestroyed();
62 
63  // reimplemented (imod::CMultiModelDispatcherBase)
64  virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet);
65 
66  // reimplemented (QThread)
67  virtual void run();
68 
69 protected:
70  struct DriveInfo
71  {
73  QString name;
74  QByteArray id;
75 
76  bool operator == (const DriveInfo& driveInfo) const
77  {
78  return (info == driveInfo.info) && (name == driveInfo.name) && (id == driveInfo.id);
79  }
80  };
81 
82  typedef std::vector<DriveInfo> DriveInfos;
83 
84 Q_SIGNALS:
85  void EmitUpdate(const DriveInfos& driveInfos);
86 
87 private Q_SLOTS:
88  void OnUpdate(const DriveInfos& driveInfos);
89 
90 private:
91  DriveInfos CalculateDriveInfos() const;
92 
93 private:
94  DriveInfos m_driveInfos;
95 
96  int m_sleepInterval;
97  bool m_threadTerminationRequested;
98 
99  mutable QMutex m_lock;
100 
101  I_ATTR(int, m_autoUpdatePeriodAttr);
102 
103  I_REF(ibase::IRuntimeStatusProvider, m_runtimeStatusCompPtr);
104  I_REF(imod::IModel, m_runtimeStatusModelCompPtr);
105 };
106 
107 
108 } // namespace ifile
109 
110 
111 #endif // !ifile_CFileSystemInfoProviderComp_included
112 
113 
bool operator==(const DriveInfo &driveInfo) const
virtual QString GetOptionName(int index) const
Get name of specified option.
Generic implementation of a data model changes notifier.
virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet &changeSet)
Constraints of selection from set of possibilities.
Definition: IOptionsList.h:22
Provider of the run-time status.
virtual bool IsOptionEnabled(int index) const
Return true if the option is enabled and can be selected.
virtual const istd::CSystem::FileDriveInfo * GetFileDriveInfo(int driveIndex=-1) const
Get info about a given file drive.
Wrapper provider of log-functionality for component based implementations.
virtual const iprm::IOptionsList & GetDriveList() const
Get the list of drives available on the local machine.
virtual QByteArray GetOptionId(int index) const
Get option ID.
void EmitUpdate(const DriveInfos &driveInfos)
Provider of file system related informations.
virtual int GetOptionsFlags() const
Get constraints flags.
virtual int GetOptionsCount() const
Get number of managed options.
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 GetOptionDescription(int index) const
Get human readable description for a option with the index index.

© 2007-2017 Witold Gantzke and Kirill Lepskiy