| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 TOOLS_GN_ITEM_H_ | 5 #ifndef TOOLS_GN_ITEM_H_ |
| 6 #define TOOLS_GN_ITEM_H_ | 6 #define TOOLS_GN_ITEM_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "tools/gn/label.h" | 10 #include "tools/gn/label.h" |
| 11 | 11 |
| 12 class Config; | 12 class Config; |
| 13 class ItemNode; | 13 class ItemNode; |
| 14 class Settings; | |
| 15 class Target; | 14 class Target; |
| 16 class Toolchain; | 15 class Toolchain; |
| 17 | 16 |
| 18 // A named item (target, config, etc.) that participates in the dependency | 17 // A named item (target, config, etc.) that participates in the dependency |
| 19 // graph. | 18 // graph. |
| 20 class Item { | 19 class Item { |
| 21 public: | 20 public: |
| 22 Item(const Settings* settings, const Label& label); | 21 Item(const Label& label); |
| 23 virtual ~Item(); | 22 virtual ~Item(); |
| 24 | 23 |
| 25 const Settings* settings() const { return settings_; } | |
| 26 | |
| 27 // This is guaranteed to never change after construction so this can be | 24 // This is guaranteed to never change after construction so this can be |
| 28 // accessed from any thread with no locking once the item is constructed. | 25 // accessed from any thread with no locking once the item is constructed. |
| 29 const Label& label() const { return label_; } | 26 const Label& label() const { return label_; } |
| 30 | 27 |
| 31 // The Item and the ItemNode make a pair. This will be set when the ItemNode | 28 // The Item and the ItemNode make a pair. This will be set when the ItemNode |
| 32 // is constructed that owns this Item. The ItemNode should only be | 29 // is constructed that owns this Item. The ItemNode should only be |
| 33 // dereferenced with the ItemTree lock held. | 30 // dereferenced with the ItemTree lock held. |
| 34 ItemNode* item_node() { return item_node_; } | 31 ItemNode* item_node() { return item_node_; } |
| 35 const ItemNode* item_node() const { return item_node_; } | 32 const ItemNode* item_node() const { return item_node_; } |
| 36 void set_item_node(ItemNode* in) { item_node_ = in; } | 33 void set_item_node(ItemNode* in) { item_node_ = in; } |
| 37 | 34 |
| 38 // Manual RTTI. | 35 // Manual RTTI. |
| 39 virtual Config* AsConfig(); | 36 virtual Config* AsConfig(); |
| 40 virtual const Config* AsConfig() const; | 37 virtual const Config* AsConfig() const; |
| 41 virtual Target* AsTarget(); | 38 virtual Target* AsTarget(); |
| 42 virtual const Target* AsTarget() const; | 39 virtual const Target* AsTarget() const; |
| 43 virtual Toolchain* AsToolchain(); | 40 virtual Toolchain* AsToolchain(); |
| 44 virtual const Toolchain* AsToolchain() const; | 41 virtual const Toolchain* AsToolchain() const; |
| 45 | 42 |
| 46 // Returns a name like "target" or "config" for the type of item this is, to | 43 // Returns a name like "target" or "config" for the type of item this is, to |
| 47 // be used in logging and error messages. | 44 // be used in logging and error messages. |
| 48 std::string GetItemTypeName() const; | 45 std::string GetItemTypeName() const; |
| 49 | 46 |
| 50 // Called when this item is resolved, meaning it and all of its dependents | 47 // Called when this item is resolved, meaning it and all of its dependents |
| 51 // have no unresolved deps. | 48 // have no unresolved deps. |
| 52 virtual void OnResolved() {} | 49 virtual void OnResolved() {} |
| 53 | 50 |
| 54 private: | 51 private: |
| 55 const Settings* settings_; | |
| 56 Label label_; | 52 Label label_; |
| 57 | 53 |
| 58 ItemNode* item_node_; | 54 ItemNode* item_node_; |
| 59 }; | 55 }; |
| 60 | 56 |
| 61 #endif // TOOLS_GN_ITEM_H_ | 57 #endif // TOOLS_GN_ITEM_H_ |
| OLD | NEW |