3 * Copyright (c) 2021 Project CHIP Authors
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 * Platform-specific key value storage implementation for Zephyr.
30 namespace DeviceLayer {
31 namespace PersistedStorage {
33 class KeyValueStoreManagerImpl final : public KeyValueStoreManager
35 // Allow the KeyValueStoreManager interface class to delegate method calls to
36 // the implementation methods provided by this class.
37 friend class KeyValueStoreManager;
42 // NOTE: Currently this platform does not support partial and offset reads
43 // these will return CHIP_ERROR_NOT_IMPLEMENTED.
44 CHIP_ERROR _Get(const char * key, void * value, size_t value_size, size_t * read_bytes_size = nullptr, size_t offset = 0) const;
46 CHIP_ERROR _Delete(const char * key);
48 CHIP_ERROR _Put(const char * key, const void * value, size_t value_size);
51 // ===== Members for internal use by the following friends.
53 friend KeyValueStoreManager & KeyValueStoreMgr();
54 friend KeyValueStoreManagerImpl & KeyValueStoreMgrImpl();
56 static KeyValueStoreManagerImpl sInstance;
60 * Returns the public interface of the KeyValueStoreManager singleton object.
62 * Chip applications should use this to access features of the KeyValueStoreManager object
63 * that are common to all platforms.
65 inline KeyValueStoreManager & KeyValueStoreMgr()
67 return KeyValueStoreManagerImpl::sInstance;
71 * Returns the platform-specific implementation of the KeyValueStoreManager singleton object.
73 * Chip applications can use this to gain access to features of the KeyValueStoreManager
74 * that are specific to the Zephyr platform.
76 inline KeyValueStoreManagerImpl & KeyValueStoreMgrImpl()
78 return KeyValueStoreManagerImpl::sInstance;
81 } // namespace PersistedStorage
82 } // namespace DeviceLayer