Line data Source code
1 : /* 2 : * This file is part of PTN Engine 3 : * 4 : * Copyright (c) 2017-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/PTN_Engine.h" 20 : #include "PTN_Engine/PTN_EngineImpProxy.h" 21 : 22 : namespace ptne 23 : { 24 : using namespace std; 25 : 26 56 : PTN_Engine::~PTN_Engine() = default; 27 : 28 56 : PTN_Engine::PTN_Engine(ACTIONS_THREAD_OPTION actionsRuntimeThread) 29 56 : : m_impProxy(make_unique<PTN_EngineImpProxy>(actionsRuntimeThread)) 30 : { 31 56 : } 32 : 33 1 : void PTN_Engine::setEventLoopSleepDuration(const EventLoopSleepDuration sleepDuration) 34 : { 35 1 : m_impProxy->setEventLoopSleepDuration(sleepDuration); 36 1 : } 37 : 38 2 : PTN_Engine::EventLoopSleepDuration PTN_Engine::getEventLoopSleepDuration() const 39 : { 40 2 : return m_impProxy->getEventLoopSleepDuration(); 41 : } 42 : 43 10 : void PTN_Engine::addArc(const ArcProperties &arcProperties) 44 : { 45 10 : m_impProxy->addArc(arcProperties); 46 10 : } 47 : 48 2 : void PTN_Engine::removeArc(const ArcProperties &arcProperties) 49 : { 50 2 : m_impProxy->removeArc(arcProperties); 51 1 : } 52 : 53 1 : void PTN_Engine::clearNet() 54 : { 55 1 : m_impProxy->clearNet(); 56 1 : } 57 : 58 12 : vector<PlaceProperties> PTN_Engine::getPlacesProperties() const 59 : { 60 12 : return m_impProxy->getPlacesProperties(); 61 : } 62 : 63 13 : vector<TransitionProperties> PTN_Engine::getTransitionsProperties() const 64 : { 65 13 : return m_impProxy->getTransitionsProperties(); 66 : } 67 : 68 133 : void PTN_Engine::createTransition(const TransitionProperties &transitionProperties) 69 : { 70 133 : m_impProxy->createTransition(transitionProperties); 71 130 : } 72 : 73 180 : void PTN_Engine::createPlace(const PlaceProperties &placeProperties) 74 : { 75 180 : m_impProxy->createPlace(placeProperties); 76 177 : } 77 : 78 11 : void PTN_Engine::registerAction(const string &name, const ActionFunction &action) const 79 : { 80 11 : m_impProxy->registerAction(name, action); 81 7 : } 82 : 83 12 : void PTN_Engine::registerCondition(const string &name, const ConditionFunction &condition) const 84 : { 85 12 : m_impProxy->registerCondition(name, condition); 86 10 : } 87 : 88 38 : void PTN_Engine::execute(const bool log, ostream &o) 89 : { 90 38 : m_impProxy->execute(log, o); 91 38 : } 92 : 93 179 : size_t PTN_Engine::getNumberOfTokens(const string &place) const 94 : { 95 179 : return m_impProxy->getNumberOfTokens(place); 96 : } 97 : 98 2468 : void PTN_Engine::incrementInputPlace(const string &place) 99 : { 100 2468 : m_impProxy->incrementInputPlace(place); 101 2467 : } 102 : 103 0 : void PTN_Engine::printState(ostream &o) const 104 : { 105 0 : m_impProxy->printState(o); 106 0 : } 107 : 108 7 : void PTN_Engine::setActionsThreadOption(const ACTIONS_THREAD_OPTION actionsThreadOption) 109 : { 110 7 : m_impProxy->setActionsThreadOption(actionsThreadOption); 111 3 : } 112 : 113 4 : PTN_Engine::ACTIONS_THREAD_OPTION PTN_Engine::getActionsThreadOption() const 114 : { 115 4 : return m_impProxy->getActionsThreadOption(); 116 : } 117 : 118 12 : bool PTN_Engine::isEventLoopRunning() const 119 : { 120 12 : return m_impProxy->isEventLoopRunning(); 121 : } 122 : 123 41 : void PTN_Engine::stop() 124 : { 125 41 : m_impProxy->stop(); 126 41 : } 127 : 128 : } // namespace ptne