world_diff.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, 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 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 /* Author: Acorn Pooley, Ioan Sucan, Sachin Chitta */
36 
37 #ifndef MOVEIT_COLLISION_DETECTION_WORLD_DIFF_
38 #define MOVEIT_COLLISION_DETECTION_WORLD_DIFF_
39 
42 
43 #include <memory>
44 
45 namespace collision_detection
46 {
47 MOVEIT_CLASS_FORWARD(WorldDiff);
48 
50 class WorldDiff
51 {
52 public:
54  WorldDiff();
55 
57  WorldDiff(const WorldPtr& world);
58 
60  WorldDiff(WorldDiff& other);
61 
62  ~WorldDiff();
63 
67  void setWorld(const WorldPtr& world);
68 
71  void reset(const WorldPtr& world);
72 
74  void reset();
75 
77  const std::map<std::string, World::Action>& getChanges() const
78  {
79  return changes_;
80  }
81 
82  typedef std::map<std::string, World::Action>::const_iterator const_iterator;
84  const_iterator begin() const
85  {
86  return changes_.begin();
87  }
89  const_iterator end() const
90  {
91  return changes_.end();
92  }
94  size_t size() const
95  {
96  return changes_.size();
97  }
99  const_iterator find(const std::string& id) const
100  {
101  return changes_.find(id);
102  }
104  void set(const std::string& id, World::Action val)
105  {
106  if (val)
107  changes_[id] = val;
108  else
109  changes_.erase(id);
110  }
111 
113  void clearChanges();
114 
115 private:
117  void notify(const World::ObjectConstPtr&, World::Action);
118 
120  std::map<std::string, World::Action> changes_;
121 
122  /* observer handle for world callback */
124 
125  /* used to unregister the notifier */
126  std::weak_ptr<World> world_;
127 };
128 }
129 
130 #endif
Maintain a diff list of changes that have happened to a World.
Definition: world_diff.h:50
std::map< std::string, World::Action >::const_iterator const_iterator
Definition: world_diff.h:82
World::ObserverHandle observer_handle_
Definition: world_diff.h:123
const_iterator begin() const
Definition: world_diff.h:84
Represents an action that occurred on an object in the world. Several bits may be set indicating seve...
Definition: world.h:195
MOVEIT_CLASS_FORWARD(AllowedCollisionMatrix)
void reset()
Turn off recording and erase all previously recorded changes.
Definition: world_diff.cpp:70
const std::map< std::string, World::Action > & getChanges() const
Return all the changes that have been recorded.
Definition: world_diff.h:77
Generic interface to collision detection.
void setWorld(const WorldPtr &world)
Set which world to record. Records all objects in old world (if any) as DESTROYED and all objects in ...
Definition: world_diff.cpp:93
void clearChanges()
Clear the internally maintained vector of changes.
Definition: world_diff.cpp:108
void notify(const World::ObjectConstPtr &, World::Action)
Notification function.
Definition: world_diff.cpp:113
std::weak_ptr< World > world_
Definition: world_diff.h:126
const_iterator end() const
Definition: world_diff.h:89
std::map< std::string, World::Action > changes_
Definition: world_diff.h:120
const_iterator find(const std::string &id) const
Definition: world_diff.h:99


moveit_core
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley
autogenerated on Wed Jul 10 2019 04:03:05