GenericNode.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 _STORAGE_GENERICNODE_H
00014 #define _STORAGE_GENERICNODE_H
00015 
00021 #include <support/INode.h>
00022 #include <support/Locker.h>
00023 
00024 #if _SUPPORTS_NAMESPACE
00025 namespace palmos {
00026 namespace storage {
00027 using namespace support;
00028 #endif
00029 
00034 class IDatum;
00035 
00036 // ==========================================================================
00037 // ==========================================================================
00038 
00040 
00053 class BGenericNode : public BnNode
00054 {
00055 public:
00056     // --------------------------------------------------------------
00060                                 BGenericNode();
00061                                 BGenericNode(const SContext& context);
00062 protected:
00063     virtual                     ~BGenericNode();
00064 public:
00065 
00067 
00073     virtual lock_status_t       Lock() const;
00074 
00076     virtual void                Unlock() const;
00077 
00079 
00080     // ---------------------------------------------------------------------
00087 
00088     virtual sptr<INode>         Attributes() const;
00090     virtual SString             MimeType() const;
00092     virtual void                SetMimeType(const SString& value);
00094     virtual nsecs_t             CreationDate() const;
00096     virtual void                SetCreationDate(nsecs_t value);
00098     virtual nsecs_t             ModifiedDate() const;
00100     virtual void                SetModifiedDate(nsecs_t value);
00102     virtual status_t            Walk(SString* path, uint32_t flags, SValue* node);
00103 
00105             status_t            SetMimeTypeLocked(const SString& value);
00107             status_t            SetCreationDateLocked(nsecs_t value);
00109             status_t            SetModifiedDateLocked(nsecs_t value);
00111     
00112     // ---------------------------------------------------------------------
00117 
00119 
00121     virtual status_t            LookupEntry(const SString& entry, uint32_t flags, SValue* node) = 0;
00122 
00124 
00125     virtual sptr<INode>         CreateNode(SString* name, status_t* err);
00126 
00128 
00129     virtual sptr<IDatum>        CreateDatum(SString* name, uint32_t flags, status_t* err);
00130 
00132     virtual SString             MimeTypeLocked() const;
00134     virtual status_t            StoreMimeTypeLocked(const SString& value);
00136     virtual nsecs_t             CreationDateLocked() const = 0;
00138     virtual status_t            StoreCreationDateLocked(nsecs_t value);
00140     virtual nsecs_t             ModifiedDateLocked() const = 0;
00142     virtual status_t            StoreModifiedDateLocked(nsecs_t value);
00143 
00145     
00146     // ---------------------------------------------------------------------
00163 
00165 
00167     virtual status_t            LookupMetaEntry(const SString& entry, uint32_t flags, SValue* node);
00168 
00170 
00173     virtual status_t            CreateMetaEntry(const SString& name, const SValue& initialValue, sptr<IDatum>* outDatum = NULL);
00174 
00176 
00178     virtual status_t            RemoveMetaEntry(const SString& name);
00179 
00181 
00183     virtual status_t            RenameMetaEntry(const SString& old_name, const SString& new_name);
00184 
00186 
00191     virtual status_t            MetaEntryAtLocked(ssize_t index, uint32_t flags, SValue* key, SValue* entry);
00192 
00194 
00196     virtual size_t              CountMetaEntriesLocked() const;
00197 
00199 
00200 protected:
00201 
00202 private:
00203             class               node_state;
00204             class               meta_datum;
00205             friend class        node_state;
00206             friend class        meta_datum;
00207 
00208             sptr<node_state>    get_state_l() const;
00209             status_t            get_meta_value_l(ssize_t index, SValue* key, SValue* value);
00210             status_t            datum_changed_l(size_t index, const SValue& newValue);
00211 
00212     mutable SLocker             m_lock;
00213     mutable wptr<node_state>    m_state;
00214 };
00215 
00216 // ==========================================================================
00217 // ==========================================================================
00218 
00221 #if _SUPPORTS_NAMESPACE
00222 } } // namespace palmos::storage
00223 #endif
00224 
00225 #endif // _STORAGE_GENERICNODE_H