Node.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 _SUPPORT_NODE_H
00014 #define _SUPPORT_NODE_H
00015 
00021 #include <support/Binder.h>
00022 #include <support/ICatalog.h>
00023 #include <support/INode.h>
00024 #include <support/INodeObserver.h>
00025 
00026 #if _SUPPORTS_NAMESPACE
00027 namespace palmos {
00028 namespace support {
00029 #endif
00030 
00035 B_CONST_STRING_VALUE_LARGE(BV_ENTRY_CREATED,        "EntryCreated", );
00036 B_CONST_STRING_VALUE_LARGE(BV_ENTRY_MODIFIED,       "EntryModified", );
00037 B_CONST_STRING_VALUE_LARGE(BV_ENTRY_REMOVED,        "EntryRemoved", );
00038 B_CONST_STRING_VALUE_LARGE(BV_ENTRY_RENAMED,        "EntryRenamed", );
00039 
00041 
00068 class SNode
00069 {
00070 public:
00071     // --------------------------------------------------------------
00075 
00076                         SNode();
00078 
00079                         SNode(const SContext& context, const SString& path, uint32_t node_flags=0);
00081 
00085                         SNode(const SValue& value);
00087                         SNode(const sptr<IBinder>& binder);
00089                         SNode(const sptr<INode>& node);
00091                         SNode(const SNode& node);
00093                         ~SNode();
00094 
00096     SNode&              operator=(const SNode& o);
00097 
00098     bool                operator<(const SNode& o) const;
00099     bool                operator<=(const SNode& o) const;
00100     bool                operator==(const SNode& o) const;
00101     bool                operator!=(const SNode& o) const;
00102     bool                operator>=(const SNode& o) const;
00103     bool                operator>(const SNode& o) const;
00104 
00106     status_t            StatusCheck() const;
00107 
00109     sptr<INode>         Node() const;
00110 
00112     SValue              CollapsedNode() const;
00113 
00115     status_t            ErrorCheck() const;
00116 
00118 
00119     // --------------------------------------------------------------
00126 
00127     SValue              Walk(const SString& path, uint32_t flags = INode::REQUEST_DATA) const;
00128     SValue              Walk(SString* path, uint32_t flags = INode::REQUEST_DATA) const;
00129     SValue              Walk(const SString& path, status_t* outErr, uint32_t flags = INode::REQUEST_DATA) const;
00130     SValue              Walk(SString* path, status_t* outErr, uint32_t flags = INode::REQUEST_DATA) const;
00131 
00133 
00134     // --------------------------------------------------------------
00139 
00140     status_t            AddEntry(const SString& name, const SValue& entry) const;
00141     status_t            RemoveEntry(const SString& name) const;
00142     status_t            RenameEntry(const SString& entry, const SString& name) const;
00143     
00145 
00146 private:
00147     void                get_catalog() const;
00148 
00149     SValue              m_value;
00150     sptr<INode>         m_node;
00151     mutable sptr<ICatalog> m_catalog;   // todo: remove?
00152 };
00153 
00154 class BNodeObserver : public BnNodeObserver
00155 {
00156 public:
00157     BNodeObserver();
00158     BNodeObserver(const SContext& context); 
00159 
00160     virtual ~BNodeObserver();
00161 
00162     virtual void NodeChanged(const sptr<INode>& node, uint32_t flags, const SValue& hints);
00163     virtual void EntryCreated(const sptr<INode>& node, const SString& name, const sptr<IBinder>& entry);
00164     virtual void EntryModified(const sptr<INode>& node, const SString& name, const sptr<IBinder>& entry);
00165     virtual void EntryRemoved(const sptr<INode>& node, const SString& name);
00166     virtual void EntryRenamed(const sptr<INode>& node, const SString& old_name, const SString& new_name, const sptr<IBinder>& entry);
00167 };
00168 
00171 #if _SUPPORTS_NAMESPACE
00172 } } // namespace palmos::support
00173 #endif
00174 
00175 #endif // _SUPPORT_NODE_H