This file is indexed.

/usr/include/actionlib/client/client_helpers.h is in libactionlib-dev 1.11.7-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/*********************************************************************
* Software License Agreement (BSD License)
*
*  Copyright (c) 2008, Willow Garage, Inc.
*  All rights reserved.
*
*  Redistribution and use in source and binary forms, with or without
*  modification, are permitted provided that the following conditions
*  are met:
*
*   * Redistributions of source code must retain the above copyright
*     notice, this list of conditions and the following disclaimer.
*   * Redistributions in binary form must reproduce the above
*     copyright notice, this list of conditions and the following
*     disclaimer in the documentation and/or other materials provided
*     with the distribution.
*   * Neither the name of the Willow Garage nor the names of its
*     contributors may be used to endorse or promote products derived
*     from this software without specific prior written permission.
*
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
*  POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/

#ifndef ACTIONLIB_GOAL_MANAGER_H_
#define ACTIONLIB_GOAL_MANAGER_H_

#include <boost/thread/recursive_mutex.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>


#include "actionlib/action_definition.h"

#include "actionlib/managed_list.h"
#include "actionlib/enclosure_deleter.h"
#include "actionlib/goal_id_generator.h"

#include "actionlib/client/comm_state.h"
#include "actionlib/client/terminal_state.h"

#include "actionlib/destruction_guard.h"

// msgs
#include "actionlib_msgs/GoalID.h"
#include "actionlib_msgs/GoalStatusArray.h"

namespace actionlib
{

template <class ActionSpec>
class ClientGoalHandle;

template <class ActionSpec>
class CommStateMachine;

template <class ActionSpec>
class GoalManager
{
public:
  ACTION_DEFINITION(ActionSpec);
  typedef GoalManager<ActionSpec> GoalManagerT;
  typedef ClientGoalHandle<ActionSpec> GoalHandleT;
  typedef boost::function<void (GoalHandleT) > TransitionCallback;
  typedef boost::function<void (GoalHandleT, const FeedbackConstPtr&) > FeedbackCallback;
  typedef boost::function<void (const ActionGoalConstPtr)> SendGoalFunc;
  typedef boost::function<void (const actionlib_msgs::GoalID&)> CancelFunc;

  GoalManager(const boost::shared_ptr<DestructionGuard>& guard) : guard_(guard) { }

  void registerSendGoalFunc(SendGoalFunc send_goal_func);
  void registerCancelFunc(CancelFunc cancel_func);

  GoalHandleT initGoal( const Goal& goal,
                        TransitionCallback transition_cb = TransitionCallback(),
                        FeedbackCallback feedback_cb = FeedbackCallback() );

  void updateStatuses(const actionlib_msgs::GoalStatusArrayConstPtr& status_array);
  void updateFeedbacks(const ActionFeedbackConstPtr& action_feedback);
  void updateResults(const ActionResultConstPtr& action_result);

  friend class ClientGoalHandle<ActionSpec>;

  // should be private
  typedef ManagedList< boost::shared_ptr<CommStateMachine<ActionSpec> > > ManagedListT;
  ManagedListT list_;
private:
  SendGoalFunc send_goal_func_ ;
  CancelFunc cancel_func_ ;

  boost::shared_ptr<DestructionGuard> guard_;

  boost::recursive_mutex list_mutex_;

  GoalIDGenerator id_generator_;

  void listElemDeleter(typename ManagedListT::iterator it);
};

/**
 * \brief Client side handle to monitor goal progress
 *
 * A ClientGoalHandle is a reference counted object that is used to manipulate and monitor the progress
 * of an already dispatched goal. Once all the goal handles go out of scope (or are reset), an
 * ActionClient stops maintaining state for that goal.
 */
template <class ActionSpec>
class ClientGoalHandle
{
private:
  ACTION_DEFINITION(ActionSpec);

public:
  /**
   * \brief Create an empty goal handle
   *
   * Constructs a goal handle that doesn't track any goal. Calling any method on an empty goal
   * handle other than operator= will trigger an assertion.
   */
  ClientGoalHandle();

  ~ClientGoalHandle();

  /**
   * \brief Stops goal handle from tracking a goal
   *
   * Useful if you want to stop tracking the progress of a goal, but it is inconvenient to force
   * the goal handle to go out of scope. Has pretty much the same semantics as boost::shared_ptr::reset()
   */
  void reset();

  /**
   * \brief Checks if this goal handle is tracking a goal
   *
   * Has pretty much the same semantics as boost::shared_ptr::expired()
   * \return True if this goal handle is not tracking a goal
   */
  inline bool isExpired() const;

