blob: 7b44f03dec4357c1b11cc0c8c8e7b3e23249e4a5 (
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
60
61
62
63
64
65
66
67
68
69
70
71
|
/**
* Copyright (c) 2012 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "pch.h"
#include <boost/unordered_map.hpp>
#include "util/intrusive_counter.h"
namespace mongo {
class DocumentSource;
class DependencyTracker :
public IntrusiveCounterUnsigned {
public:
void addDependency(const string &fieldPath,
const DocumentSource *pSource);
void removeDependency(const string &fieldPath);
bool getDependency(intrusive_ptr<const DocumentSource> *ppSource,
const string &fieldPath) const;
private:
struct Tracker {
Tracker(const string &fieldPath,
const DocumentSource *pSource);
string fieldPath;
intrusive_ptr<const DocumentSource> pSource;
struct Hash :
unary_function<string, size_t> {
size_t operator()(const string &rS) const;
};
};
typedef boost::unordered_map<string, Tracker, Tracker::Hash> MapType;
MapType map;
};
}
/* ======================= PRIVATE IMPLEMENTATIONS ========================== */
namespace mongo {
inline size_t DependencyTracker::Tracker::Hash::operator()(
const string &rS) const {
size_t seed = 0xf0afbeef;
boost::hash_combine(seed, rS);
return seed;
}
}
|