CRegistriesManagerComp.h
Go to the documentation of this file.
1 #ifndef ipackage_CRegistriesManagerComp_included
2 #define ipackage_CRegistriesManagerComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QMap>
7 #include <QtCore/QDir>
8 
9 // ACF includes
10 #include <istd/TDelPtr.h>
13 #include <icomp/IRegistryLoader.h>
14 #include <icomp/CComponentBase.h>
15 #include <ilog/TLoggerCompWrap.h>
16 #include <ifile/IFilePersistence.h>
17 #include <ifile/IFileNameParam.h>
18 
19 
20 namespace ipackage
21 {
22 
23 
30  virtual public icomp::IExtPackagesManager,
31  virtual public icomp::IRegistriesManager,
32  virtual public icomp::IRegistryLoader
33 {
34 public:
36 
37  enum MessageId
38  {
41  };
42 
43  I_BEGIN_COMPONENT(CRegistriesManagerComp);
44  I_REGISTER_INTERFACE(icomp::IExtPackagesManager);
45  I_REGISTER_INTERFACE(icomp::IPackagesManager);
46  I_REGISTER_INTERFACE(icomp::IRegistriesManager);
47  I_REGISTER_INTERFACE(icomp::IRegistryLoader);
48  I_ASSIGN(m_registryLoaderCompPtr, "RegistryLoader", "Loader used to read registry", true, "RegistryLoader");
49  I_ASSIGN(m_configFilePathCompPtr, "ConfigFilePath", "Path of packages configuration file will be loaded, if enabled", false, "ConfigFilePath");
50  I_ASSIGN(m_ignoreRealPackagesAttrPtr, "AreRealPackagesIgnored", "If set to true, all real packages will be ignored", true, false);
51  I_END_COMPONENT;
52 
53  // reimplemented (icomp::IExtPackagesManager)
54  virtual PathList GetConfigurationPathList(PathType pathType) const;
55  virtual int GetPackageDefinitionLevel(const QByteArray& packageId) const;
56 
57  // reimplemented (icomp::IPackagesManager)
58  virtual bool LoadPackages(const QString& configFilePath = QString());
59  virtual int GetPackageType(const QByteArray& packageId) const;
60  virtual QString GetPackagePath(const QByteArray& packageId) const;
61  virtual QString GetRegistryPath(const icomp::CComponentAddress& address) const;
62 
63  // reimplemented (icomp::IRegistriesManager)
64  virtual const icomp::IRegistry* GetRegistry(const icomp::CComponentAddress& address, const icomp::IRegistry* contextRegistryPtr = NULL) const;
65 
66  // reimplemented (icomp::IComponentListProvider)
67  virtual ComponentAddresses GetComponentAddresses(int typeFlag = CTF_ALL) const;
68 
69  // reimplemented (icomp::IRegistryLoader)
70  virtual const icomp::IRegistry* GetRegistryFromFile(const QString& path) const;
71 
72 protected:
73  void RegisterPackageFile(const QString& file, int definitionLevel);
74  void RegisterPackagesDir(const QString& subDir, int definitionLevel);
75  bool LoadConfigFile(const QString& configFile, int definitionLevel);
76 
77  bool CheckAndMarkPath(PathList& pathList, const QDir& directory, const QString& path, QString& resultPath) const;
78 
79  // reimplemented (icomp::CComponentBase)
80  virtual void OnComponentCreated();
81 
82 private:
83  struct RealPackageInfo
84  {
85  QString filePath;
86  int definitionLevel;
87  };
91  typedef QMap<QByteArray, RealPackageInfo> RealPackagesMap;
92  RealPackagesMap m_realPackagesMap;
93 
94  typedef QMap<QByteArray, QString> ComponentIdToRegistryFileMap;
95  struct CompositePackageInfo
96  {
97  QDir directory;
98  ComponentIdToRegistryFileMap componentIdToRegistryFileMap;
99  int definitionLevel;
100  };
104  typedef QMap<QByteArray, CompositePackageInfo> CompositePackagesMap;
105  CompositePackagesMap m_compositePackagesMap;
106 
107  typedef istd::TDelPtr<icomp::IRegistry> RegistryPtr;
108  typedef QMap<QString, RegistryPtr> RegistriesMap;
109 
110  mutable RegistriesMap m_registriesMap;
111 
112  mutable PathList m_usedConfigFilesList;
113  mutable PathList m_usedPackageDirsList;
114  mutable PathList m_usedPackageFilesList;
115  mutable PathList m_usedRegistryFilesList;
116 
117  I_REF(ifile::IFilePersistence, m_registryLoaderCompPtr);
118  I_REF(ifile::IFileNameParam, m_configFilePathCompPtr);
119  I_ATTR(bool, m_ignoreRealPackagesAttrPtr);
120 };
121 
122 
123 } // namespace ipackage
124 
125 
126 #endif // !ipackage_CRegistriesManagerComp_included
127 
128 
Represents global address of component.
virtual int GetPackageDefinitionLevel(const QByteArray &packageId) const
Get level of package definition in configuration.
bool LoadConfigFile(const QString &configFile, int definitionLevel)
virtual PathList GetConfigurationPathList(PathType pathType) const
Get list of files used for configuration.
Interface representing information stored in component registry.
Definition: IRegistry.h:30
virtual QString GetRegistryPath(const icomp::CComponentAddress &address) const
Get registry file path, if it is composed registry.
Interface for a ACF registry loader.
Manages registries and composed component.
void RegisterPackageFile(const QString &file, int definitionLevel)
void RegisterPackagesDir(const QString &subDir, int definitionLevel)
virtual QString GetPackagePath(const QByteArray &packageId) const
Get directory path of specified component package.
Wrapper provider of log-functionality for component based implementations.
virtual int GetPackageType(const QByteArray &packageId) const
Get type of package as defined in PackageType.
Common interface for any file system item name (e.g directory, file or URL path)
bool CheckAndMarkPath(PathList &pathList, const QDir &directory, const QString &path, QString &resultPath) const
virtual ComponentAddresses GetComponentAddresses(int typeFlag=CTF_ALL) const
Get addresses of known components.
QSet< CComponentAddress > ComponentAddresses
virtual const icomp::IRegistry * GetRegistryFromFile(const QString &path) const
Get an ACF registry from a given file.
#define NULL
Definition: istd.h:64
ilog::CLoggerComponentBase BaseClass
virtual bool LoadPackages(const QString &configFilePath=QString())
Configure environment for specified file path.
Allow access to registries defined by composed components.
QSet< QString > PathList
List of pathes.
virtual const icomp::IRegistry * GetRegistry(const icomp::CComponentAddress &address, const icomp::IRegistry *contextRegistryPtr=NULL) const
Get access to stored registry.
Interface providing loading and saving of data objects.
Pointer wrapper providing automatic deleting pointed object during destruction.
Definition: TDelPtr.h:20

© 2007-2017 Witold Gantzke and Kirill Lepskiy