| | |
| | | namespace license { |
| | | namespace hw_identifier { |
| | | |
| | | static vector<LCC_API_IDENTIFICATION_STRATEGY> available_strategies() { |
| | | static vector<LCC_API_HW_IDENTIFICATION_STRATEGY> available_strategies() { |
| | | os::ExecutionEnvironment exec; |
| | | os::VIRTUALIZATION virtualization = exec.getVirtualization(); |
| | | vector<LCC_API_IDENTIFICATION_STRATEGY> strategy_to_try; |
| | | vector<LCC_API_HW_IDENTIFICATION_STRATEGY> strategy_to_try; |
| | | if (virtualization == os::CONTAINER) { |
| | | if (exec.is_docker()) { |
| | | strategy_to_try = LCC_DOCKER_STRATEGIES; |
| | |
| | | |
| | | DefaultStrategy::~DefaultStrategy() {} |
| | | |
| | | LCC_API_IDENTIFICATION_STRATEGY DefaultStrategy::identification_strategy() const { return STRATEGY_DEFAULT; } |
| | | LCC_API_HW_IDENTIFICATION_STRATEGY DefaultStrategy::identification_strategy() const { return STRATEGY_DEFAULT; } |
| | | |
| | | FUNCTION_RETURN DefaultStrategy::identify_pc(HwIdentifier& pc_id) const { |
| | | vector<LCC_API_IDENTIFICATION_STRATEGY> strategy_to_try = available_strategies(); |
| | | FUNCTION_RETURN DefaultStrategy::generate_pc_id(HwIdentifier& pc_id) const { |
| | | vector<LCC_API_HW_IDENTIFICATION_STRATEGY> strategy_to_try = available_strategies(); |
| | | FUNCTION_RETURN ret = FUNC_RET_NOT_AVAIL; |
| | | for (auto it : strategy_to_try) { |
| | | LCC_API_IDENTIFICATION_STRATEGY strat_to_try = it; |
| | | LCC_API_HW_IDENTIFICATION_STRATEGY strat_to_try = it; |
| | | unique_ptr<IdentificationStrategy> strategy_ptr = IdentificationStrategy::get_strategy(strat_to_try); |
| | | ret = strategy_ptr->identify_pc(pc_id); |
| | | ret = strategy_ptr->generate_pc_id(pc_id); |
| | | if (ret == FUNC_RET_OK) { |
| | | break; |
| | | } |
| | |
| | | } |
| | | |
| | | std::vector<HwIdentifier> DefaultStrategy::alternative_ids() const { |
| | | vector<LCC_API_IDENTIFICATION_STRATEGY> strategy_to_try = available_strategies(); |
| | | vector<LCC_API_HW_IDENTIFICATION_STRATEGY> strategy_to_try = available_strategies(); |
| | | vector<HwIdentifier> identifiers; |
| | | FUNCTION_RETURN ret = FUNC_RET_NOT_AVAIL; |
| | | for (auto it : strategy_to_try) { |
| | | LCC_API_IDENTIFICATION_STRATEGY strat_to_try = it; |
| | | LCC_API_HW_IDENTIFICATION_STRATEGY strat_to_try = it; |
| | | unique_ptr<IdentificationStrategy> strategy_ptr = IdentificationStrategy::get_strategy(strat_to_try); |
| | | vector<HwIdentifier> alt_ids = strategy_ptr->alternative_ids(); |
| | | identifiers.insert(alt_ids.begin(), alt_ids.end(), identifiers.end()); |