OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_COMMON_PROPERTY_BAG_H_ | 5 #ifndef CHROME_COMMON_PROPERTY_BAG_H_ |
6 #define CHROME_COMMON_PROPERTY_BAG_H_ | 6 #define CHROME_COMMON_PROPERTY_BAG_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 if (!prop) | 147 if (!prop) |
148 return NULL; | 148 return NULL; |
149 return static_cast<const Container*>(prop)->get(); | 149 return static_cast<const Container*>(prop)->get(); |
150 } | 150 } |
151 | 151 |
152 // See also DeleteProperty on thn PropertyAccessorBase. | 152 // See also DeleteProperty on thn PropertyAccessorBase. |
153 | 153 |
154 private: | 154 private: |
155 class Container : public PropertyBag::Prop { | 155 class Container : public PropertyBag::Prop { |
156 public: | 156 public: |
157 Container(const T& data) : data_(data) {} | 157 explicit Container(const T& data) : data_(data) {} |
158 | 158 |
159 T* get() { return &data_; } | 159 T* get() { return &data_; } |
160 const T* get() const { return &data_; } | 160 const T* get() const { return &data_; } |
161 | 161 |
162 private: | 162 private: |
163 virtual Prop* copy() { | 163 virtual Prop* copy() { |
164 return new Container(data_); | 164 return new Container(data_); |
165 } | 165 } |
166 | 166 |
167 T data_; | 167 T data_; |
168 }; | 168 }; |
169 | 169 |
170 DISALLOW_COPY_AND_ASSIGN(PropertyAccessor); | 170 DISALLOW_COPY_AND_ASSIGN(PropertyAccessor); |
171 }; | 171 }; |
172 | 172 |
173 #endif // CHROME_COMMON_PROPERTY_BAG_H_ | 173 #endif // CHROME_COMMON_PROPERTY_BAG_H_ |
OLD | NEW |