| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.asset_node; | 5 library barback.asset_node; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'asset.dart'; | 9 import 'asset.dart'; |
| 10 import 'asset_graph.dart'; | |
| 11 import 'asset_id.dart'; | 10 import 'asset_id.dart'; |
| 12 import 'phase.dart'; | 11 import 'phase.dart'; |
| 13 import 'transform_node.dart'; | 12 import 'transform_node.dart'; |
| 14 | 13 |
| 15 /// Describes an asset and its relationship to the build dependency graph. | 14 /// Describes an asset and its relationship to the build dependency graph. |
| 16 /// | 15 /// |
| 17 /// Keeps a cache of the last asset that was built for this node (i.e. for this | 16 /// Keeps a cache of the last asset that was built for this node (i.e. for this |
| 18 /// node's ID and phase) and tracks which transforms depend on it. | 17 /// node's ID and phase) and tracks which transforms depend on it. |
| 19 class AssetNode { | 18 class AssetNode { |
| 20 Asset asset; | 19 Asset asset; |
| 21 | 20 |
| 22 /// The [TransformNode]s that consume this node's asset as an input. | 21 /// The [TransformNode]s that consume this node's asset as an input. |
| 23 final consumers = new Set<TransformNode>(); | 22 final consumers = new Set<TransformNode>(); |
| 24 | 23 |
| 25 AssetId get id => asset.id; | 24 AssetId get id => asset.id; |
| 26 | 25 |
| 27 AssetNode(this.asset); | 26 AssetNode(this.asset); |
| 28 | 27 |
| 29 /// Updates this node's generated asset value and marks all transforms that | 28 /// Updates this node's generated asset value and marks all transforms that |
| 30 /// use this as dirty. | 29 /// use this as dirty. |
| 31 void updateAsset(Asset asset) { | 30 void updateAsset(Asset asset) { |
| 32 // Cannot update an asset to one with a different ID. | 31 // Cannot update an asset to one with a different ID. |
| 33 assert(id == asset.id); | 32 assert(id == asset.id); |
| 34 | 33 |
| 35 this.asset = asset; | 34 this.asset = asset; |
| 36 consumers.forEach((consumer) => consumer.dirty()); | 35 consumers.forEach((consumer) => consumer.dirty()); |
| 37 } | 36 } |
| 38 } | 37 } |
| OLD | NEW |