Line data Source code
1 : /*
2 : * Copyright (c) 2021-2024 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/AttributeAccessInterface.h>
19 : #include <app/CommandHandlerInterface.h>
20 : #include <app/util/af-types.h>
21 :
22 : namespace chip {
23 : namespace app {
24 : namespace Compatibility {
25 :
26 : // This reader should never actually be registered; we do manual dispatch to it
27 : // for the one attribute it handles.
28 : class MandatoryGlobalAttributeReader : public AttributeAccessInterface
29 : {
30 : public:
31 716 : MandatoryGlobalAttributeReader(const EmberAfCluster * aCluster) :
32 716 : AttributeAccessInterface(MakeOptional(kInvalidEndpointId), kInvalidClusterId), mCluster(aCluster)
33 716 : {}
34 :
35 : protected:
36 : const EmberAfCluster * mCluster;
37 : };
38 :
39 : class GlobalAttributeReader : public MandatoryGlobalAttributeReader
40 : {
41 : public:
42 716 : GlobalAttributeReader(const EmberAfCluster * aCluster) : MandatoryGlobalAttributeReader(aCluster) {}
43 :
44 : CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override;
45 :
46 : private:
47 : typedef CHIP_ERROR (CommandHandlerInterface::*CommandListEnumerator)(const ConcreteClusterPath & cluster,
48 : CommandHandlerInterface::CommandIdCallback callback,
49 : void * context);
50 : static CHIP_ERROR EncodeCommandList(const ConcreteClusterPath & aClusterPath, AttributeValueEncoder & aEncoder,
51 : CommandListEnumerator aEnumerator, const CommandId * aClusterCommandList);
52 : };
53 :
54 : } // namespace Compatibility
55 : } // namespace app
56 : } // namespace chip
|