| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library barback.transformer.base_transform; | 5 library barback.transformer.base_transform; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import '../asset/asset_id.dart'; | 9 import '../asset/asset_id.dart'; |
| 10 import '../graph/transform_node.dart'; | 10 import '../graph/transform_node.dart'; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 _consumedPrimaries.add(id); | 69 _consumedPrimaries.add(id); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 /// The base class for controllers of subclasses of [BaseTransform]. | 73 /// The base class for controllers of subclasses of [BaseTransform]. |
| 74 /// | 74 /// |
| 75 /// Controllers are used so that [TransformNode]s can get values from a | 75 /// Controllers are used so that [TransformNode]s can get values from a |
| 76 /// [BaseTransform] without exposing getters in the public API. | 76 /// [BaseTransform] without exposing getters in the public API. |
| 77 abstract class BaseTransformController { | 77 abstract class BaseTransformController { |
| 78 /// The [BaseTransform] controlled by this controller. | 78 /// The [BaseTransform] controlled by this controller. |
| 79 final BaseTransform transform; | 79 BaseTransform get transform; |
| 80 | 80 |
| 81 /// The ids of primary inputs that should be consumed. | 81 /// The ids of primary inputs that should be consumed. |
| 82 Set<AssetId> get consumedPrimaries => transform._consumedPrimaries; | 82 Set<AssetId> get consumedPrimaries => transform._consumedPrimaries; |
| 83 | 83 |
| 84 /// Whether the transform logged an error. | 84 /// Whether the transform logged an error. |
| 85 bool get loggedError => transform._loggedError; | 85 bool get loggedError => transform._loggedError; |
| 86 | 86 |
| 87 /// The stream of log entries emitted by the transformer during a run. | 87 /// The stream of log entries emitted by the transformer during a run. |
| 88 Stream<LogEntry> get onLog => transform._onLogController.stream; | 88 Stream<LogEntry> get onLog => transform._onLogController.stream; |
| 89 | 89 |
| 90 /// Whether the transform's input or id stream has been closed. | 90 /// Whether the transform's input or id stream has been closed. |
| 91 /// | 91 /// |
| 92 /// See also [done]. | 92 /// See also [done]. |
| 93 bool get isDone; | 93 bool get isDone; |
| 94 | 94 |
| 95 BaseTransformController(this.transform); | |
| 96 | |
| 97 /// Mark this transform as finished emitting new inputs or input ids. | 95 /// Mark this transform as finished emitting new inputs or input ids. |
| 98 /// | 96 /// |
| 99 /// This is distinct from [cancel] in that it *doesn't* indicate that the | 97 /// This is distinct from [cancel] in that it *doesn't* indicate that the |
| 100 /// transform is finished being used entirely. The transformer may still log | 98 /// transform is finished being used entirely. The transformer may still log |
| 101 /// messages and load secondary inputs. This just indicates that all the | 99 /// messages and load secondary inputs. This just indicates that all the |
| 102 /// primary inputs are accounted for. | 100 /// primary inputs are accounted for. |
| 103 void done(); | 101 void done(); |
| 104 | 102 |
| 105 /// Mark this transform as canceled. | 103 /// Mark this transform as canceled. |
| 106 /// | 104 /// |
| 107 /// This will close any streams and release any resources that were allocated | 105 /// This will close any streams and release any resources that were allocated |
| 108 /// for the duration of the transformation. Unlike [done], this indicates that | 106 /// for the duration of the transformation. Unlike [done], this indicates that |
| 109 /// the transformation is no longer relevant; either it has returned, or | 107 /// the transformation is no longer relevant; either it has returned, or |
| 110 /// something external has preemptively invalidated its results. | 108 /// something external has preemptively invalidated its results. |
| 111 void cancel() { | 109 void cancel() { |
| 112 done(); | 110 done(); |
| 113 transform._onLogController.close(); | 111 transform._onLogController.close(); |
| 114 } | 112 } |
| 115 } | 113 } |
| OLD | NEW |