blob: 760fc03e811bbc5b10d42707f37c8623ff436679 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// file : build/scope -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
#ifndef BUILD_SCOPE
#define BUILD_SCOPE
#include <map>
#include <build/path>
#include <build/prerequisite>
namespace build
{
class scope
{
public:
typedef build::path path_type;
const path_type&
path () const {return i_->first;} // Absolute and normalized.
private:
friend class scope_map;
typedef std::map<path_type, scope>::const_iterator iterator;
scope () = default;
void
init (const iterator& i) {i_ = i;}
public:
prerequisite_set prerequisites;
private:
iterator i_;
};
class scope_map: std::map<path, scope>
{
public:
scope&
operator[] (const path& k)
{
auto i (emplace (k, scope ()));
auto& r (i.first->second);
if (i.second)
r.init (i.first);
return r;
}
};
extern scope_map scopes;
}
#endif // BUILD_SCOPE
|