diff options
author | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-26 22:29:20 +0000 |
---|---|---|
committer | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-26 22:29:20 +0000 |
commit | b3c33d463366d2725ec4d669b98dc468a751c541 (patch) | |
tree | d8496a8ae8fc73ed71b93d67c055e9f1bba4fcc7 /app/tree_node_model.h | |
parent | 7b91dfd0bce7b4f864d9654e8bd0a9f93683cec0 (diff) | |
download | chromium_src-b3c33d463366d2725ec4d669b98dc468a751c541.zip chromium_src-b3c33d463366d2725ec4d669b98dc468a751c541.tar.gz chromium_src-b3c33d463366d2725ec4d669b98dc468a751c541.tar.bz2 |
Make bookmark model public interface use const BookmarkNode* instead of
BookmarkNode*. This helps in making the BookmarkNode class setters public
also without worrying about someone inadvertently changing BookmarkNode
properties directly for bookmark model bookmarks.
Change all the call sites to reflect this.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/146116
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19428 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/tree_node_model.h')
-rw-r--r-- | app/tree_node_model.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/app/tree_node_model.h b/app/tree_node_model.h index 7767d49..7d96438 100644 --- a/app/tree_node_model.h +++ b/app/tree_node_model.h @@ -100,7 +100,7 @@ class TreeNode : public TreeModelNode { } // Returns the number of children. - int GetChildCount() { + int GetChildCount() const { return static_cast<int>(children_->size()); } @@ -109,16 +109,23 @@ class TreeNode : public TreeModelNode { DCHECK(index >= 0 && index < GetChildCount()); return children_[index]; } + const NodeType* GetChild(int index) const { + DCHECK(index >= 0 && index < GetChildCount()); + return children_[index]; + } // Returns the parent. NodeType* GetParent() { return parent_; } + const NodeType* GetParent() const { + return parent_; + } // Returns the index of the specified child, or -1 if node is a not a child. - int IndexOfChild(const NodeType* node) { + int IndexOfChild(const NodeType* node) const { DCHECK(node); - typename std::vector<NodeType*>::iterator i = + typename std::vector<NodeType*>::const_iterator i = std::find(children_->begin(), children_->end(), node); if (i != children_->end()) return static_cast<int>(i - children_->begin()); @@ -136,11 +143,11 @@ class TreeNode : public TreeModelNode { } // Returns true if this is the root. - bool IsRoot() { return (parent_ == NULL); } + bool IsRoot() const { return (parent_ == NULL); } // Returns true if this == ancestor, or one of this nodes parents is // ancestor. - bool HasAncestor(NodeType* ancestor) const { + bool HasAncestor(const NodeType* ancestor) const { if (ancestor == this) return true; if (!ancestor) |