SchemaDatabaseNode.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 Palmsource, Inc.
00003  * 
00004  * This software is licensed as described in the file LICENSE, which
00005  * you should have received as part of this distribution. The terms
00006  * are also available at http://www.openbinder.org/license.html.
00007  * 
00008  * This software consists of voluntary contributions made by many
00009  * individuals. For the exact contribution history, see the revision
00010  * history and logs, available at http://www.openbinder.org
00011  */
00012 
00013 #ifndef _DMPROVIDER_SCHEMADATABASENODE_H
00014 #define _DMPROVIDER_SCHEMADATABASENODE_H
00015 
00022 #include <dmprovider/SchemaTableNode.h>
00023 
00024 #if _SUPPORTS_NAMESPACE
00025 namespace palmos {
00026 namespace dmprovider {
00027 using namespace palmos::storage;
00028 #endif
00029 
00043 // ==========================================================================
00044 // ==========================================================================
00045 
00047 
00063 class BSchemaDatabaseNode : public BIndexedDataNode, public BnReferable
00064 {
00065 public:
00066     // --------------------------------------------------------------
00070 
00071     typedef void (*database_missing_func)(const sptr<BSchemaDatabaseNode> &table);
00072 
00073                                     BSchemaDatabaseNode(const SContext& context,
00074                                                         const SString& dbname,
00075                                                         uint32_t creator,
00076                                                         DmOpenModeType mode = dmModeReadOnly,
00077                                                         DbShareModeType share = dbShareReadWrite,
00078                                                         database_missing_func missing = NULL,
00079                                                         const SValue& args = B_UNDEFINED_VALUE); 
00080                                     BSchemaDatabaseNode(const SContext& context,
00081                                                         const SDatabase &database,
00082                                                         const SValue& args = B_UNDEFINED_VALUE);
00083 protected:
00084     virtual                         ~BSchemaDatabaseNode();
00086     virtual void                    InitAtom();
00087 public:
00089     inline  SContext                Context() { return BIndexedDataNode::Context(); }
00091     virtual SValue                  Inspect(const sptr<IBinder>& caller, const SValue& which, uint32_t flags);
00093             status_t                StatusCheck();
00094 
00096 
00097     // --------------------------------------------------------------
00101 
00103     virtual size_t                  CountEntriesLocked() const;
00105     virtual ssize_t                 EntryIndexOfLocked(const SString& entry) const;
00107     virtual SString                 EntryNameAtLocked(size_t index) const;
00109     virtual SValue                  ValueAtLocked(size_t index) const;
00111     virtual status_t                StoreValueAtLocked(size_t index, const SValue& value);
00112 
00114             sptr<BSchemaTableNode>  TableAtLocked(size_t index) const;
00116             sptr<BSchemaTableNode>  TableForLocked(const SString& name) const;
00117 
00119             SDatabase               DatabaseLocked() const;
00120 
00122 
00125     virtual sptr<BSchemaTableNode>  NewSchemaTableNodeLocked(const SString& table, const SString& refPath);
00126 
00128 
00129     // --------------------------------------------------------------
00132 
00133     virtual SString                 Reference() const;
00134 
00136 
00137 private:
00138                                     BSchemaDatabaseNode(const BSchemaDatabaseNode&);
00139             BSchemaDatabaseNode&    operator=(const BSchemaDatabaseNode&);
00140 
00141             void                    open_database();
00142             void                    retrieve_tables();
00143 
00144     const   SString                 m_dbname;
00145     const   uint32_t                m_creator;
00146     const   DmOpenModeType          m_mode;
00147     const   DbShareModeType         m_share;
00148     const   database_missing_func   m_dbMissing;
00149     const   SString                 m_refPath;
00150 
00151 
00152             status_t                m_status;
00153             SDatabase               m_database;
00154 
00155             SVector<sptr<BSchemaTableNode> >    m_tables;
00156             SKeyedVector<SString, ssize_t>      m_tableNameToIndex;
00157 };
00158 
00159 // ==========================================================================
00160 // ==========================================================================
00161 
00164 #if _SUPPORTS_NAMESPACE
00165 } } // namespace palmos::dmprovider
00166 #endif
00167 
00168 #endif // _DMPROVIDER_SCHEMADATABASENODE_H