Line data Source code
1 : /* 2 : * This file is part of PTN Engine 3 : * 4 : * Copyright (c) 2024 Eduardo ValgĂ´de 5 : * 6 : * Licensed under the Apache License, Version 2.0 (the "License"); 7 : * you may not use this file except in compliance with the License. 8 : * You may obtain a copy of the License at 9 : * 10 : * http://www.apache.org/licenses/LICENSE-2.0 11 : * 12 : * Unless required by applicable law or agreed to in writing, software 13 : * distributed under the License is distributed on an "AS IS" BASIS, 14 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 : * See the License for the specific language governing permissions and 16 : * limitations under the License. 17 : */ 18 : 19 : #include "PTN_Engine/Executor/ActionsExecutorFactory.h" 20 : #include "PTN_Engine/Executor/DetachedExecutor.h" 21 : #include "PTN_Engine/Executor/JobQueueExecutor.h" 22 : #include "PTN_Engine/Executor/SingleThreadExecutor.h" 23 : #include "PTN_Engine/PTN_Exception.h" 24 : 25 : 26 : namespace ptne 27 : { 28 : 29 : using namespace std; 30 : 31 : unique_ptr<IActionsExecutor> 32 130 : ActionsExecutorFactory::createExecutor(PTN_Engine::ACTIONS_THREAD_OPTION actionsThreadOption) 33 : { 34 130 : switch (actionsThreadOption) 35 : { 36 0 : default: 37 : { 38 0 : throw PTN_Exception("Invalid configuration"); 39 : } 40 59 : case PTN_Engine::ACTIONS_THREAD_OPTION::SINGLE_THREAD: 41 : case PTN_Engine::ACTIONS_THREAD_OPTION::EVENT_LOOP: 42 : { 43 59 : return make_unique<SingleThreadExecutor>(); 44 : } 45 61 : case PTN_Engine::ACTIONS_THREAD_OPTION::JOB_QUEUE: 46 : { 47 61 : return make_unique<JobQueueExecutor>(); 48 : } 49 10 : case PTN_Engine::ACTIONS_THREAD_OPTION::DETACHED: 50 : { 51 10 : return make_unique<DetachedExecutor>(); 52 : } 53 : } 54 : } 55 : 56 : 57 : } // namespace ptne