blob: 4910172e01ff76c47a18c4d970f2f116f0b26d72 [file]
/*
* Copyright (c) 2025 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This file contains common storage structures for FabricTableImpl
*/
#pragma once
#include <lib/support/TypeTraits.h>
namespace chip {
namespace app {
namespace Storage {
namespace Data {
// Storage index for entries in nvm
typedef uint16_t EntryIndex;
inline constexpr EntryIndex kUndefinedEntryIndex = 0xffff;
/// @brief Struct combining both ID and data of a table entry
template <class StorageId, class StorageData>
struct TableEntry
{
// ID
StorageId mStorageId;
// DATA
StorageData mStorageData;
TableEntry() = default;
TableEntry(StorageId id) : mStorageId(id) {}
TableEntry(const StorageId id, const StorageData data) : mStorageId(id), mStorageData(data) {}
bool operator==(const TableEntry & other) const
{
return (mStorageId == other.mStorageId && mStorageData == other.mStorageData);
}
void operator=(const TableEntry & other)
{
mStorageId = other.mStorageId;
mStorageData = other.mStorageData;
}
};
} // namespace Data
} // namespace Storage
} // namespace app
} // namespace chip