OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_BASE_MODELS_TREE_NODE_MODEL_H_ | 5 #ifndef UI_BASE_MODELS_TREE_NODE_MODEL_H_ |
6 #define UI_BASE_MODELS_TREE_NODE_MODEL_H_ | 6 #define UI_BASE_MODELS_TREE_NODE_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 20 matching lines...) Expand all Loading... |
31 // yourself any time you make any change directly to the TreeNodes. For example, | 31 // yourself any time you make any change directly to the TreeNodes. For example, |
32 // if you directly invoke set_title on a node it does not notify the observer, | 32 // if you directly invoke set_title on a node it does not notify the observer, |
33 // you will need to do it yourself. This includes the following methods: Add, | 33 // you will need to do it yourself. This includes the following methods: Add, |
34 // Remove and set_title. TreeNodeModel provides cover methods that mutate the | 34 // Remove and set_title. TreeNodeModel provides cover methods that mutate the |
35 // TreeNodes and notify the observer. If you are using TreeNodes with a | 35 // TreeNodes and notify the observer. If you are using TreeNodes with a |
36 // TreeNodeModel use the cover methods to save yourself the headache. | 36 // TreeNodeModel use the cover methods to save yourself the headache. |
37 // | 37 // |
38 // The following example creates a TreeNode with two children and then | 38 // The following example creates a TreeNode with two children and then |
39 // creates a TreeNodeModel from it: | 39 // creates a TreeNodeModel from it: |
40 // | 40 // |
41 // TreeNodeWithValue<int> root; | 41 // TreeNodeWithValue<int>* root = new TreeNodeWithValue<int>(); |
42 // root.Add(new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 0)); | 42 // root->Add(new TreeNodeWithValue<int>(ASCIIToUTF16("child 1"), 0)); |
43 // root.Add(new TreeNodeWithValue<int>(ASCIIToUTF16("child 2"), 1)); | 43 // root->Add(new TreeNodeWithValue<int>(ASCIIToUTF16("child 2"), 1)); |
44 // TreeNodeModel<TreeNodeWithValue<int> > model(&root); | 44 // TreeNodeModel<TreeNodeWithValue<int> > model(root); |
45 // | 45 // |
46 // Two variants of TreeNode are provided here: | 46 // Two variants of TreeNode are provided here: |
47 // | 47 // |
48 // . TreeNode itself is intended for subclassing. It has one type parameter | 48 // . TreeNode itself is intended for subclassing. It has one type parameter |
49 // that corresponds to the type of the node. When subclassing use your class | 49 // that corresponds to the type of the node. When subclassing use your class |
50 // name as the type parameter, eg: | 50 // name as the type parameter, eg: |
51 // class MyTreeNode : public TreeNode<MyTreeNode> . | 51 // class MyTreeNode : public TreeNode<MyTreeNode> . |
52 // . TreeNodeWithValue is a trivial subclass of TreeNode that has one type | 52 // . TreeNodeWithValue is a trivial subclass of TreeNode that has one type |
53 // type parameter: a value type that is associated with the node. | 53 // type parameter: a value type that is associated with the node. |
54 // | 54 // |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 289 |
290 // The root. | 290 // The root. |
291 scoped_ptr<NodeType> root_; | 291 scoped_ptr<NodeType> root_; |
292 | 292 |
293 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel); | 293 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel); |
294 }; | 294 }; |
295 | 295 |
296 } // namespace ui | 296 } // namespace ui |
297 | 297 |
298 #endif // UI_BASE_MODELS_TREE_NODE_MODEL_H_ | 298 #endif // UI_BASE_MODELS_TREE_NODE_MODEL_H_ |
OLD | NEW |