Skip to content

Commit

Permalink
Build time optimization (#37433)
Browse files Browse the repository at this point in the history
* Move some classes out of af-types.h

Move AttributesChangedListener and MarkAttributeDirty out of af-types.h

Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>

* Remove dependency to cluster-objects.h

Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>

* Remove cluster-objects from chip_data_model.cmake

Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>

* [Chef] Fix includes

Fix missing includes after changes in Accessors.h

Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>

* [Infineon] Fix includes

Fix missing includes after changes in Accessors.h

Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>

* [Silabs] Fix includes

Fix missing includes after changes in Accessors.h

Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>

---------

Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>
  • Loading branch information
adigie authored Feb 19, 2025
1 parent 86e0b85 commit 38cc24b
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/util/config.h>
#include <chef-dishwasher-mode-delegate-impl.h>

using namespace chip;
using namespace chip::app;
Expand Down
1 change: 1 addition & 0 deletions examples/chef/common/chef-rvc-mode-delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/util/config.h>
#include <chef-rvc-mode-delegate.h>

using namespace chip;
using namespace chip::app;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <platform/CHIPDeviceLayer.h>
#include <platform/DeviceInstanceInfoProvider.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "LightingManager.h"
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <platform/CHIPDeviceLayer.h>
#include <platform/DeviceInstanceInfoProvider.h>

Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/infineon/cyw30739/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "LockManager.h"
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app/data-model/Nullable.h>
#include <lib/core/DataModelTypes.h>
#include <lib/support/logging/CHIPLogging.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "AppTask.h"
#include "hdc2010.h"
#include "platform/CHIPDeviceLayer.h"
#include <app-common/zap-generated/cluster-objects.h>

/**********************************************************
* Defines and Constants
Expand Down
1 change: 1 addition & 0 deletions examples/thermostat/silabs/src/TemperatureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "AppConfig.h"
#include "AppEvent.h"
#include "AppTask.h"
#include <app-common/zap-generated/cluster-objects.h>

/**********************************************************
* Defines and Constants
Expand Down
8 changes: 0 additions & 8 deletions src/app/chip_data_model.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,6 @@ function(chip_configure_data_model APP_TARGET)
set(APP_GEN_FILES)
endif()

# This is:
# //src/app/common:cluster-objects
#
# TODO: ideally we would avoid duplication and would link gn-built items
target_sources(${APP_TARGET} ${SCOPE}
${CHIP_APP_BASE_DIR}/../../zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp
)

chip_zapgen(${APP_TARGET}-zapgen
INPUT "${ARG_ZAP_FILE}"
GENERATOR "app-templates"
Expand Down
35 changes: 35 additions & 0 deletions src/app/util/AttributesChangedListener.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
*
* 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.
*/
#pragma once

#include <app/AttributePathParams.h>

namespace chip {
namespace app {

/// Notification object of a specific path being changed
class AttributesChangedListener
{
public:
virtual ~AttributesChangedListener() = default;

/// Called when the set of attributes identified by AttributePathParams (which may contain wildcards) is to be considered dirty.
virtual void MarkDirty(const AttributePathParams & path) = 0;
};

} // namespace app
} // namespace chip
6 changes: 5 additions & 1 deletion src/app/util/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ source_set("types") {

# This source set also depends on data-model
source_set("af-types") {
sources = [ "af-types.h" ]
sources = [
"AttributesChangedListener.h",
"MarkAttributeDirty.h",
"af-types.h",
]
deps = [
":types",
"${chip_root}/src/app:paths",
Expand Down
33 changes: 33 additions & 0 deletions src/app/util/MarkAttributeDirty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
*
* 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.
*/
#pragma once

namespace chip {
namespace app {

enum class MarkAttributeDirty
{
kIfChanged,
kNo,
// kYes might need to be used if the attribute value was previously changed
// without reporting, and now is being set in a situation where we know
// reporting needs to be triggered (e.g. because QuieterReportingAttribute
// indicated that).
kYes,
};
}
} // namespace chip
29 changes: 2 additions & 27 deletions src/app/util/af-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <stdbool.h> // For bool
#include <stdint.h> // For various uint*_t types

#include <app/util/AttributesChangedListener.h>
#include <app/util/MarkAttributeDirty.h>
#include <app/util/basic-types.h>
#include <app/util/types_stub.h> // For various types.

Expand Down Expand Up @@ -280,30 +282,3 @@ typedef chip::Protocols::InteractionModel::Status (*EmberAfClusterPreAttributeCh
#define MAX_INT16U_VALUE (0xFFFF)

/** @} END addtogroup */

namespace chip {
namespace app {

enum class MarkAttributeDirty
{
kIfChanged,
kNo,
// kYes might need to be used if the attribute value was previously changed
// without reporting, and now is being set in a situation where we know
// reporting needs to be triggered (e.g. because QuieterReportingAttribute
// indicated that).
kYes,
};

/// Notification object of a specific path being changed
class AttributesChangedListener
{
public:
virtual ~AttributesChangedListener() = default;

/// Called when the set of attributes identified by AttributePathParams (which may contain wildcards) is to be considered dirty.
virtual void MarkDirty(const AttributePathParams & path) = 0;
};

} // namespace app
} // namespace chip
3 changes: 2 additions & 1 deletion src/app/util/attribute-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#pragma once

#include <app/ConcreteAttributePath.h>
#include <app/util/af-types.h>
#include <app/util/AttributesChangedListener.h>
#include <app/util/MarkAttributeDirty.h>
#include <app/util/attribute-metadata.h>
#include <lib/core/DataModelTypes.h>
#include <protocols/interaction_model/StatusCode.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/util/attribute-storage-null-handling.h>
#include <app/util/attribute-table.h>
#include <app/util/ember-strings.h>
#include <app/util/odd-sized-integers.h>
#include <lib/core/CHIPEncoding.h>
#include <lib/support/logging/CHIPLogging.h>
Expand Down
7 changes: 3 additions & 4 deletions src/app/zap-templates/templates/app/attributes/Accessors.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

#pragma once

#include <app-common/zap-generated/cluster-enums.h>
#include <app/data-model/Nullable.h>
#include <app/util/af-types.h>
#include <app/util/ember-strings.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <lib/support/Span.h>
#include <app/util/basic-types.h>
#include <app/util/MarkAttributeDirty.h>
#include <protocols/interaction_model/StatusCode.h>

namespace chip {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 38cc24b

Please sign in to comment.