Gabriele Contini
2019-12-14 5bfaf2ce035d09a6f12af81bf99a46169a5890fc
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