CPropertiesManager.h
Go to the documentation of this file.
1 #ifndef iprop_CPropertiesManager_included
2 #define iprop_CPropertiesManager_included
3 
4 
5 // ACF includes
7 #include "istd/TSingleFactory.h"
9 #include "istd/TDelPtr.h"
10 #include "iser/IArchive.h"
11 #include "iser/CArchiveTag.h"
12 
13 // ACF-Solutions includes
14 #include "iprop/TProperty.h"
15 #include "iprop/TMultiProperty.h"
17 
18 
19 namespace iprop
20 {
21 
22 
27 {
28 public:
29  /*
30  Internal property info object.
31  */
32  struct PropertyInfo
33  {
34  QByteArray propertyId;
35  QByteArray propertyDescription;
37 
39  };
40 
42 
46  PropertyInfo* GetPropertyInfo(const QByteArray& propertyId) const;
47 
51  template <typename PropertyType>
52  static bool RegisterPropertyType();
53 
54  // reimplemented (iprop::IPropertiesManager)
55  virtual void ResetProperties();
56  virtual int GetPropertiesCount() const;
57  virtual iser::IObject* GetProperty(int propertyIndex) const;
58  virtual QByteArray GetPropertyId(int propertyIndex) const;
59  virtual QString GetPropertyDescription(int propertyIndex) const;
60  virtual IProperty::PropertyFlags GetPropertyFlags(int propertyIndex) const;
61  virtual void InsertProperty(
62  iser::IObject* objectPtr,
63  const QByteArray& propertyId,
64  const QByteArray& propertyDescription,
65  int propertyFlags,
66  bool releaseFlag);
67 
68  // reimplemented (iser::ISerializable)
69  virtual bool Serialize(iser::IArchive& archive);
70 
71 protected:
79  bool RemoveProperty(const QByteArray& propertyId, bool onlyOwned = true);
80  bool ReadProperties(
81  iser::IArchive& archive,
82  const iser::CArchiveTag& propertiesTag,
83  const iser::CArchiveTag& propertyTag);
84 
85  bool WriteProperties(
86  iser::IArchive& archive,
87  const iser::CArchiveTag& propertiesTag,
88  const iser::CArchiveTag& propertyTag) const;
89 private:
94  bool AreIdsEqual(QByteArray firstId, QByteArray secondId) const;
95 
97 
98  static PropertyFactory& GetPropertyFactory();
99 
100 private:
101  istd::TPointerVector<PropertyInfo> m_propertiesList;
102 };
103 
104 
105 // public static methods
106 
107 template <typename PropertyImpl>
109 {
110  return GetPropertyFactory().RegisterFactory(new istd::TSingleFactory<iser::IObject, PropertyImpl>(PropertyImpl::GetTypeName()), true);
111 }
112 
113 
114 } // namespace iprop
115 
116 
117 #endif // !iprop_CPropertiesManager_included
118 
119 
virtual QByteArray GetPropertyId(int propertyIndex) const
Get the ID of the property with the given index propertyIndex.
virtual IProperty::PropertyFlags GetPropertyFlags(int propertyIndex) const
Get the property flags.
bool ReadProperties(iser::IArchive &archive, const iser::CArchiveTag &propertiesTag, const iser::CArchiveTag &propertyTag)
virtual void InsertProperty(iser::IObject *objectPtr, const QByteArray &propertyId, const QByteArray &propertyDescription, int propertyFlags, bool releaseFlag)
Insert an property into the object.
Common interface for a container of properties.
virtual bool Serialize(iser::IArchive &archive)
Basic implementation of an property container.
static bool RegisterPropertyType()
Register a new property type.
istd::TOptDelPtr< iser::IObject > objectPtr
virtual int GetPropertiesCount() const
Get number of properties.
bool RegisterFactory(FactoryInterface *factoryPtr, bool releaseFlag=false)
PropertyInfo * GetPropertyInfo(const QByteArray &propertyId) const
Get property info object for a given property ID.
bool RemoveProperty(const QByteArray &propertyId, bool onlyOwned=true)
Remove property from manager.
virtual QString GetPropertyDescription(int propertyIndex) const
Get the description of the property with the given index propertyIndex.
bool WriteProperties(iser::IArchive &archive, const iser::CArchiveTag &propertiesTag, const iser::CArchiveTag &propertyTag) const
virtual void ResetProperties()
Reset properties.
virtual iser::IObject * GetProperty(int propertyIndex) const
Get property with the given index.

© 2007-2011 Witold Gantzke and Kirill Lepskiy