Line data Source code
1 : /** 2 : * 3 : * Copyright (c) 2020 Project CHIP Authors 4 : * Copyright (c) 2016-2017 Nest Labs, Inc. 5 : * 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 9 : * 10 : * http://www.apache.org/licenses/LICENSE-2.0 11 : * 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. 17 : */ 18 : /** 19 : * @file 20 : * This file defines AttributeReportIBs parser and builder in CHIP interaction model 21 : * 22 : */ 23 : 24 : #pragma once 25 : 26 : #include "ArrayBuilder.h" 27 : #include "ArrayParser.h" 28 : #include "AttributeReportIB.h" 29 : 30 : #include <app/AppConfig.h> 31 : #include <app/ConcreteAttributePath.h> 32 : #include <app/MessageDef/StatusIB.h> 33 : #include <app/util/basic-types.h> 34 : #include <lib/core/CHIPCore.h> 35 : #include <lib/core/TLV.h> 36 : #include <lib/support/CodeUtils.h> 37 : #include <lib/support/logging/CHIPLogging.h> 38 : 39 : namespace chip { 40 : namespace app { 41 : namespace AttributeReportIBs { 42 : class Parser : public ArrayParser 43 : { 44 : public: 45 : #if CHIP_CONFIG_IM_PRETTY_PRINT 46 : CHIP_ERROR PrettyPrint() const; 47 : #endif // CHIP_CONFIG_IM_PRETTY_PRINT 48 : }; 49 : 50 : class Builder : public ArrayBuilder 51 : { 52 : public: 53 : /** 54 : * @brief Initialize a AttributeReportIB::Builder for writing into the TLV stream 55 : * 56 : * @return A reference to AttributeReportIB::Builder 57 : */ 58 : AttributeReportIB::Builder & CreateAttributeReport(); 59 : 60 11981 : AttributeReportIB::Builder & GetAttributeReport() { return mAttributeReport; } 61 : 62 : /** 63 : * @brief Mark the end of this AttributeReportIBs 64 : * 65 : * @return The builder's final status. 66 : */ 67 : CHIP_ERROR EndOfAttributeReportIBs(); 68 : 69 : /** 70 : * Encode an AttributeReportIB containing an AttributeStatus. 71 : */ 72 : CHIP_ERROR EncodeAttributeStatus(const ConcreteReadAttributePath & aPath, const StatusIB & aStatus); 73 : 74 : private: 75 : AttributeReportIB::Builder mAttributeReport; 76 : }; 77 : } // namespace AttributeReportIBs 78 : } // namespace app 79 : } // namespace chip