00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _DMPROVIDER_SCHEMATAROWIDJOIN_H
00014 #define _DMPROVIDER_SCHEMATAROWIDJOIN_H
00015
00021 #include <dmprovider/SchemaTableNode.h>
00022
00023 #if _SUPPORTS_NAMESPACE
00024 namespace palmos {
00025 namespace dmprovider {
00026 using namespace palmos::storage;
00027 #endif
00028
00033
00034
00035
00037
00054 class BSchemaRowIDJoin : public BMetaDataNode, public BGenericIterable
00055 {
00056 public:
00057
00061
00062
00074 BSchemaRowIDJoin( const SContext& context,
00075 const sptr<BSchemaTableNode>& primary,
00076 const sptr<BSchemaTableNode>& join,
00077 const SString& joinIDCol,
00078 const SString& primaryColumnName = SString());
00079 protected:
00081 virtual ~BSchemaRowIDJoin();
00082 public:
00083
00085 virtual lock_status_t Lock() const;
00087 virtual void Unlock() const;
00089 inline SContext Context() { return BMetaDataNode::Context(); }
00091 virtual SValue Inspect(const sptr<IBinder>& caller, const SValue& which, uint32_t flags);
00093 status_t StatusCheck() const;
00095
00096
00100
00102
00106 virtual void SetMimeType(const SString& value);
00107
00109 SString RowMimeTypeLocked() const;
00110
00112 status_t StoreRowMimeTypeLocked(const SString& mimeType);
00113
00115
00116
00120
00121 class RowNode;
00122
00124 virtual status_t LookupEntry(const SString& entry, uint32_t flags, SValue* node);
00125
00127 sptr<RowNode> NodeForLocked( const sptr<BSchemaTableNode::RowNode>& priNode,
00128 const sptr<BSchemaTableNode::RowNode>& joinNode);
00129
00131
00132
00135
00136 class JoinIterator;
00137
00138 virtual sptr<GenericIterator> NewGenericIterator(const SValue& args);
00139
00141
00143 virtual sptr<RowNode> NewRowNodeLocked( const sptr<BSchemaTableNode::RowNode>& priNode,
00144 const sptr<BSchemaTableNode::RowNode>& joinNode);
00145
00147 private:
00148 BSchemaRowIDJoin(const BSchemaRowIDJoin&);
00149 BSchemaRowIDJoin& operator=(const BSchemaRowIDJoin&);
00150
00151 friend class RowNode;
00152 friend class JoinIterator;
00153
00154 const sptr<BSchemaTableNode> m_primaryTable;
00155 const sptr<BSchemaTableNode> m_joinTable;
00156 const SString m_joinIDColumn;
00157 const SString m_primaryColumnName;
00158
00159 ssize_t m_joinIDIndex;
00160
00161 SString m_rowMimeType;
00162
00163 sptr<BSchemaTableNode::DataAccessor> m_primaryData;
00164 sptr<BSchemaTableNode::DataAccessor> m_joinData;
00165
00166 struct node_key {
00167 sptr<BSchemaTableNode::RowNode> primary;
00168 sptr<BSchemaTableNode::RowNode> join;
00169
00170 bool operator<(const node_key& o) const { return primary < o.primary || join < o.join; }
00171 };
00172
00173 SKeyedVector<node_key, wptr<RowNode> > m_nodes;
00174 };
00175
00176
00177
00179
00186 class BSchemaRowIDJoin::RowNode : public BMetaDataNode, public BIndexedIterable
00187 {
00188 public:
00189
00193 RowNode( const SContext& context,
00194 const sptr<BSchemaRowIDJoin>& owner,
00195 const sptr<BSchemaTableNode::RowNode>& primary,
00196 const sptr<BSchemaTableNode::RowNode>& join);
00197 protected:
00198 virtual ~RowNode();
00200 virtual status_t FinishAtom(const void* id);
00202 virtual bool HoldRefForLink(const SValue& binding, uint32_t flags);
00203 public:
00204
00206 virtual lock_status_t Lock() const;
00208 virtual void Unlock() const;
00210 inline SContext Context() { return BMetaDataNode::Context(); }
00212 virtual SValue Inspect(const sptr<IBinder>& caller, const SValue& which, uint32_t flags);
00213
00215
00216
00220
00222 virtual status_t LookupEntry(const SString& entry, uint32_t flags, SValue* node);
00224 virtual status_t EntryAtLocked(const sptr<IndexedIterator>& it, size_t index, uint32_t flags, SValue* key, SValue* entry);
00226 virtual SString MimeTypeLocked() const;
00228 virtual status_t StoreMimeTypeLocked(const SString& value);
00230 virtual size_t CountEntriesLocked() const;
00231
00233
00234 private:
00235 RowNode(const RowNode&);
00236 RowNode& operator=(const RowNode&);
00237
00238 const sptr<BSchemaRowIDJoin> m_owner;
00239 const sptr<BSchemaTableNode::RowNode> m_primary;
00240 const sptr<BSchemaTableNode::RowNode> m_join;
00241 };
00242
00243
00244
00246
00251 class BSchemaRowIDJoin::JoinIterator : public BGenericIterable::GenericIterator
00252 {
00253 public:
00254
00258 JoinIterator(const SContext& context, const sptr<BSchemaRowIDJoin>& owner);
00259 protected:
00260 virtual ~JoinIterator();
00262 virtual SValue Inspect(const sptr<IBinder>& caller, const SValue& which, uint32_t flags);
00263 public:
00265 virtual status_t FinishAtom(const void* id);
00266
00268
00269 virtual SValue Options() const;
00270 virtual status_t Remove();
00271 virtual size_t Count() const;
00272 virtual size_t Position() const;
00273 virtual void SetPosition(size_t p);
00274
00275 virtual status_t ParseArgs(const SValue& args);
00276
00277 virtual status_t NextLocked(uint32_t flags, SValue* key, SValue* entry);
00278
00279 private:
00280 JoinIterator(const JoinIterator&);
00281 JoinIterator& operator=(const JoinIterator&);
00282
00283 const sptr<BSchemaRowIDJoin> m_owner;
00284 sptr<BSchemaTableNode::DataAccessor> m_primaryData;
00285 sptr<BSchemaTableNode::QueryIterator> m_joinIterator;
00286 SValue m_args;
00287 bool m_includePrimaryNode;
00288 };
00289
00290
00291
00292
00295 #if _SUPPORTS_NAMESPACE
00296 } }
00297 #endif
00298
00299 #endif // _DMPROVIDER_SCHEMATAROWIDJOIN_H