simple_client_goal_state.h
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 #ifndef ACTIONLIB__CLIENT__SIMPLE_CLIENT_GOAL_STATE_H_
36 #define ACTIONLIB__CLIENT__SIMPLE_CLIENT_GOAL_STATE_H_
37 
38 #include <string>
39 
40 namespace actionlib
41 {
42 
44 {
45 public:
47  enum StateEnum
48  {
57  };
58 
60  std::string text_;
61 
63  const std::string & text = std::string(""))
64  : state_(state), text_(text) {}
65 
66  inline bool operator==(const SimpleClientGoalState & rhs) const
67  {
68  return state_ == rhs.state_;
69  }
70 
71  inline bool operator==(const SimpleClientGoalState::StateEnum & rhs) const
72  {
73  return state_ == rhs;
74  }
75 
76  inline bool operator!=(const SimpleClientGoalState::StateEnum & rhs) const
77  {
78  return !(*this == rhs);
79  }
80 
81  inline bool operator!=(const SimpleClientGoalState & rhs) const
82  {
83  return !(*this == rhs);
84  }
85 
90  inline bool isDone() const
91  {
92  switch (state_) {
93  case RECALLED:
94  case REJECTED:
95  case PREEMPTED:
96  case ABORTED:
97  case SUCCEEDED:
98  case LOST:
99  return true;
100  default:
101  return false;
102  }
103  }
104 
105  std::string getText() const
106  {
107  return text_;
108  }
109 
111  std::string toString() const
112  {
113  switch (state_) {
114  case PENDING:
115  return "PENDING";
116  case ACTIVE:
117  return "ACTIVE";
118  case RECALLED:
119  return "RECALLED";
120  case REJECTED:
121  return "REJECTED";
122  case PREEMPTED:
123  return "PREEMPTED";
124  case ABORTED:
125  return "ABORTED";
126  case SUCCEEDED:
127  return "SUCCEEDED";
128  case LOST:
129  return "LOST";
130  default:
131  ROS_ERROR_NAMED("actionlib", "BUG: Unhandled SimpleGoalState: %u", state_);
132  break;
133  }
134  return "BUG-UNKNOWN";
135  }
136 };
137 
138 } // namespace actionlib
139 
140 #endif // ACTIONLIB__CLIENT__SIMPLE_CLIENT_GOAL_STATE_H_
bool operator==(const SimpleClientGoalState::StateEnum &rhs) const
bool isDone() const
Determine if goal is done executing (ie. reached a terminal state)
bool operator!=(const SimpleClientGoalState::StateEnum &rhs) const
std::string toString() const
Convert the state to a string. Useful when printing debugging information.
SimpleClientGoalState(const StateEnum &state, const std::string &text=std::string(""))
bool operator==(const SimpleClientGoalState &rhs) const
#define ROS_ERROR_NAMED(name,...)
bool operator!=(const SimpleClientGoalState &rhs) const
StateEnum
Defines the various states the goal can be in.


actionlib
Author(s): Eitan Marder-Eppstein, Vijay Pradeep
autogenerated on Thu May 24 2018 02:39:31