blob: d6af170a30e54c8383dec07acb078dad01f61135 (
plain) (
blame)
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
namespace search::attribute {
class IAttributeVector;
/**
* Short-lived guard for getting read access to an attribute vector.
*
* Sub-classes must ensure that the appropriate guard(s)
* are held during the lifetime of this object.
*/
class AttributeReadGuard {
private:
const IAttributeVector *_attr;
protected:
AttributeReadGuard(const IAttributeVector *attr);
public:
AttributeReadGuard(const AttributeReadGuard &) = delete;
AttributeReadGuard &operator=(const AttributeReadGuard &) = delete;
AttributeReadGuard(AttributeReadGuard &&) = delete;
AttributeReadGuard &operator=(AttributeReadGuard &&) = delete;
virtual ~AttributeReadGuard();
const IAttributeVector *operator->() const { return _attr; }
const IAttributeVector &operator*() const { return *_attr; }
const IAttributeVector *attribute() const { return _attr; }
};
}
|