| 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 #include "tools/gn/visibility.h" | 11 #include "tools/gn/visibility.h" |
| 12 | 12 |
| 13 class Config; | 13 class Config; |
| 14 class ParseNode; | 14 class ParseNode; |
| 15 class Pool; |
| 15 class Settings; | 16 class Settings; |
| 16 class Target; | 17 class Target; |
| 17 class Toolchain; | 18 class Toolchain; |
| 18 | 19 |
| 19 // A named item (target, config, etc.) that participates in the dependency | 20 // A named item (target, config, etc.) that participates in the dependency |
| 20 // graph. | 21 // graph. |
| 21 class Item { | 22 class Item { |
| 22 public: | 23 public: |
| 23 Item(const Settings* settings, const Label& label); | 24 Item(const Settings* settings, const Label& label); |
| 24 virtual ~Item(); | 25 virtual ~Item(); |
| 25 | 26 |
| 26 const Settings* settings() const { return settings_; } | 27 const Settings* settings() const { return settings_; } |
| 27 | 28 |
| 28 // This is guaranteed to never change after construction so this can be | 29 // This is guaranteed to never change after construction so this can be |
| 29 // accessed from any thread with no locking once the item is constructed. | 30 // accessed from any thread with no locking once the item is constructed. |
| 30 const Label& label() const { return label_; } | 31 const Label& label() const { return label_; } |
| 31 | 32 |
| 32 const ParseNode* defined_from() const { return defined_from_; } | 33 const ParseNode* defined_from() const { return defined_from_; } |
| 33 void set_defined_from(const ParseNode* df) { defined_from_ = df; } | 34 void set_defined_from(const ParseNode* df) { defined_from_ = df; } |
| 34 | 35 |
| 35 Visibility& visibility() { return visibility_; } | 36 Visibility& visibility() { return visibility_; } |
| 36 const Visibility& visibility() const { return visibility_; } | 37 const Visibility& visibility() const { return visibility_; } |
| 37 | 38 |
| 38 // Manual RTTI. | 39 // Manual RTTI. |
| 39 virtual Config* AsConfig(); | 40 virtual Config* AsConfig(); |
| 40 virtual const Config* AsConfig() const; | 41 virtual const Config* AsConfig() const; |
| 42 virtual Pool* AsPool(); |
| 43 virtual const Pool* AsPool() const; |
| 41 virtual Target* AsTarget(); | 44 virtual Target* AsTarget(); |
| 42 virtual const Target* AsTarget() const; | 45 virtual const Target* AsTarget() const; |
| 43 virtual Toolchain* AsToolchain(); | 46 virtual Toolchain* AsToolchain(); |
| 44 virtual const Toolchain* AsToolchain() const; | 47 virtual const Toolchain* AsToolchain() const; |
| 45 | 48 |
| 46 // Returns a name like "target" or "config" for the type of item this is, to | 49 // Returns a name like "target" or "config" for the type of item this is, to |
| 47 // be used in logging and error messages. | 50 // be used in logging and error messages. |
| 48 std::string GetItemTypeName() const; | 51 std::string GetItemTypeName() const; |
| 49 | 52 |
| 50 // Called when this item is resolved, meaning it and all of its dependents | 53 // Called when this item is resolved, meaning it and all of its dependents |
| 51 // have no unresolved deps. Returns true on success. Sets the error and | 54 // have no unresolved deps. Returns true on success. Sets the error and |
| 52 // returns false on failure. | 55 // returns false on failure. |
| 53 virtual bool OnResolved(Err* err); | 56 virtual bool OnResolved(Err* err); |
| 54 | 57 |
| 55 private: | 58 private: |
| 56 const Settings* settings_; | 59 const Settings* settings_; |
| 57 Label label_; | 60 Label label_; |
| 58 const ParseNode* defined_from_; | 61 const ParseNode* defined_from_; |
| 59 | 62 |
| 60 Visibility visibility_; | 63 Visibility visibility_; |
| 61 }; | 64 }; |
| 62 | 65 |
| 63 #endif // TOOLS_GN_ITEM_H_ | 66 #endif // TOOLS_GN_ITEM_H_ |
| OLD | NEW |