  /**
   * \brief Get the state of this goal's communication state machine from interaction with the server
   *
   * Possible States are: WAITING_FOR_GOAL_ACK, PENDING, ACTIVE, WAITING_FOR_RESULT,
   *                      WAITING_FOR_CANCEL_ACK, RECALLING, PREEMPTING, DONE
   * \return The current goal's communication state with the server
   */
  CommState getCommState() const;

  /**
   * \brief Get the terminal state information for this goal
   *
   * Possible States Are: RECALLED, REJECTED, PREEMPTED, ABORTED, SUCCEEDED, LOST
   * This call only makes sense if CommState==DONE. This will send ROS_WARNs if we're not in DONE
   * \return The terminal state
   */
  TerminalState getTerminalState() const;

  /**
   * \brief Get result associated with this goal
   *
   * \return NULL if no reseult received.  Otherwise returns shared_ptr to result.
   */
  ResultConstPtr getResult() const;

  /**
   * \brief Resends this goal [with the same GoalID] to the ActionServer
   *
   * Useful if the user thinks that the goal may have gotten lost in transit
   */
  void resend();

  /**
   * \brief Sends a cancel message for this specific goal to the ActionServer
   *
   * Also transitions the Communication State Machine to WAITING_FOR_CANCEL_ACK
   */
  void cancel();

  /**
   * \brief Check if two goal handles point to the same goal
   * \return TRUE if both point to the same goal. Also returns TRUE if both handles are inactive.
   */
  bool operator==(const ClientGoalHandle<ActionSpec>& rhs) const;

  /**
   * \brief !(operator==())
   */
  bool operator!=(const ClientGoalHandle<ActionSpec>& rhs) const;

  friend class GoalManager<ActionSpec>;
private:
  typedef GoalManager<ActionSpec> GoalManagerT;
  typedef ManagedList< boost::shared_ptr<CommStateMachine<ActionSpec> > > ManagedListT;

  ClientGoalHandle(GoalManagerT* gm, typename ManagedListT::Handle handle, const boost::shared_ptr<DestructionGuard>& guard);

  GoalManagerT* gm_;
  bool active_;
  //typename ManagedListT::iterator it_;
  boost::shared_ptr<DestructionGuard> guard_;   // Guard must still exist when the list_handle_ is destroyed
  typename ManagedListT::Handle list_handle_;
};

template <class ActionSpec>
class CommStateMachine
{
  private:
    //generates typedefs that we'll use to make our lives easier
    ACTION_DEFINITION(ActionSpec);

  public:
    typedef boost::function<void (const ClientGoalHandle<ActionSpec>&) > TransitionCallback;
    typedef boost::function<void (const ClientGoalHandle<ActionSpec>&, const FeedbackConstPtr&) > FeedbackCallback;
    typedef ClientGoalHandle<ActionSpec> GoalHandleT;

    CommStateMachine(const ActionGoalConstPtr& action_goal,
                     TransitionCallback transition_callback,
                     FeedbackCallback feedback_callback);

    ActionGoalConstPtr getActionGoal() const;
    CommState getCommState() const;
    actionlib_msgs::GoalStatus getGoalStatus() const;
    ResultConstPtr getResult() const;

    // Transitions caused by messages
    void updateStatus(GoalHandleT& gh, const actionlib_msgs::GoalStatusArrayConstPtr& status_array);
    void updateFeedback(GoalHandleT& gh, const ActionFeedbackConstPtr& feedback);
    void updateResult(GoalHandleT& gh, const ActionResultConstPtr& result);

    // Forced transitions
    void transitionToState(GoalHandleT& gh, const CommState::StateEnum& next_state);
    void transitionToState(GoalHandleT& gh, const CommState& next_state);
    void processLost(GoalHandleT& gh);
  private:
    CommStateMachine();

    // State
    CommState state_;
    ActionGoalConstPtr action_goal_;
    actionlib_msgs::GoalStatus latest_goal_status_;
    ActionResultConstPtr latest_result_;

    // Callbacks
    TransitionCallback transition_cb_;
    FeedbackCallback   feedback_cb_;

    // **** Implementation ****
    //! Change the state, as well as print out ROS_DEBUG info
    void setCommState(const CommState& state);
    void setCommState(const CommState::StateEnum& state);
    const actionlib_msgs::GoalStatus* findGoalStatus(const std::vector<actionlib_msgs::GoalStatus>& status_vec) const;
};

}

#include "actionlib/client/goal_manager_imp.h"
#include "actionlib/client/client_goal_handle_imp.h"
#include "actionlib/client/comm_state_machine_imp.h"

#endif // ACTIONLIB_GOAL_MANAGER_H_