[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / tools / gn / item.h
blob069c3edc55848419f636171ac08215b23eb12e45
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
3 // found in the LICENSE file.
5 #ifndef TOOLS_GN_ITEM_H_
6 #define TOOLS_GN_ITEM_H_
8 #include <string>
10 #include "tools/gn/label.h"
11 #include "tools/gn/visibility.h"
13 class Config;
14 class ParseNode;
15 class Settings;
16 class Target;
17 class Toolchain;
19 // A named item (target, config, etc.) that participates in the dependency
20 // graph.
21 class Item {
22 public:
23 Item(const Settings* settings, const Label& label);
24 virtual ~Item();
26 const Settings* settings() const { return settings_; }
28 // 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 const Label& label() const { return label_; }
32 const ParseNode* defined_from() const { return defined_from_; }
33 void set_defined_from(const ParseNode* df) { defined_from_ = df; }
35 Visibility& visibility() { return visibility_; }
36 const Visibility& visibility() const { return visibility_; }
38 // Manual RTTI.
39 virtual Config* AsConfig();
40 virtual const Config* AsConfig() const;
41 virtual Target* AsTarget();
42 virtual const Target* AsTarget() const;
43 virtual Toolchain* AsToolchain();
44 virtual const Toolchain* AsToolchain() const;
46 // Returns a name like "target" or "config" for the type of item this is, to
47 // be used in logging and error messages.
48 std::string GetItemTypeName() const;
50 // 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
52 // returns false on failure.
53 virtual bool OnResolved(Err* err);
55 private:
56 const Settings* settings_;
57 Label label_;
58 const ParseNode* defined_from_;
60 Visibility visibility_;
63 #endif // TOOLS_GN_ITEM_H_