Line data Source code
1 : /*
2 : * Copyright (c) 2021-2025 Project CHIP Authors
3 : *
4 : * Licensed under the Apache License, Version 2.0 (the "License");
5 : * you may not use this file except in compliance with the License.
6 : * You may obtain a copy of the License at
7 : *
8 : * http://www.apache.org/licenses/LICENSE-2.0
9 : *
10 : * Unless required by applicable law or agreed to in writing, software
11 : * distributed under the License is distributed on an "AS IS" BASIS,
12 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 : * See the License for the specific language governing permissions and
14 : * limitations under the License.
15 : */
16 : #pragma once
17 :
18 : #include <app/ConcreteAttributePath.h>
19 : #include <lib/support/Span.h>
20 :
21 : namespace chip {
22 : namespace app {
23 :
24 : /**
25 : * Interface for persisting attribute values.
26 : *
27 : * COMPATIBILITY NOTE:
28 : * - This generally is assumed to write under a different key space from
29 : * SafeAttributePersistenceProvider.
30 : */
31 : class AttributePersistenceProvider
32 : {
33 : public:
34 79 : virtual ~AttributePersistenceProvider() = default;
35 : AttributePersistenceProvider() = default;
36 :
37 : /**
38 : * Write an attribute value from the attribute store (i.e. not a struct or
39 : * list) to non-volatile memory.
40 : *
41 : * @param [in] aPath the attribute path for the data being written.
42 : * @param [in] aValue the data to write.
43 : */
44 : virtual CHIP_ERROR WriteValue(const ConcreteAttributePath & aPath, const ByteSpan & aValue) = 0;
45 :
46 : /**
47 : * Read an attribute value from non-volatile memory.
48 : *
49 : * @param [in] aPath the attribute path for the data being persisted.
50 : * @param [in,out] aValue where to place the data.
51 : */
52 : virtual CHIP_ERROR ReadValue(const ConcreteAttributePath & aPath, MutableByteSpan & aValue) = 0;
53 : };
54 :
55 : } // namespace app
56 : } // namespace chip
|