task_interface.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (c) 2020,
6  * TU Dortmund - Institute of Control Theory and Systems Engineering.
7  * All rights reserved.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  *
22  * Authors: Christoph Rösmann
23  *********************************************************************/
24 #ifndef SRC_TASKS_INCLUDE_CORBO_TASKS_TASK_INTERFACE_H_
25 #define SRC_TASKS_INCLUDE_CORBO_TASKS_TASK_INTERFACE_H_
26 
27 #include <corbo-core/global.h>
30 
31 #ifdef MESSAGE_SUPPORT
32 #include <corbo-communication/messages/tasks/tasks.pb.h>
33 #endif
34 
35 #include <memory>
36 #include <string>
37 
38 namespace corbo {
39 
60 class TaskInterface
61 {
62  public:
63  using Ptr = std::shared_ptr<TaskInterface>;
64 
66  virtual ~TaskInterface() {}
68  virtual Ptr getInstance() const = 0;
69 
75  virtual void performTask(Environment& environment, SignalTargetInterface* signal_target = nullptr, std::string* msg = nullptr,
76  const std::string& ns = "") = 0;
77 
92  virtual bool verify(const Environment& environment, std::string* msg = nullptr) const = 0;
93 
103  virtual void getAvailableSignals(const Environment& environment, SignalTargetInterface& signal_target, const std::string& ns = "") const {}
104 
106  virtual void reset() = 0;
107 
108 #ifdef MESSAGE_SUPPORT
109  virtual void toMessage(messages::Task& message) const {}
112  virtual void fromMessage(const messages::Task& message, std::stringstream* issues = nullptr) {}
113 #endif
114 };
115 
116 using TaskFactory = Factory<TaskInterface>;
117 #define FACTORY_REGISTER_TASK(type) FACTORY_REGISTER_OBJECT(type, TaskInterface)
118 
119 } // namespace corbo
120 
121 #endif // SRC_TASKS_INCLUDE_CORBO_TASKS_TASK_INTERFACE_H_
signal_target_interface.h
global.h
corbo::TaskInterface::performTask
virtual void performTask(Environment &environment, SignalTargetInterface *signal_target=nullptr, std::string *msg=nullptr, const std::string &ns="")=0
Perform task.
corbo::TaskInterface::Ptr
std::shared_ptr< TaskInterface > Ptr
Definition: task_interface.h:107
corbo::TaskInterface::~TaskInterface
virtual ~TaskInterface()
Virtuel destructor.
Definition: task_interface.h:110
corbo
Definition: communication/include/corbo-communication/utilities.h:37
corbo::TaskInterface::verify
virtual bool verify(const Environment &environment, std::string *msg=nullptr) const =0
Check if the environment and other settings satisfy all requirements for the given task.
corbo::TaskInterface::getInstance
virtual Ptr getInstance() const =0
Return a newly created shared instance of the implemented class.
corbo::TaskInterface::reset
virtual void reset()=0
Reset task state.
corbo::TaskFactory
Factory< TaskInterface > TaskFactory
Definition: task_interface.h:138
environment.h
corbo::TaskInterface::getAvailableSignals
virtual void getAvailableSignals(const Environment &environment, SignalTargetInterface &signal_target, const std::string &ns="") const
Retrieve available signals from the task.
Definition: task_interface.h:147


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:06:33