Line data Source code
1 : /*
2 : * Copyright (c) 2025 Project CHIP Authors
3 : * All rights reserved.
4 : *
5 : * Licensed under the Apache License, Version 2.0 (the "License");
6 : * you may not use this file except in compliance with the License.
7 : * You may obtain a copy of the License at
8 : *
9 : * http://www.apache.org/licenses/LICENSE-2.0
10 : *
11 : * Unless required by applicable law or agreed to in writing, software
12 : * distributed under the License is distributed on an "AS IS" BASIS,
13 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 : * See the License for the specific language governing permissions and
15 : * limitations under the License.
16 : */
17 : #pragma once
18 :
19 : #include <app/data-model-provider/Context.h>
20 : #include <app/data-model-provider/Provider.h>
21 : #include <lib/core/CHIPPersistentStorageDelegate.h>
22 :
23 : namespace chip {
24 : namespace app {
25 :
26 : /// Represents a runtime context for server cluster interfaces to interact
27 : /// with the outside world such as:
28 : /// - notify of state changes to trigger attribute reports
29 : /// - emit events
30 : /// - potentially interact/review global metadata
31 : ///
32 : /// The context object is quite large in terms of exposed functionality and not all clusters use
33 : /// all the information within, however a common context is used to minimize RAM overhead
34 : /// for every cluster maintaining such a context.
35 : struct ServerClusterContext
36 : {
37 : DataModel::Provider * const provider = nullptr; /// underlying provider that the cluster operates in
38 : PersistentStorageDelegate * const storage = nullptr; /// read/write persistent storage
39 : DataModel::InteractionModelContext * const interactionContext = nullptr; /// outside-world communication
40 :
41 227 : bool operator!=(const ServerClusterContext & other) const
42 : {
43 227 : return (provider != other.provider) //
44 226 : || (interactionContext != other.interactionContext) //
45 453 : || (storage != other.storage);
46 : }
47 : };
48 :
49 : } // namespace app
50 : } // namespace chip
|