blob: ac0872d644fd5ed9cf33602123f6777436f43e3e (
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
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_POLICY_POLICY_MAP_H_
#define CHROME_BROWSER_POLICY_POLICY_MAP_H_
#pragma once
#include <map>
#include "base/values.h"
#include "policy/configuration_policy_type.h"
namespace policy {
struct PolicyDefinitionList;
// Wrapper class around a std::map<ConfigurationPolicyType, Value*> that
// properly cleans up after itself when going out of scope.
// Exposes interesting methods of the underlying std::map.
class PolicyMap {
public:
typedef std::map<ConfigurationPolicyType, Value*> PolicyMapType;
typedef PolicyMapType::const_iterator const_iterator;
PolicyMap();
virtual ~PolicyMap();
// Returns a weak reference to the value currently stored for key |policy|.
// Ownership is retained by PolicyMap; callers should use Value::DeepCopy
// if they need a copy that they own themselves.
// Returns NULL if the map does not contain a value for |policy|.
const Value* Get(ConfigurationPolicyType policy) const;
// Takes ownership of |value|. Overwrites any existing value stored in the
// map for the key |policy|.
void Set(ConfigurationPolicyType policy, Value* value);
void Erase(ConfigurationPolicyType policy);
void Swap(PolicyMap* other);
void CopyFrom(const PolicyMap& other);
// Loads the values in |policies| into this PolicyMap, mapped to their
// corresponding policy type. The policies to load, and their types, are
// listed in |list|.
void LoadFrom(const DictionaryValue* policies,
const PolicyDefinitionList* list);
bool Equals(const PolicyMap& other) const;
bool empty() const;
size_t size() const;
const_iterator begin() const;
const_iterator end() const;
void Clear();
private:
// Helper function for Equals(...).
static bool MapEntryEquals(const PolicyMapType::value_type& a,
const PolicyMapType::value_type& b);
PolicyMapType map_;
DISALLOW_COPY_AND_ASSIGN(PolicyMap);
};
} // namespace policy
#endif // CHROME_BROWSER_POLICY_POLICY_MAP_H_
|