OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // locks. | 88 // locks. |
89 template<typename T> | 89 template<typename T> |
90 static const T& default_value() { | 90 static const T& default_value() { |
91 RTC_DEFINE_STATIC_LOCAL(const T, def, ()); | 91 RTC_DEFINE_STATIC_LOCAL(const T, def, ()); |
92 return def; | 92 return def; |
93 } | 93 } |
94 | 94 |
95 typedef std::map<OptionIdentifier, BaseOption*> OptionMap; | 95 typedef std::map<OptionIdentifier, BaseOption*> OptionMap; |
96 OptionMap options_; | 96 OptionMap options_; |
97 | 97 |
98 // DISALLOW_COPY_AND_ASSIGN | 98 // RTC_DISALLOW_COPY_AND_ASSIGN |
99 Config(const Config&); | 99 Config(const Config&); |
100 void operator=(const Config&); | 100 void operator=(const Config&); |
101 }; | 101 }; |
102 | 102 |
103 template<typename T> | 103 template<typename T> |
104 const T& Config::Get() const { | 104 const T& Config::Get() const { |
105 OptionMap::const_iterator it = options_.find(identifier<T>()); | 105 OptionMap::const_iterator it = options_.find(identifier<T>()); |
106 if (it != options_.end()) { | 106 if (it != options_.end()) { |
107 const T* t = static_cast<Option<T>*>(it->second)->value; | 107 const T* t = static_cast<Option<T>*>(it->second)->value; |
108 if (t) { | 108 if (t) { |
109 return *t; | 109 return *t; |
110 } | 110 } |
111 } | 111 } |
112 return default_value<T>(); | 112 return default_value<T>(); |
113 } | 113 } |
114 | 114 |
115 template<typename T> | 115 template<typename T> |
116 void Config::Set(T* value) { | 116 void Config::Set(T* value) { |
117 BaseOption*& it = options_[identifier<T>()]; | 117 BaseOption*& it = options_[identifier<T>()]; |
118 delete it; | 118 delete it; |
119 it = new Option<T>(value); | 119 it = new Option<T>(value); |
120 } | 120 } |
121 | 121 |
122 } // namespace webrtc | 122 } // namespace webrtc |
123 | 123 |
124 #endif // WEBRTC_COMMON_H_ | 124 #endif // WEBRTC_COMMON_H_ |
OLD | NEW |