Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SofaGraphComponent] Fix a typo in the warning emited by the APIVersion component and add missing allowed versions. #2103

Merged
merged 2 commits into from May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Expand Up @@ -4,8 +4,8 @@ project(Sofa) # Cannot use VERSION with patch like "00"
include(CMakeDependentOption)

# Manually define VERSION
set(Sofa_VERSION_MAJOR 20)
set(Sofa_VERSION_MINOR 12)
set(Sofa_VERSION_MAJOR 21)
set(Sofa_VERSION_MINOR 06)
set(Sofa_VERSION_PATCH 99)
set(Sofa_VERSION ${Sofa_VERSION_MAJOR}.${Sofa_VERSION_MINOR}.${Sofa_VERSION_PATCH})

Expand Down
12 changes: 9 additions & 3 deletions modules/SofaGraphComponent/src/SofaGraphComponent/APIVersion.cpp
Expand Up @@ -28,6 +28,7 @@ using sofa::core::RegisterObject ;

#include "APIVersion.h"
#include <sofa/version.h>
#include <numeric>

namespace sofa::component::_apiversion_
{
Expand Down Expand Up @@ -56,10 +57,15 @@ void APIVersion::checkInputData()
if( !d_level.isSet() && name.isSet() ){
d_level.setValue(getName());
}
std::vector<std::string> allowedVersion = { "17.06", "17.12", "18.06", "18.12", SOFA_VERSION_STR } ;
if( std::find( allowedVersion.begin(), allowedVersion.end(), d_level.getValue()) == allowedVersion.end() )

const auto & API_version = d_level.getValue();
static const std::set<std::string> allowedAPIVersions { "17.06", "17.12", "18.06", "18.12", "19.06", "19.12", "20.06", "20.12", SOFA_VERSION_STR } ;
if( allowedAPIVersions.find(API_version) == std::cend(allowedAPIVersions) )
{
msg_warning() << "The provided level '"<< d_level.getValue() <<"' is now valid. " ;
auto allowedVersionStr = std::accumulate(std::next(allowedAPIVersions.begin()), allowedAPIVersions.end(), *(allowedAPIVersions.begin()), [](const std::string & s, const std::string & v) {
return s + ", " + v;
});
msg_warning() << "The provided level '"<< API_version <<"' is not valid. Allowed versions are [" << allowedVersionStr << "]." ;
}
}

Expand Down