Skip to content

Commit

Permalink
WIP proto for parametric signature
Browse files Browse the repository at this point in the history
(references OpenFLUID#1157)
  • Loading branch information
Arthoni committed Oct 26, 2023
1 parent 15c9a87 commit 3c6f745
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMake.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SET(OFBUILD_CUSTOM_CMAKE_VERSION "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.
SET(OPENFLUID_VERSION_MAJOR 2)
SET(OPENFLUID_VERSION_MINOR 2)
SET(OPENFLUID_VERSION_PATCH 0)
SET(OPENFLUID_VERSION_STATUS "alpha99") # example: SET(OPENFLUID_VERSION_STATUS "rc1")
SET(OPENFLUID_VERSION_STATUS "alpha100") # example: SET(OPENFLUID_VERSION_STATUS "rc1")

SET(OPENFLUID_VERSION_FULL "${OPENFLUID_VERSION_MAJOR}.${OPENFLUID_VERSION_MINOR}.${OPENFLUID_VERSION_PATCH}")

Expand Down
4 changes: 2 additions & 2 deletions cmake/OpenFLUIDHelpers.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ FUNCTION(_OPENFLUID_WAREPLUGIN_BUILD)
SET(CMAKE_BUILD_TYPE "Debug")
ENDIF()

# Run info2build if not already done
# Run info2build if not already done, src-path was CMAKE_SOURCE_DIR but parametrized signature require configuration
IF (NOT _FORCE_PARAMSUI)
EXECUTE_PROCESS(COMMAND "${OpenFLUID_CMD_PROGRAM}" "info2build"
"--src-path=${CMAKE_SOURCE_DIR}" "--dest-path=${CMAKE_BINARY_DIR}"
"--src-path=${CMAKE_BINARY_DIR}" "--dest-path=${CMAKE_BINARY_DIR}"
RESULT_VARIABLE _WAREINFO_RESULT
OUTPUT_VARIABLE _WAREINFO_OUTPUT)
IF(_WAREINFO_RESULT AND NOT _WAREINFO_RESULT EQUAL 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ PROJECT("%%WAREID%%")

FIND_PACKAGE(OpenFLUID REQUIRED)

CONFIGURE_FILE(openfluid-ware.json openfluid-ware.json COPYONLY)

ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(doc)
ADD_SUBDIRECTORY(tests)
Expand Down
11 changes: 9 additions & 2 deletions src/openfluid/tools/IDHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,19 @@ bool isValidDatasetName(const std::string& Name)
// =====================================================================


bool isValidWareID(const openfluid::ware::WareID_t& ID)
bool isValidWareID(const openfluid::ware::WareID_t& ID, bool Template)
{
// authorized chars: a to z, A to Z, 0 to 9, -, ., _
// must start by an alphanumeric char

return std::regex_match(ID,std::regex(WareIDRuleString));
if (Template)
{
return std::regex_match(ID,std::regex(WareIDRuleStringAndTpl));
}
else
{
return std::regex_match(ID,std::regex(WareIDRuleString));
}
}


Expand Down
3 changes: 2 additions & 1 deletion src/openfluid/tools/IDHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace openfluid { namespace tools {
constexpr auto DatasetNameRuleString("[A-Za-z0-9]+([A-Za-z0-9_\\.\\-]*)");

constexpr auto WareIDRuleString("[A-Za-z0-9]+([A-Za-z0-9_\\.\\-]*)");
constexpr auto WareIDRuleStringAndTpl("[A-Za-z0-9]+([A-Za-z0-9_@\\.\\-]*)");

constexpr auto FragmentNameRuleString("[A-Za-z]+([A-Za-z0-9_\\.\\-]*)");

Expand Down Expand Up @@ -99,7 +100,7 @@ bool OPENFLUID_API isValidDatasetName(const std::string& Name);
@param[in] ID the ware ID to check
@return true if the ID is valid
*/
bool OPENFLUID_API isValidWareID(const openfluid::ware::WareID_t& ID);
bool OPENFLUID_API isValidWareID(const openfluid::ware::WareID_t& ID, bool Template=false);


/**
Expand Down
2 changes: 1 addition & 1 deletion src/openfluid/ui/common/SignatureEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ bool SignatureEditorWidget::isValidID() const
return true;
}

return openfluid::tools::isValidWareID(ui->IDEdit->text().toStdString());
return openfluid::tools::isValidWareID(ui->IDEdit->text().toStdString(), true);
}


Expand Down
2 changes: 1 addition & 1 deletion src/openfluid/ui/waresdev/NewWareDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ QRegularExpression NewWareDialog::getWareIdRegExp(QString& Tooltip)

Tooltip = QObject::tr("Accepts only letters, digits, dashes ('-'), underscores ('_') and dots ('.').");
#if (QT_VERSION_MAJOR < 6)
return QRegExp(QString::fromStdString(openfluid::tools::WareIDRuleString));
return QRegExp(QString::fromStdString(openfluid::tools::WareIDRuleStringAndTpl));
#else
return QRegularExpression(QString::fromStdString(openfluid::tools::WareIDRuleString));
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/openfluid/waresdev/WareSignatureSerializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ SignatureType WareSignatureSerializer<SignatureType>::fromJSONBase(const openflu
SignatureType Sign;

Sign.ID = Json.value("id","");
if (!openfluid::tools::isValidWareID(Sign.ID))
if (!openfluid::tools::isValidWareID(Sign.ID, true))
{
throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,"Missing or invalid ware ID");
}
Expand Down

0 comments on commit 3c6f745

Please sign in to comment.