00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef _DATAQUAY_PROPERTY_OBJECT_H_
00035 #define _DATAQUAY_PROPERTY_OBJECT_H_
00036
00037 #include <QString>
00038 #include <QUrl>
00039 #include <map>
00040
00041 namespace Dataquay
00042 {
00043
00044 class Transaction;
00045 class Store;
00046
00085 class PropertyObject
00086 {
00087 public:
00093 PropertyObject(Store *s, QUrl myUri);
00094
00101 PropertyObject(Store *s, QString myUri);
00102
00108 PropertyObject(Store *s, QString propertyPrefix, QUrl myUri);
00109
00115 PropertyObject(Store *s, QString propertyPrefix, QString myUri);
00116
00123 bool hasProperty(QString name) const;
00124
00131 bool hasProperty(Transaction *tx, QString name) const;
00132
00141 QVariant getProperty(QString name) const;
00142
00152 QVariant getProperty(Transaction *tx, QString name) const;
00153
00162 void setProperty(Transaction *tx, QString name, QVariant value);
00163
00169 void removeProperty(Transaction *tx, QString name);
00170
00178 Store *getStore(Transaction *tx) const;
00179
00186 QUrl getPropertyUri(QString name) const;
00187
00193 static void setDefaultPropertyPrefix(QString prefix);
00194
00195 private:
00196 Store *m_store;
00197 QString m_pfx;
00198 QUrl m_uri;
00199 static QString m_defaultPrefix;
00200 };
00201
00212 class CacheingPropertyObject
00213 {
00214 public:
00215 CacheingPropertyObject(Store *s, QUrl myUri);
00216 CacheingPropertyObject(Store *s, QString myUri);
00217 CacheingPropertyObject(Store *s, QString propertyPrefix, QUrl myUri);
00218 CacheingPropertyObject(Store *s, QString propertyPrefix, QString myUri);
00219
00220 bool hasProperty(QString name) const;
00221 bool hasProperty(Transaction *tx, QString name) const;
00222 QVariant getProperty(QString name) const;
00223 QVariant getProperty(Transaction *tx, QString name) const;
00224 void setProperty(Transaction *tx, QString name, QVariant value);
00225 void removeProperty(Transaction *tx, QString name);
00226
00227 Store *getStore(Transaction *tx) const;
00228 QUrl getPropertyUri(QString name) const;
00229
00230 private:
00231 PropertyObject m_po;
00232 typedef std::map<QString, QVariant> StringVariantMap;
00233 mutable StringVariantMap m_cache;
00234 };
00235
00236 }
00237
00238 #endif