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