trajectory_generation_exceptions.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Pilz GmbH & Co. KG
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13 
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef TRAJECTORY_GENERATION_EXCEPTIONS_H
19 #define TRAJECTORY_GENERATION_EXCEPTIONS_H
20 
21 #include <stdexcept>
22 #include <string>
23 
24 #include <moveit_msgs/MoveItErrorCodes.h>
25 
27 {
28 
32 class MoveItErrorCodeException : public std::runtime_error
33 {
34 public:
35  MoveItErrorCodeException(const std::string& msg);
36 
37 protected:
40  ~MoveItErrorCodeException() = default;
41 
44 
45 public:
46  virtual const moveit_msgs::MoveItErrorCodes::_val_type& getErrorCode() const = 0;
47 };
48 
49 template <moveit_msgs::MoveItErrorCodes::_val_type ERROR_CODE = moveit_msgs::MoveItErrorCodes::FAILURE>
51 {
52 public:
53  TemplatedMoveItErrorCodeException(const std::string& msg);
54  TemplatedMoveItErrorCodeException(const std::string& msg,
55  const moveit_msgs::MoveItErrorCodes::_val_type& error_code);
56 
57 public:
58  virtual const moveit_msgs::MoveItErrorCodes::_val_type& getErrorCode() const override;
59 
60 private:
61  const moveit_msgs::MoveItErrorCodes::_val_type error_code_ {ERROR_CODE};
62 };
63 
64 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
66  : std::runtime_error(msg)
67 {}
68 
69 template <moveit_msgs::MoveItErrorCodes::_val_type ERROR_CODE>
72 {}
73 
74 template <moveit_msgs::MoveItErrorCodes::_val_type ERROR_CODE>
76  const moveit_msgs::MoveItErrorCodes::_val_type& error_code)
78  , error_code_(error_code)
79 {}
80 
81 template <moveit_msgs::MoveItErrorCodes::_val_type ERROR_CODE>
82 inline const moveit_msgs::MoveItErrorCodes::_val_type& TemplatedMoveItErrorCodeException<ERROR_CODE>::getErrorCode() const
83 {
84  return error_code_;
85 }
86 
87 /*
88  * @brief Macro to automatically generate a derived class of
89  * the MoveItErrorCodeException class.
90  */
91 #define CREATE_MOVEIT_ERROR_CODE_EXCEPTION(EXCEPTION_CLASS_NAME, ERROR_CODE) \
92 class EXCEPTION_CLASS_NAME : public TemplatedMoveItErrorCodeException<ERROR_CODE> \
93 { \
94 public: \
95  EXCEPTION_CLASS_NAME(const std::string& msg) \
96  : TemplatedMoveItErrorCodeException(msg) \
97  {} \
98 \
99  EXCEPTION_CLASS_NAME(const std::string& msg, const moveit_msgs::MoveItErrorCodes::_val_type& error_code) \
100  : TemplatedMoveItErrorCodeException(msg, error_code) \
101  {} \
102 }
103 
104 }
105 
106 #endif // TRAJECTORY_GENERATION_EXCEPTIONS_H
virtual const moveit_msgs::MoveItErrorCodes::_val_type & getErrorCode() const =0
MoveItErrorCodeException & operator=(const MoveItErrorCodeException &)=default
virtual const moveit_msgs::MoveItErrorCodes::_val_type & getErrorCode() const override
Exception storing an moveit_msgs::MoveItErrorCodes value.


pilz_trajectory_generation
Author(s):
autogenerated on Mon Apr 6 2020 03:17:33