You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "fgerlits (via GitHub)" <gi...@apache.org> on 2023/08/10 09:18:45 UTC
[GitHub] [nifi-minifi-cpp] fgerlits opened a new pull request, #1626: MINIFICPP-2164 Use a list of types for allowed types in PropertyDefinition
fgerlits opened a new pull request, #1626:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1626
https://issues.apache.org/jira/browse/MINIFICPP-2164
---
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [x] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
- [x] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [x] Has your PR been rebased against the latest commit within the target branch (typically main)?
- [x] Is your initial contribution a single, squashed commit?
### For code changes:
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the LICENSE file?
- [ ] If applicable, have you updated the NOTICE file?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1626: MINIFICPP-2164 Use a list of types for allowed types in PropertyDefinition
Posted by "szaszm (via GitHub)" <gi...@apache.org>.
szaszm commented on code in PR #1626:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1626#discussion_r1290183175
##########
libminifi/include/core/PropertyDefinitionBuilder.h:
##########
@@ -23,75 +23,69 @@
namespace org::apache::nifi::minifi::core {
-template <size_t NumAllowedValues = 0, size_t NumAllowedTypes = 0, size_t NumDependentProperties = 0, size_t NumExclusiveOfProperties = 0>
+template<size_t NumAllowedValues = 0, size_t NumDependentProperties = 0, size_t NumExclusiveOfProperties = 0, typename AllowedTypes = utils::meta::type_list<>>
struct PropertyDefinitionBuilder {
- static constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> createProperty(std::string_view name) {
- PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> builder;
+ static constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> createProperty(std::string_view name) {
+ PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> builder;
builder.property.name = name;
return builder;
}
- static constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> createProperty(std::string_view name, std::string_view display_name) {
- PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> builder;
+ static constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> createProperty(std::string_view name, std::string_view display_name) {
+ PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> builder;
builder.property.name = name;
builder.property.display_name = display_name;
return builder;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> withDescription(std::string_view description) {
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> withDescription(std::string_view description) {
property.description = description;
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> isRequired(bool required) {
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> isRequired(bool required) {
property.is_required = required;
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> supportsExpressionLanguage(bool supports_expression_language) {
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> supportsExpressionLanguage(bool supports_expression_language) {
property.supports_expression_language = supports_expression_language;
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> withDefaultValue(std::string_view default_value) {
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> withDefaultValue(std::string_view default_value) {
property.default_value = std::optional<std::string_view>{default_value}; // workaround for gcc 11.1; on gcc 11.3 and later, `property.default_value = default_value` works, too
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> withAllowedValues(
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> withAllowedValues(
std::array<std::string_view, NumAllowedValues> allowed_values) {
property.allowed_values = allowed_values;
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> withAllowedTypes(
- std::array<std::string_view, NumAllowedTypes> types) {
- property.allowed_types = types;
- return *this;
- }
Review Comment:
I think it would be nicer to not have to specify this upfront in the template argument list, only in the call. I think something like this would work:
```cpp
template<typename... NewAllowedTypes>
constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveProperties, utils::meta::type_list<NewAllowedTypes...>> withAllowedTypes()
{
return {
.property = {
.name = property.name,
.display_name = property.display_name,
.description = property.description,
.is_required = property.is_required,
.allowed_values = property.allowed_values;
.dependent_properties = property.dependent_properties,
.exclusive_of_properties = property.exclusive_of_properties,
.default_value = property.default_value,
.type = property.type,
.supports_expression_language = property.supports_expression_language
}
};
}
```
Optionally, the member list duplication could be moved by defining a templated copy constructor on `PropertyDefinition`, or it can be transformed into some additional complexity by using X macro or similar reflection tricks to list all members of `PropertyDefinition`. The second approach should make it easier to do the same with the rest of the template arguments as well.
```cpp
// near PropertyDefinition
#define PROPERTY_DEFINITION_MEMBER_LIST (name, display_name, description, is_required, allowed_values, dependent_properties, exclusive_of_properties, default_value, type, supports_expression_language)
// in PropertyDefinitionBuilder, using utils/Macro.h
template<typename... NewAllowedTypes>
constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveProperties, utils::meta::type_list<NewAllowedTypes...>> withAllowedTypes()
{
#define PROPERTY_DEFINITION_BUILDER_WITH_ALLOWED_TYPES_IMPL_COPY_MEMBER(member, ...) .member = property.member
return {
.property = {
FOR_EACH(PROPERTY_DEFINITION_BUILDER_WITH_ALLOWED_TYPES_IMPL_COPY_MEMBER, COMMA, PROPERTY_DEFINITION_MEMBER_LIST)
}
};
#undef PROPERTY_DEFINITION_BUILDER_WITH_ALLOWED_TYPES_COPY_MEMBER
}
```
Both of these examples are untested, so they may have bugs. Especially the second one, because I'm not familiar with all of the preprocessor quirks.
##########
libminifi/include/utils/meta/type_list.h:
##########
@@ -15,14 +15,23 @@
* limitations under the License.
*/
#pragma once
+
+#include <array>
+#include <string_view>
#include <type_traits>
+#include "core/Core.h"
+
namespace org::apache::nifi::minifi::utils::meta {
+
template<typename... Types>
struct type_list {
template<typename T>
[[nodiscard]] constexpr static bool contains() noexcept {
return (std::is_same_v<T, Types> || ...);
}
+
+ static constexpr auto AsStringViews = std::array<std::string_view, sizeof...(Types)>{core::className<Types>()...};
Review Comment:
I would either move this near the usage site, or keep it more generic. Possible generic version:
```suggestion
template<template<typename...> typename Container, typename Mapper>
requires (requires(Mapper m) { m<Types>(); } && ...)
static constexpr auto MapToValues(Mapper templated_map_function) {
return Container{templated_map_function<Types>()...};
}
// MapToValues<std::array>([]<typename T>() { return core::className<T>(); })
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1626: MINIFICPP-2164 Use a list of types for allowed types in PropertyDefinition
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #1626:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1626#discussion_r1293332893
##########
libminifi/include/utils/meta/type_list.h:
##########
@@ -15,14 +15,23 @@
* limitations under the License.
*/
#pragma once
+
+#include <array>
+#include <string_view>
#include <type_traits>
+#include "core/Core.h"
+
namespace org::apache::nifi::minifi::utils::meta {
+
template<typename... Types>
struct type_list {
template<typename T>
[[nodiscard]] constexpr static bool contains() noexcept {
return (std::is_same_v<T, Types> || ...);
}
+
+ static constexpr auto AsStringViews = std::array<std::string_view, sizeof...(Types)>{core::className<Types>()...};
Review Comment:
I have moved it to `PropertyDefinition.h`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1626: MINIFICPP-2164 Use a list of types for allowed types in PropertyDefinition
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #1626:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1626#discussion_r1293332893
##########
libminifi/include/utils/meta/type_list.h:
##########
@@ -15,14 +15,23 @@
* limitations under the License.
*/
#pragma once
+
+#include <array>
+#include <string_view>
#include <type_traits>
+#include "core/Core.h"
+
namespace org::apache::nifi::minifi::utils::meta {
+
template<typename... Types>
struct type_list {
template<typename T>
[[nodiscard]] constexpr static bool contains() noexcept {
return (std::is_same_v<T, Types> || ...);
}
+
+ static constexpr auto AsStringViews = std::array<std::string_view, sizeof...(Types)>{core::className<Types>()...};
Review Comment:
I have moved it to `PropertyDefinition.h`.
But I have kept the unit tests on `contains()`; they don't really belong in this pull request now, but I think they're useful.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1626: MINIFICPP-2164 Use a list of types for allowed types in PropertyDefinition
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #1626:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1626#discussion_r1293332560
##########
libminifi/include/core/PropertyDefinitionBuilder.h:
##########
@@ -23,75 +23,69 @@
namespace org::apache::nifi::minifi::core {
-template <size_t NumAllowedValues = 0, size_t NumAllowedTypes = 0, size_t NumDependentProperties = 0, size_t NumExclusiveOfProperties = 0>
+template<size_t NumAllowedValues = 0, size_t NumDependentProperties = 0, size_t NumExclusiveOfProperties = 0, typename AllowedTypes = utils::meta::type_list<>>
struct PropertyDefinitionBuilder {
- static constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> createProperty(std::string_view name) {
- PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> builder;
+ static constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> createProperty(std::string_view name) {
+ PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> builder;
builder.property.name = name;
return builder;
}
- static constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> createProperty(std::string_view name, std::string_view display_name) {
- PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> builder;
+ static constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> createProperty(std::string_view name, std::string_view display_name) {
+ PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> builder;
builder.property.name = name;
builder.property.display_name = display_name;
return builder;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> withDescription(std::string_view description) {
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> withDescription(std::string_view description) {
property.description = description;
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> isRequired(bool required) {
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> isRequired(bool required) {
property.is_required = required;
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> supportsExpressionLanguage(bool supports_expression_language) {
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> supportsExpressionLanguage(bool supports_expression_language) {
property.supports_expression_language = supports_expression_language;
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> withDefaultValue(std::string_view default_value) {
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> withDefaultValue(std::string_view default_value) {
property.default_value = std::optional<std::string_view>{default_value}; // workaround for gcc 11.1; on gcc 11.3 and later, `property.default_value = default_value` works, too
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> withAllowedValues(
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> withAllowedValues(
std::array<std::string_view, NumAllowedValues> allowed_values) {
property.allowed_values = allowed_values;
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> withAllowedTypes(
- std::array<std::string_view, NumAllowedTypes> types) {
- property.allowed_types = types;
- return *this;
- }
Review Comment:
I have rewritten it in a way to only require a template parameter on `withAllowedTypes()` instead of the `PropertyDefinition` and `PropertyDefinitionBuilder`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1626: MINIFICPP-2164 Use a list of types for allowed types in PropertyDefinition
Posted by "szaszm (via GitHub)" <gi...@apache.org>.
szaszm commented on code in PR #1626:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1626#discussion_r1293381914
##########
libminifi/include/core/PropertyDefinitionBuilder.h:
##########
@@ -23,75 +23,69 @@
namespace org::apache::nifi::minifi::core {
-template <size_t NumAllowedValues = 0, size_t NumAllowedTypes = 0, size_t NumDependentProperties = 0, size_t NumExclusiveOfProperties = 0>
+template<size_t NumAllowedValues = 0, size_t NumDependentProperties = 0, size_t NumExclusiveOfProperties = 0, typename AllowedTypes = utils::meta::type_list<>>
struct PropertyDefinitionBuilder {
- static constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> createProperty(std::string_view name) {
- PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> builder;
+ static constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> createProperty(std::string_view name) {
+ PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> builder;
builder.property.name = name;
return builder;
}
- static constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> createProperty(std::string_view name, std::string_view display_name) {
- PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> builder;
+ static constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> createProperty(std::string_view name, std::string_view display_name) {
+ PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> builder;
builder.property.name = name;
builder.property.display_name = display_name;
return builder;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> withDescription(std::string_view description) {
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> withDescription(std::string_view description) {
property.description = description;
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> isRequired(bool required) {
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> isRequired(bool required) {
property.is_required = required;
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> supportsExpressionLanguage(bool supports_expression_language) {
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> supportsExpressionLanguage(bool supports_expression_language) {
property.supports_expression_language = supports_expression_language;
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> withDefaultValue(std::string_view default_value) {
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> withDefaultValue(std::string_view default_value) {
property.default_value = std::optional<std::string_view>{default_value}; // workaround for gcc 11.1; on gcc 11.3 and later, `property.default_value = default_value` works, too
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> withAllowedValues(
+ constexpr PropertyDefinitionBuilder<NumAllowedValues, NumDependentProperties, NumExclusiveOfProperties, AllowedTypes> withAllowedValues(
std::array<std::string_view, NumAllowedValues> allowed_values) {
property.allowed_values = allowed_values;
return *this;
}
- constexpr PropertyDefinitionBuilder<NumAllowedValues, NumAllowedTypes, NumDependentProperties, NumExclusiveOfProperties> withAllowedTypes(
- std::array<std::string_view, NumAllowedTypes> types) {
- property.allowed_types = types;
- return *this;
- }
Review Comment:
that's a great solution that I completely missed when writing the comment. Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1626: MINIFICPP-2164 Use a list of types for allowed types in PropertyDefinition
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #1626:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1626#discussion_r1293677820
##########
libminifi/test/unit/TypeListTests.cpp:
##########
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#include "../Catch.h"
+#include "core/Core.h"
+#include "utils/meta/type_list.h"
+
+class A {};
+
+namespace outer {
+class B {};
+class C {};
+
+namespace inner {
+class D {};
+}
+}
+
+template<typename... Types>
+using type_list = org::apache::nifi::minifi::utils::meta::type_list<Types...>;
+
+TEST_CASE("an empty type_list doesn't contain anything") {
+ STATIC_CHECK_FALSE(type_list<>::contains<A>());
+ STATIC_CHECK_FALSE(type_list<>::contains<outer::B>());
+ STATIC_CHECK_FALSE(type_list<>::contains<outer::inner::D>());
+ STATIC_CHECK_FALSE(type_list<>::contains<std::string>());
+}
+
+TEST_CASE("a non-empty type_list contains what it should") {
+ STATIC_CHECK(type_list<A, outer::B>::contains<A>());
+ STATIC_CHECK(type_list<A, outer::B>::contains<outer::B>());
+ STATIC_CHECK_FALSE(type_list<A, outer::B>::contains<outer::C>());
+ STATIC_CHECK_FALSE(type_list<A, outer::B>::contains<outer::inner::D>());
Review Comment:
good idea, added in 6675fb9337f7c1536871acdd1daadd89c9b2c614
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez closed pull request #1626: MINIFICPP-2164 Use a list of types for allowed types in PropertyDefinition
Posted by "lordgamez (via GitHub)" <gi...@apache.org>.
lordgamez closed pull request #1626: MINIFICPP-2164 Use a list of types for allowed types in PropertyDefinition
URL: https://github.com/apache/nifi-minifi-cpp/pull/1626
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a diff in pull request #1626: MINIFICPP-2164 Use a list of types for allowed types in PropertyDefinition
Posted by "adamdebreceni (via GitHub)" <gi...@apache.org>.
adamdebreceni commented on code in PR #1626:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1626#discussion_r1293417705
##########
libminifi/test/unit/TypeListTests.cpp:
##########
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#include "../Catch.h"
+#include "core/Core.h"
+#include "utils/meta/type_list.h"
+
+class A {};
+
+namespace outer {
+class B {};
+class C {};
+
+namespace inner {
+class D {};
+}
+}
+
+template<typename... Types>
+using type_list = org::apache::nifi::minifi::utils::meta::type_list<Types...>;
+
+TEST_CASE("an empty type_list doesn't contain anything") {
+ STATIC_CHECK_FALSE(type_list<>::contains<A>());
+ STATIC_CHECK_FALSE(type_list<>::contains<outer::B>());
+ STATIC_CHECK_FALSE(type_list<>::contains<outer::inner::D>());
+ STATIC_CHECK_FALSE(type_list<>::contains<std::string>());
+}
+
+TEST_CASE("a non-empty type_list contains what it should") {
+ STATIC_CHECK(type_list<A, outer::B>::contains<A>());
+ STATIC_CHECK(type_list<A, outer::B>::contains<outer::B>());
+ STATIC_CHECK_FALSE(type_list<A, outer::B>::contains<outer::C>());
+ STATIC_CHECK_FALSE(type_list<A, outer::B>::contains<outer::inner::D>());
Review Comment:
could a test with classes with the same name but in different namespaces be useful?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org