00001 /* 00002 * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA) 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 00018 #ifndef MODEEXECUTOR_H 00019 #define MODEEXECUTOR_H 00020 00021 #include <mode.h> 00022 #include <iColorO.h> 00023 #include <modeFactory.h> 00024 #include <boost/thread.hpp> 00025 #include <boost/lambda/bind.hpp> 00026 #include <map> 00027 00028 class ModeExecutor 00029 { 00030 public: 00031 ModeExecutor(IColorO* colorO); 00032 ~ModeExecutor(); 00033 00034 uint64_t execute(boost::shared_ptr<Mode> mode); 00035 uint64_t execute(cob_light::LightMode requestMode); 00036 00037 int getExecutingPriority(); 00038 int getExecutingMode(); 00039 uint64_t getExecutingUId(); 00040 00041 void pause(); 00042 void resume(); 00043 void stop(); 00044 bool stop(uint64_t uId); 00045 00046 void setDefaultPriority(int priority); 00047 00048 private: 00049 IColorO* _colorO; 00050 00051 boost::shared_ptr<Mode> _activeMode; 00052 std::map<int, boost::shared_ptr<Mode>, std::greater<int> > _mapActiveModes; 00053 color::rgba _activeColor; 00054 00055 bool _stopRequested; 00056 int default_priority; 00057 00058 void onModeFinishedReceived(int prio); 00059 void onColorSetReceived(color::rgba color); 00060 }; 00061 00062 #endif