Go to the documentation of this file.
1 #ifndef ipackage_CRegistryCodeSaverComp_included
2 #define ipackage_CRegistryCodeSaverComp_included
5 // Qt includes
6 #include <QtCore/QList>
7 #include <QtCore/QSet>
8 #include <QtCore/QTextStream>
10 // ACF includes
11 #include <icomp/IRegistry.h>
14 #include <iprm/ISelectionParam.h>
15 #include <iprm/IOptionsList.h>
16 #include <ilog/TLoggerCompWrap.h>
17 #include <ifile/IFilePersistence.h>
18 #include <ifile/IFileNameParam.h>
21 namespace ipackage
22 {
31 {
32 public:
35  enum MessageId
36  {
41  };
44  {
53  };
55  I_BEGIN_COMPONENT(CRegistryCodeSaverComp);
56  I_REGISTER_INTERFACE(ifile::IFileTypeInfo);
57  I_REGISTER_INTERFACE(ifile::IFilePersistence);
58  I_REGISTER_INTERFACE(iprm::IOptionsList);
59  I_ASSIGN(m_packagesManagerCompPtr, "PackagesManager", "Packages manager providing access to package informations", true, "PackagesManager");
60  I_ASSIGN_TO(m_extPackagesManagerCompPtr, m_packagesManagerCompPtr, false);
61  I_ASSIGN(m_registriesManagerCompPtr, "RegistriesManager", "Registries manager providing access to all composite component registries", true, "RegistriesManager");
62  I_ASSIGN(m_workingModeAttrPtr, "WorkingMode", "Working mode\n\t0 - generate sources\n\t1 - generate dependencies to registries\n\t2 - generate all dependencies", true, 0);
63  I_ASSIGN(m_translationLevelAttrPtr, "TranslationLevel", "Level of configuration used for translation all packages, if disabled all levels of used packages will be stored", false, 0);
64  I_ASSIGN(m_useBinaryCodeAttrPtr, "UseBinaryCode", "If true, binary serialized registries will be used instead of generated by code", true, false);
69  // reimplemented (ifile::IFilePersistence)
70  virtual bool IsOperationSupported(
71  const istd::IChangeable* dataObjectPtr,
72  const QString* filePathPtr = NULL,
73  int flags = -1,
74  bool beQuiet = true) const;
75  virtual int LoadFromFile(
76  istd::IChangeable& data,
77  const QString& filePath = QString(),
78  ibase::IProgressManager* progressManagerPtr = NULL) const;
79  virtual int SaveToFile(
80  const istd::IChangeable& data,
81  const QString& filePath = QString(),
82  ibase::IProgressManager* progressManagerPtr = NULL) const;
84  // reimplemented (ifile::IFileTypeInfo)
85  virtual bool GetFileExtensions(QStringList& result, const istd::IChangeable* dataObjectPtr = NULL, int flags = -1, bool doAppend = false) const;
86  virtual QString GetTypeDescription(const QString* extensionPtr = NULL) const;
88 protected:
89  typedef QSet<icomp::CComponentAddress> Addresses;
90  typedef QSet<QByteArray> Ids;
95  bool AppendAddresses(
96  const icomp::IRegistry& registry,
97  const QStringList& registryPath,
98  Addresses& realAddresses,
99  Addresses& composedAddresses) const;
100  Ids ExtractPackageIds(const Addresses& addresses) const;
101  Ids ExtractComponentIds(const Addresses& addresses, const QByteArray& packageId) const;
103  bool WriteHeader(
104  const QByteArray& className,
105  const icomp::IRegistry& registry,
106  const Addresses& composedAddresses,
107  const Addresses& realAddresses,
108  QTextStream& stream) const;
109  bool WriteIncludes(
110  const QByteArray& className,
111  const Addresses& addresses,
112  QTextStream& stream) const;
114  const QByteArray& className,
115  const icomp::IRegistry& registry,
116  const Addresses& composedAddresses,
117  const Addresses& realAddresses,
118  QTextStream& stream) const;
119  bool WriteDependencies(
120  const Addresses& composedAddresses,
121  const Addresses& realAddresses,
122  QTextStream& stream) const;
123  bool WriteRegistryInfo(
124  const icomp::IRegistry& registry,
125  const QByteArray& registryCallPrefix,
126  QTextStream& stream) const;
127  bool WriteComponentInfo(
128  const icomp::IRegistry& registry,
129  const QByteArray& registryCallPrefix,
130  const QByteArray& componentId,
131  const icomp::IRegistry::ElementInfo& componentInfo,
132  QTextStream& stream) const;
133  bool WriteAttribute(
134  const QByteArray& attributeId,
135  const QByteArray& componentId,
136  const QByteArray& attributeName,
137  const iser::IObject& attribute,
138  QTextStream& stream) const;
144  const icomp::IRegistry& registry,
145  bool& translationFound,
146  QTextStream& stream) const;
151  int level,
152  bool& translationFound,
153  QTextStream& stream) const;
159  const QByteArray& componentId,
160  const icomp::IRegistry::ElementInfo& componentInfo,
161  bool& translationFound,
162  QTextStream& stream) const;
165  const QByteArray& baseClassName,
166  const QByteArray& registryClassName,
167  const icomp::IRegistry& registry,
168  QTextStream& stream) const;
170  const QByteArray& baseClassName,
171  const QByteArray& registryClassName,
172  const icomp::IRegistry& registry,
173  QTextStream& stream) const;
177  bool WriteDeserializingCode(const iser::ISerializable& object, QTextStream& stream) const;
179  bool GetAttributeValue(
180  const iser::ISerializable& attribute,
181  QByteArray& valueString,
182  QByteArray& typeName) const;
184  const iser::ISerializable& attribute,
185  QList<QByteArray>& valueStrings,
186  QByteArray& typeName) const;
191  bool NextLine(QTextStream& stream) const;
192  int ChangeIndent(int difference) const;
197  bool ExtractInfoFromFile(const QString& filePath, QByteArray& className, QString& baseFilePath) const;
202  QByteArray GetPackageName(const QByteArray& packageId) const;
207  QByteArray GetStringLiteral(const QString& text) const;
211  QByteArray GetIdValueLiteral(const QByteArray& text) const;
215  QByteArray GetValidIdentifier(const QByteArray& identifier) const;
217 private:
218  I_REF(icomp::IPackagesManager, m_packagesManagerCompPtr);
219  I_REF(icomp::IExtPackagesManager, m_extPackagesManagerCompPtr);
220  I_REF(icomp::IRegistriesManager, m_registriesManagerCompPtr);
221  I_ATTR(int, m_workingModeAttrPtr);
222  I_ATTR(int, m_translationLevelAttrPtr);
223  I_ATTR(bool, m_useBinaryCodeAttrPtr);
225  mutable int m_indentCount;
226 };
229 } // namespace ipackage
232 #endif // !ipackage_CRegistryCodeSaverComp_included
bool WriteRegistryTranslation(const icomp::IRegistry &registry, bool &translationFound, QTextStream &stream) const
Write translation macro of all string attributes from registry.
virtual int SaveToFile(const istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const
This function saves data data to file filePath.
bool GetMultiAttributeValue(const iser::ISerializable &attribute, QList< QByteArray > &valueStrings, QByteArray &typeName) const
bool ExtractInfoFromFile(const QString &filePath, QByteArray &className, QString &baseFilePath) const
Extract class name and absolute header path from a file name.
Provide loading and saving of objects.
Definition: IFileTypeInfo.h:22
bool WriteRegistryClassDeclaration(const QByteArray &baseClassName, const QByteArray &registryClassName, const icomp::IRegistry &registry, QTextStream &stream) const
virtual QString GetTypeDescription(const QString *extensionPtr=NULL) const
Get description of object type associated with single extension.
bool WriteComponentInfo(const icomp::IRegistry &registry, const QByteArray &registryCallPrefix, const QByteArray &componentId, const icomp::IRegistry::ElementInfo &componentInfo, QTextStream &stream) const
ilog::CLoggerComponentBase BaseClass
Ids ExtractComponentIds(const Addresses &addresses, const QByteArray &packageId) const
QByteArray GetIdValueLiteral(const QByteArray &text) const
Get some string as C++ string literal.
bool WriteIncludes(const QByteArray &className, const Addresses &addresses, QTextStream &stream) const
Interface representing information stored in component registry.
Definition: IRegistry.h:30
Constraints of selection from set of possibilities.
Definition: IOptionsList.h:22
virtual int LoadFromFile(istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const
This function loads data data from file filePath.
Common class for all classes which objects can be archived or restored from archive.
Definition: ISerializable.h:23
Common interface for factorisable model objects.
Definition: IObject.h:19
virtual bool GetFileExtensions(QStringList &result, const istd::IChangeable *dataObjectPtr=NULL, int flags=-1, bool doAppend=false) const
Get file extensions supported by this loader.
bool WriteHeader(const QByteArray &className, const icomp::IRegistry &registry, const Addresses &composedAddresses, const Addresses &realAddresses, QTextStream &stream) const
bool AppendAddresses(const icomp::IRegistry &registry, const QStringList &registryPath, Addresses &realAddresses, Addresses &composedAddresses) const
Get component addresses used by given registry and its elements (recursively).
bool WritePackagesTranslation(int level, bool &translationFound, QTextStream &stream) const
Write translation macro of all string attributes from packages till some level of package depth...
QByteArray GetStringLiteral(const QString &text) const
Get some wide string as C++ string literal.
bool WriteDependencies(const Addresses &composedAddresses, const Addresses &realAddresses, QTextStream &stream) const
bool NextLine(QTextStream &stream) const
Insert a new line and indentation tabs.
Wrapper provider of log-functionality for component based implementations.
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
Generation of dependencies to all related ACF registry files.
int ChangeIndent(int difference) const
bool WriteDeserializingCode(const iser::ISerializable &object, QTextStream &stream) const
Write code deserializing some object from data buffer.
Ids ExtractPackageIds(const Addresses &addresses) const
QSet< icomp::CComponentAddress > Addresses
bool WriteComponentTranslation(const QByteArray &componentId, const icomp::IRegistry::ElementInfo &componentInfo, bool &translationFound, QTextStream &stream) const
Write translation macro of all string attributes from component.
QByteArray GetValidIdentifier(const QByteArray &identifier) const
Get valid C++ identifier (used for variable names) from arbitrary string.
bool GetAttributeValue(const iser::ISerializable &attribute, QByteArray &valueString, QByteArray &typeName) const
#define NULL
Definition: istd.h:64
Describe information stored with each element.
Definition: IRegistry.h:51
bool WriteClassDefinitions(const QByteArray &className, const icomp::IRegistry &registry, const Addresses &composedAddresses, const Addresses &realAddresses, QTextStream &stream) const
QByteArray GetPackageName(const QByteArray &packageId) const
Ensure that a package name ends with 'Pck'.
bool WriteRegistryClassBody(const QByteArray &baseClassName, const QByteArray &registryClassName, const icomp::IRegistry &registry, QTextStream &stream) const
Allow access to registries defined by composed components.
List of possible message IDs used in context of this interface.
Save registry as C++ code (it generates C++ class with the same functionality) and/or dependencies li...
virtual bool IsOperationSupported(const istd::IChangeable *dataObjectPtr, const QString *filePathPtr=NULL, int flags=-1, bool beQuiet=true) const
Returns true if object dataObject can be loaded/saved.
Interface providing loading and saving of data objects.
bool WriteAttribute(const QByteArray &attributeId, const QByteArray &componentId, const QByteArray &attributeName, const iser::IObject &attribute, QTextStream &stream) const
bool WriteRegistryInfo(const icomp::IRegistry &registry, const QByteArray &registryCallPrefix, QTextStream &stream) const
Consume information about progress of some process.

© 2007-2017 Witold Gantzke and Kirill Lepskiy