OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ |
7 | 7 |
8 #include <ostream> | |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 namespace media_router { | 11 namespace media_router { |
11 | 12 |
13 using MediaSourceId = std::string; | |
Kevin Marshall
2015/04/01 17:00:19
Any thoughts about making this a child type of Med
imcheng
2015/04/01 18:10:09
I think this is fine for now. We should also keep
| |
14 | |
12 class MediaSource { | 15 class MediaSource { |
13 public: | 16 public: |
14 explicit MediaSource(const std::string& id); | 17 explicit MediaSource(const MediaSourceId& id); |
18 MediaSource(); | |
15 ~MediaSource(); | 19 ~MediaSource(); |
16 | 20 |
17 // Gets the ID of the media source. | 21 // Gets the ID of the media source. |
18 std::string id() const; | 22 MediaSourceId id() const; |
23 | |
24 // Returns true if two MediaSource objects use the same media ID. | |
25 bool Equals(const MediaSource& other) const; | |
26 | |
27 // Returns true if a MediaSource is empty or uninitialized. | |
28 bool Empty() const; | |
29 | |
30 // Stream output, used for logging. | |
31 friend std::ostream& operator<<(std::ostream& output, | |
32 const MediaSource& source); | |
19 | 33 |
20 private: | 34 private: |
21 std::string id_; | 35 MediaSourceId id_; |
36 }; | |
37 | |
38 // Inequality comparison functor to provide map lookup capabilities for | |
39 // MediaSource. | |
40 class MediaSourceLess { | |
41 public: | |
42 bool operator()(const MediaSource& lhs, const MediaSource& rhs) const { | |
43 return lhs.id() < rhs.id(); | |
44 } | |
22 }; | 45 }; |
23 | 46 |
24 } // namespace media_router | 47 } // namespace media_router |
25 | 48 |
26 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ | 49 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ |
OLD | NEW |