OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SERVICES_MEDIA_FRAMEWORK_REFS_H_ | |
6 #define SERVICES_MEDIA_FRAMEWORK_REFS_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 namespace mojo { | |
11 namespace media { | |
12 | |
13 class Graph; | |
14 class Stage; | |
15 class Input; | |
16 class Output; | |
17 class Engine; | |
18 class InputRef; | |
19 class OutputRef; | |
20 | |
21 // Opaque Stage pointer used for graph building. | |
22 class PartRef { | |
23 public: | |
24 PartRef() : stage_(nullptr) {} | |
25 | |
26 size_t input_count() const; | |
27 InputRef input(size_t index) const; | |
28 InputRef input() const; | |
29 size_t output_count() const; | |
30 OutputRef output(size_t index) const; | |
31 OutputRef output() const; | |
32 | |
33 private: | |
34 explicit PartRef(Stage* stage) : stage_(stage) {} | |
35 | |
36 explicit operator bool() const { return stage_ != nullptr; } | |
37 | |
38 bool valid() const { return stage_ != nullptr; } | |
johngro
2016/02/08 22:33:36
why make valid() (and its operator bool form) priv
dalesat
2016/02/09 00:34:11
The operator should be public...did that.
I don't
| |
39 | |
40 Stage* stage_; | |
41 | |
42 friend Graph; | |
43 friend InputRef; | |
44 friend OutputRef; | |
45 friend Engine; | |
46 }; | |
47 | |
48 // Opaque Input pointer used for graph building. | |
49 class InputRef { | |
50 public: | |
51 InputRef() : stage_(nullptr), index_(0) {} | |
52 | |
53 InputRef& operator=(std::nullptr_t) { | |
54 stage_ = nullptr; | |
55 index_ = 0; | |
56 return *this; | |
57 } | |
58 | |
59 explicit operator bool() const { return stage_ != nullptr; } | |
johngro
2016/02/08 22:33:36
Note; everything here applies to OutputRef as well
dalesat
2016/02/09 00:34:11
The operator is essentially a null check while val
| |
60 | |
61 PartRef part() const { return PartRef(stage_); } | |
62 | |
63 bool connected() const; | |
64 | |
65 const OutputRef& mate() const; | |
66 | |
67 private: | |
68 InputRef(Stage* stage, size_t index); | |
69 | |
70 Input& actual() const; | |
71 | |
72 bool valid() const; | |
73 | |
74 Stage* stage_; | |
75 size_t index_; | |
76 | |
77 friend Graph; | |
78 friend PartRef; | |
79 friend OutputRef; | |
80 friend Output; | |
81 friend Engine; | |
82 }; | |
83 | |
84 // Opaque Output pointer used for graph building. | |
85 class OutputRef { | |
86 public: | |
87 OutputRef() : stage_(nullptr), index_(0) {} | |
88 | |
89 OutputRef& operator=(std::nullptr_t) { | |
90 stage_ = nullptr; | |
91 index_ = 0; | |
92 return *this; | |
93 } | |
94 | |
95 explicit operator bool() const { return stage_ != nullptr; } | |
96 | |
97 PartRef part() const { return PartRef(stage_); } | |
98 | |
99 bool connected() const; | |
100 | |
101 const InputRef& mate() const; | |
102 | |
103 private: | |
104 OutputRef(Stage* stage, size_t index); | |
105 | |
106 Output& actual() const; | |
107 | |
108 bool valid() const; | |
109 | |
110 Stage* stage_; | |
111 size_t index_; | |
112 | |
113 friend Graph; | |
114 friend PartRef; | |
115 friend InputRef; | |
116 friend Input; | |
117 friend Engine; | |
118 }; | |
119 | |
120 } // namespace media | |
121 } // namespace mojo | |
122 | |
123 #endif // SERVICES_MEDIA_FRAMEWORK_REFS_H_ | |
OLD | NEW |