Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / app / MessageDef / AttributeDataVersionList.h
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 AttributeDataVersionList parser and builder in CHIP interaction model
21  *
22  */
23
24 #pragma once
25
26 #ifndef _CHIP_INTERACTION_MODEL_MESSAGE_DEF_ATTRIBUTE_DATA_VERSION_LIST_H
27 #define _CHIP_INTERACTION_MODEL_MESSAGE_DEF_ATTRIBUTE_DATA_VERSION_LIST_H
28
29 #include "AttributeDataElement.h"
30 #include "ListBuilder.h"
31 #include "ListParser.h"
32
33 #include <core/CHIPCore.h>
34 #include <core/CHIPTLV.h>
35 #include <support/CodeUtils.h>
36 #include <support/logging/CHIPLogging.h>
37 #include <util/basic-types.h>
38
39 namespace chip {
40 namespace app {
41 namespace AttributeDataVersionList {
42 class Parser : public ListParser
43 {
44 public:
45     /**
46      *  @brief Roughly verify the message is correctly formed
47      *   1) all mandatory tags are present
48      *   2) all elements have expected data type
49      *   3) any tag can only appear once
50      *   4) At the top level of the structure, unknown tags are ignored for forward compatibility
51      *  @note The main use of this function is to print out what we're
52      *    receiving during protocol development and debugging.
53      *    The encoding rule has changed in IM encoding spec so this
54      *    check is only "roughly" conformant now.
55      *
56      *  @return #CHIP_NO_ERROR on success
57      */
58     CHIP_ERROR CheckSchemaValidity() const;
59
60     /**
61      *  @brief Check if this element is valid
62      *
63      *  @return A Boolean
64      */
65     bool IsElementValid(void);
66
67     /**
68      *  @brief Check if this element is NULL
69      *
70      *  @return A Boolean
71      */
72     bool IsNull(void);
73
74     /**
75      *  @brief Get a value for the DataVersion. Next() must be called before accessing them.
76      *
77      *  @param [in] apVersion    A pointer to apVersion
78      *
79      *  @return #CHIP_NO_ERROR on success
80      *          #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
81      *          #CHIP_END_OF_TLV if there is no such element
82      */
83     CHIP_ERROR GetVersion(chip::DataVersion * const apVersion);
84 };
85
86 class Builder : public ListBuilder
87 {
88 public:
89     /**
90      *  @brief Add version in AttributeDataVersionList
91      *
92      *  @return A reference to AttributeDataVersionList::Builder
93      */
94     AttributeDataVersionList::Builder & AddVersion(const uint64_t aVersion);
95
96     /**
97      *  @brief Add Null in version list
98      *
99      *  @return A reference to *this
100      */
101     AttributeDataVersionList::Builder & AddNull(void);
102     /**
103      *  @brief Mark the end of this AttributeDataVersionList
104      *
105      *  @return A reference to *this
106      */
107     AttributeDataVersionList::Builder & EndOfAttributeDataVersionList();
108
109 private:
110     AttributeDataElement::Builder mAttributeDataElementBuilder;
111 };
112 }; // namespace AttributeDataVersionList
113 }; // namespace app
114 }; // namespace chip
115
116 #endif // _CHIP_INTERACTION_MODEL_MESSAGE_DEF_ATTRIBUTE_DATA_VERSION_LIST_H