00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _STORAGE_CATALOGDELEGATE_H
00014 #define _STORAGE_CATALOGDELEGATE_H
00015
00022 #include <storage/GenericIterable.h>
00023 #include <storage/NodeDelegate.h>
00024
00025 #include <support/ICatalog.h>
00026 #include <support/Locker.h>
00027
00028 #if _SUPPORTS_NAMESPACE
00029 namespace palmos {
00030 namespace storage {
00031 #endif
00032
00037
00038
00050 class BCatalogDelegate : public BNodeDelegate, public BGenericIterable, public BnCatalog
00051 {
00052 public:
00053
00057 BCatalogDelegate( const SContext& context,
00058 const sptr<IBinder>& base);
00059 protected:
00060 virtual ~BCatalogDelegate();
00061 public:
00062
00064 virtual lock_status_t Lock() const;
00066 virtual void Unlock() const;
00068 inline SContext Context() { return BnNode::Context(); }
00070
00072 virtual SValue Inspect(const sptr<IBinder>& caller, const SValue& which, uint32_t flags);
00073
00075
00076
00080
00081 class IteratorDelegate;
00082
00084 inline sptr<IIterable> BaseIterable() const { return m_baseIterable; }
00085
00086 virtual sptr<GenericIterator> NewGenericIterator(const SValue& args);
00087
00089
00090
00094
00096 inline sptr<ICatalog> BaseCatalog() const { return m_baseCatalog; }
00097
00098 virtual status_t AddEntry(const SString& name, const SValue& entry);
00099 virtual status_t RemoveEntry(const SString& name);
00100 virtual status_t RenameEntry(const SString& entry, const SString& name);
00101
00102 virtual sptr<INode> CreateNode(SString* name, status_t* err);
00103 virtual sptr<IDatum> CreateDatum(SString* name, uint32_t flags, status_t* err);
00104
00106
00107 private:
00108 BCatalogDelegate(const BCatalogDelegate&);
00109 BCatalogDelegate& operator=(const BCatalogDelegate&);
00110
00111 const sptr<IIterable> m_baseIterable;
00112 const sptr<ICatalog> m_baseCatalog;
00113 };
00114
00115
00116
00118
00121 class BCatalogDelegate::IteratorDelegate : public BGenericIterable::GenericIterator
00122 {
00123 public:
00124
00128 IteratorDelegate( const SContext& context,
00129 const sptr<BGenericIterable>& owner);
00130 protected:
00131 virtual ~IteratorDelegate();
00132 public:
00133
00135 virtual SValue Inspect(const sptr<IBinder>& caller, const SValue& which, uint32_t flags);
00137 virtual status_t StatusCheck() const;
00138
00140
00142 virtual SValue Options() const;
00144
00150 virtual status_t Next(IIterator::ValueList* keys, IIterator::ValueList* values, uint32_t flags, size_t count);
00152 virtual status_t Remove();
00153
00155 virtual size_t Count() const;
00157 virtual size_t Position() const;
00159 virtual void SetPosition(size_t p);
00160
00162 virtual status_t ParseArgs(const SValue& args);
00163
00165 virtual status_t NextLocked(uint32_t flags, SValue* key, SValue* entry);
00166
00167 private:
00168 status_t m_baseError;
00169 sptr<IIterator> m_baseIterator;
00170 sptr<IRandomIterator> m_baseRandomIterator;
00171 };
00172
00173
00174
00175
00178 #if _SUPPORTS_NAMESPACE
00179 } }
00180 #endif
00181
00182 #endif // _STORAGE_CATALOGDELEGATE_H
00183