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 #pragma once
38 
41 
42 namespace collision_detection
43 {
44 MOVEIT_CLASS_FORWARD(WorldDiff); // Defines WorldDiffPtr, ConstPtr, WeakPtr... etc
45 
47 class WorldDiff
48 {
49 public:
51  WorldDiff();
52 
54  WorldDiff(const WorldPtr& world);
55 
57  WorldDiff(WorldDiff& other);
58 
59  ~WorldDiff();
60 
64  void setWorld(const WorldPtr& world);
65 
68  void reset(const WorldPtr& world);
69 
71  void reset();
72 
74  const std::map<std::string, World::Action>& getChanges() const
75  {
76  return changes_;
77  }
78 
79  using const_iterator = std::map<std::string, World::Action>::const_iterator;
81  const_iterator begin() const
82  {
83  return changes_.begin();
84  }
86  const_iterator end() const
87  {
88  return changes_.end();
89  }
91  size_t size() const
92  {
93  return changes_.size();
94  }
96  const_iterator find(const std::string& id) const
97  {
98  return changes_.find(id);
99  }
101  void set(const std::string& id, World::Action val)
102  {
103  if (val)
104  changes_[id] = val;
105  else
106  changes_.erase(id);
107  }
108 
110  void clearChanges();
111 
112 private:
114  void notify(const World::ObjectConstPtr& /*obj*/, World::Action /*action*/);
115 
117  std::map<std::string, World::Action> changes_;
118 
119  /* observer handle for world callback */
121 
122  /* used to unregister the notifier */
123  WorldWeakPtr world_;
124 };
125 } // namespace collision_detection
collision_detection::WorldDiff::WorldDiff
WorldDiff()
Constructor.
Definition: world_diff.cpp:81
collision_detection::WorldDiff::clearChanges
void clearChanges()
Clear the internally maintained vector of changes.
Definition: world_diff.cpp:144
collision_detection::WorldDiff::begin
const_iterator begin() const
Definition: world_diff.h:113
collision_detection::WorldDiff::changes_
std::map< std::string, World::Action > changes_
Definition: world_diff.h:149
collision_detection::MOVEIT_CLASS_FORWARD
MOVEIT_CLASS_FORWARD(AllowedCollisionMatrix)
collision_detection::WorldDiff::setWorld
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:128
world.h
collision_detection::WorldDiff::end
const_iterator end() const
Definition: world_diff.h:118
collision_detection::World::Action
Represents an action that occurred on an object in the world. Several bits may be set indicating seve...
Definition: world.h:268
collision_detection::World::ObserverHandle
Definition: world.h:290
class_forward.h
collision_detection::WorldDiff::~WorldDiff
~WorldDiff()
Definition: world_diff.cpp:74
collision_detection::WorldDiff::size
size_t size() const
Definition: world_diff.h:123
collision_detection::WorldDiff::const_iterator
std::map< std::string, World::Action >::const_iterator const_iterator
Definition: world_diff.h:111
collision_detection::WorldDiff::notify
void notify(const World::ObjectConstPtr &, World::Action)
Notification function.
Definition: world_diff.cpp:149
collision_detection::WorldDiff::find
const_iterator find(const std::string &id) const
Definition: world_diff.h:128
collision_detection::WorldDiff::reset
void reset()
Turn off recording and erase all previously recorded changes.
Definition: world_diff.cpp:104
collision_detection::WorldDiff::world_
WorldWeakPtr world_
Definition: world_diff.h:155
collision_detection::WorldDiff::getChanges
const std::map< std::string, World::Action > & getChanges() const
Return all the changes that have been recorded.
Definition: world_diff.h:106
collision_detection::WorldDiff::observer_handle_
World::ObserverHandle observer_handle_
Definition: world_diff.h:152
collision_detection::WorldDiff::set
void set(const std::string &id, World::Action val)
Definition: world_diff.h:133
collision_detection
Definition: collision_detector_allocator_allvalid.h:42


moveit_core
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley
autogenerated on Sat Dec 21 2024 03:23:42