From e2c2e9dc1a9a7f7eafff371cdf29bb731015238c Mon Sep 17 00:00:00 2001 From: Gabriele Contini <gcontini@users.noreply.github.com> Date: 周六, 14 12月 2019 13:56:41 +0800 Subject: [PATCH] Merge pull request #69 from open-license-manager/feature/issue_licenses_42 --- src/library/locate/LocatorFactory.cpp | 39 +++++++++++++++------------------------ 1 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/library/locate/LocatorFactory.cpp b/src/library/locate/LocatorFactory.cpp index 1b45752..9b77b06 100644 --- a/src/library/locate/LocatorFactory.cpp +++ b/src/library/locate/LocatorFactory.cpp @@ -5,8 +5,6 @@ * Author: Gabriele Contini */ -#include "build_properties.h" - #include "LocatorStrategy.hpp" #include "LocatorFactory.hpp" #include "ApplicationFolder.hpp" @@ -16,31 +14,24 @@ namespace license { namespace locate { +static std::vector<std::unique_ptr<LocatorStrategy>> extra_strategies; -FUNCTION_RETURN LocatorFactory::get_active_strategies( - std::vector<std::unique_ptr<LocatorStrategy>> &strategies, - const LicenseLocation *locationHint) { -#if(FIND_LICENSE_NEAR_MODULE) - strategies.push_back( - std::unique_ptr<LocatorStrategy>( - (LocatorStrategy*) new ApplicationFolder())); -#endif -#if(FIND_LICENSE_WITH_ENV_VAR) - strategies.push_back( - std::unique_ptr<LocatorStrategy>( - (LocatorStrategy*) new EnvironmentVarLocation())); - strategies.push_back( - std::unique_ptr<LocatorStrategy>( - (LocatorStrategy*) new EnvironmentVarData())); -#endif +bool LocatorFactory::find_license_near_moduleb = FIND_LICENSE_NEAR_MODULE; +bool LocatorFactory::find_license_with_env_varb = FIND_LICENSE_WITH_ENV_VAR; +FUNCTION_RETURN LocatorFactory::get_active_strategies(std::vector<std::unique_ptr<LocatorStrategy>> &strategies, + const LicenseLocation *locationHint) { + if (find_license_near_moduleb) { + strategies.push_back(std::unique_ptr<LocatorStrategy>((LocatorStrategy *)new ApplicationFolder())); + } + if (find_license_with_env_varb) { + strategies.push_back(std::unique_ptr<LocatorStrategy>((LocatorStrategy *)new EnvironmentVarLocation())); + strategies.push_back(std::unique_ptr<LocatorStrategy>((LocatorStrategy *)new EnvironmentVarData())); + } if (locationHint != nullptr) { - strategies.push_back( - std::unique_ptr<LocatorStrategy>( - (LocatorStrategy*) new ExternalDefinition(locationHint))); + strategies.push_back(std::unique_ptr<LocatorStrategy>((LocatorStrategy *)new ExternalDefinition(locationHint))); } return strategies.size() > 0 ? FUNC_RET_OK : FUNC_RET_NOT_AVAIL; - } -} -} +} // namespace locate +} // namespace license -- Gitblit v1.9.1