Skip to content

Commit

Permalink
[SofaGraphComponent] Fix a typo in the warning emited by the APIVersi…
Browse files Browse the repository at this point in the history
…on component and add missing allowed versions. (#2103)

* [SofaGraphComponent] Fix a typo in the warning emitted by the APIVersion component and add missing allowed versions.

* [CMake] FIX project version

Co-authored-by: Guillaume Paran <guillaume.paran@sofa-framework.org>
  • Loading branch information
jnbrunet and guparan committed May 26, 2021
1 parent 6135cb2 commit 14d4124
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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

0 comments on commit 14d4124

Please sign in to comment.