CPackagesLoaderComp.h
Go to the documentation of this file.
1 #ifndef ipackage_CPackagesLoaderComp_included
2 #define ipackage_CPackagesLoaderComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QMap>
7 #include <QtCore/QFileInfo>
8 #include <QtCore/QDir>
9 #include <QtCore/QLibrary>
10 
11 // ACF includes
12 #include <istd/TDelPtr.h>
13 #include <icomp/IRegistryLoader.h>
14 #include <icomp/CRegistry.h>
16 #include <icomp/CComponentBase.h>
18 #include <icomp/export.h>
19 #include <ilog/TLoggerCompWrap.h>
20 #include <ifile/IFilePersistence.h>
21 #include <ifile/IFileNameParam.h>
22 
23 
24 namespace ipackage
25 {
26 
27 
32  public QObject,
35  virtual public icomp::IRegistryLoader
36 {
37  Q_OBJECT
38 
39 public:
42 
43  enum MessageId
44  {
47  };
48 
49  I_BEGIN_COMPONENT(CPackagesLoaderComp);
50  I_REGISTER_INTERFACE(icomp::IRegistryLoader);
51  I_REGISTER_INTERFACE(icomp::IComponentEnvironmentManager);
52  I_REGISTER_INTERFACE(icomp::IComponentStaticInfo);
53  I_REGISTER_INTERFACE(icomp::IPackagesManager);
54  I_REGISTER_INTERFACE(icomp::IRegistriesManager);
55  I_REGISTER_INTERFACE(icomp::IMetaInfoManager);
56  I_ASSIGN(m_registryLoaderCompPtr, "RegistryLoader", "Loader used to read registry", true, "RegistryLoader");
57  I_ASSIGN(m_configFilePathCompPtr, "ConfigFilePath", "Path of packages configuration file will be loaded, if enabled", false, "ConfigFilePath");
58  I_END_COMPONENT;
59 
60  // reimplemented (icomp::IRegistryLoader)
61  virtual const icomp::IRegistry* GetRegistryFromFile(const QString& path) const;
62 
63  // reimplemented (icomp::IComponentEnvironmentManager)
64  virtual QString GetConfigFilePath() const;
65 
66  // reimplemented (icomp::IPackagesManager)
67  virtual bool LoadPackages(const QString& configFilePath = QString());
68  virtual int GetPackageType(const QByteArray& packageId) const;
69  virtual QString GetPackagePath(const QByteArray& packageId) const;
70  virtual QString GetRegistryPath(const icomp::CComponentAddress& address) const;
71 
72  // reimplemented (icomp::IRegistriesManager)
73  virtual const icomp::IRegistry* GetRegistry(const icomp::CComponentAddress& address, const icomp::IRegistry* contextRegistryPtr = NULL) const;
74 
75  // reimplemented (icomp::IComponentListProvider)
76  virtual ComponentAddresses GetComponentAddresses(int typeFlag = CTF_ALL) const;
77 
78  // reimplemented (icomp::CComponentBase)
79  virtual void OnComponentCreated();
80 
81 protected:
83  {
84  public:
86 
87  explicit LogingRegistry(CPackagesLoaderComp* parentPtr);
88 
89  // reimplemented (icomp::IRegistry)
91  const QByteArray& elementId,
92  const icomp::CComponentAddress& address,
93  bool ensureElementCreated = true);
94 
95  private:
96  CPackagesLoaderComp& m_parent;
97  };
98 
99  virtual bool RegisterPackageFile(const QString& file);
100  virtual bool RegisterPackagesDir(const QString& subDir);
101  virtual bool LoadConfigFile(const QString& configFile);
102 
103  icomp::GetPackageInfoFunc GetPackageFunction(const QFileInfo& fileInfo);
104 
108  bool CheckAndMarkPath(const QDir& directory, const QString& path, QString& resultPath) const;
109 
110 private:
111  typedef QMap<QString, icomp::GetPackageInfoFunc> LibraryToInfoFuncMap;
112  LibraryToInfoFuncMap m_libraryToInfoFuncMap;
113 
114  typedef QMap<QByteArray, QString> ComponentIdToRegistryFileMap;
115  struct CompositePackageInfo
116  {
118 
119  QDir directory;
120  ComponentIdToRegistryFileMap componentIdToRegistryFileMap;
121  };
125  typedef QMap<QByteArray, QString> RealPackagesMap;
126  RealPackagesMap m_realPackagesMap;
127 
131  typedef QMap<QByteArray, CompositePackageInfo> CompositePackagesMap;
132  CompositePackagesMap m_compositePackagesMap;
133 
134  typedef istd::TDelPtr<icomp::IRegistry> RegistryPtr;
135  typedef QMap<QString, RegistryPtr> RegistriesMap;
136  typedef QMap<const icomp::IRegistry*, QFileInfo> InvRegistriesMap;
137 
138  mutable RegistriesMap m_registriesMap;
139  mutable InvRegistriesMap m_invRegistriesMap;
140 
144  typedef QSet<QString> PathList;
145  mutable PathList m_usedFilesList;
146 
147  QString m_configFilePath;
148 
149  I_REF(ifile::IFilePersistence, m_registryLoaderCompPtr);
150  I_REF(ifile::IFileNameParam, m_configFilePathCompPtr);
151 };
152 
153 
154 } // namespace ipackage
155 
156 
157 #endif // !ipackage_CPackagesLoaderComp_included
158 
159 
Represents global address of component.
Standard implementation of registry.
Definition: CRegistry.h:20
virtual void OnComponentCreated()
ilog::CLoggerComponentBase BaseClass
virtual QString GetPackagePath(const QByteArray &packageId) const
Get directory path of specified component package.
Interface representing information stored in component registry.
Definition: IRegistry.h:30
virtual const icomp::IRegistry * GetRegistryFromFile(const QString &path) const
Get an ACF registry from a given file.
bool CheckAndMarkPath(const QDir &directory, const QString &path, QString &resultPath) const
Check if path was already visited and return enrolled value.
virtual QString GetRegistryPath(const icomp::CComponentAddress &address) const
Get registry file path, if it is composed registry.
Interface for a ACF registry loader.
virtual ComponentAddresses GetComponentAddresses(int typeFlag=CTF_ALL) const
Get addresses of known components.
virtual int GetPackageType(const QByteArray &packageId) const
Get type of package as defined in PackageType.
virtual bool LoadPackages(const QString &configFilePath=QString())
Configure environment for specified file path.
Wrapper provider of log-functionality for component based implementations.
Common interface for any file system item name (e.g directory, file or URL path)
virtual const icomp::IRegistry * GetRegistry(const icomp::CComponentAddress &address, const icomp::IRegistry *contextRegistryPtr=NULL) const
Get access to stored registry.
icomp::CEnvironmentManagerBase BaseClass2
QSet< CComponentAddress > ComponentAddresses
#define NULL
Definition: istd.h:64
Describe information stored with each element.
Definition: IRegistry.h:51
virtual bool RegisterPackageFile(const QString &file)
Allow access to registries defined by composed components.
Interface providing loading and saving of data objects.
virtual bool RegisterPackagesDir(const QString &subDir)
virtual QString GetConfigFilePath() const
Get file path of real used config file.
icomp::GetPackageInfoFunc GetPackageFunction(const QFileInfo &fileInfo)
This interface provide static information about component meta info.
Loads component packages from dynamic link libraries.
virtual ElementInfo * InsertElementInfo(const QByteArray &elementId, const icomp::CComponentAddress &address, bool ensureElementCreated=true)
Insert new attribute info object to collection of attributes.
virtual bool LoadConfigFile(const QString &configFile)
LogingRegistry(CPackagesLoaderComp *parentPtr)

© 2007-2017 Witold Gantzke and Kirill Lepskiy