Events.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _EVENTS_HH_
18 #define _EVENTS_HH_
19 
20 #include <string>
21 #include <sdf/sdf.hh>
22 
23 #include "gazebo/common/Console.hh"
25 #include "gazebo/common/Event.hh"
26 #include "gazebo/util/system.hh"
27 
28 namespace gazebo
29 {
30  namespace event
31  {
34 
37  class GZ_COMMON_VISIBLE Events
38  {
43  public: template<typename T>
44  static ConnectionPtr ConnectPause(T _subscriber)
45  { return pause.Connect(_subscriber); }
46 
50  public: static void DisconnectPause(ConnectionPtr _subscriber)
52  { pause.Disconnect(_subscriber->Id()); }
53 
58  public: template<typename T>
59  static ConnectionPtr ConnectStep(T _subscriber)
60  { return step.Connect(_subscriber); }
64  public: static void DisconnectStep(ConnectionPtr _subscriber)
66  { step.Disconnect(_subscriber->Id()); }
67 
72  public: template<typename T>
73  static ConnectionPtr ConnectStop(T _subscriber)
74  { return stop.Connect(_subscriber); }
78  public: static void DisconnectStop(ConnectionPtr _subscriber)
80  { stop.Disconnect(_subscriber->Id()); }
81 
86  public: template<typename T>
87  static ConnectionPtr ConnectWorldCreated(T _subscriber)
88  { return worldCreated.Connect(_subscriber); }
91  public: static void DisconnectWorldCreated(ConnectionPtr _subscriber)
93  { worldCreated.Disconnect(_subscriber->Id()); }
94 
99  public: template<typename T>
100  static ConnectionPtr ConnectCreateEntity(T _subscriber)
101  { return entityCreated.Connect(_subscriber); }
105  public: static void DisconnectCreateEntity(ConnectionPtr _subscriber)
106  GAZEBO_DEPRECATED(8.0)
107  { entityCreated.Disconnect(_subscriber->Id()); }
108 
113  public: template<typename T>
115  { return setSelectedEntity.Connect(_subscriber); }
119  public: static void DisconnectSetSelectedEntity(ConnectionPtr _subscriber)
120  GAZEBO_DEPRECATED(8.0)
121  { setSelectedEntity.Disconnect(_subscriber->Id()); }
126  public: template<typename T>
127  static ConnectionPtr ConnectDeleteEntity(T _subscriber)
128  { return deleteEntity.Connect(_subscriber); }
132  public: static void DisconnectDeleteEntity(ConnectionPtr _subscriber)
133  GAZEBO_DEPRECATED(8.0)
134  { deleteEntity.Disconnect(_subscriber->Id()); }
139  public: template<typename T>
140  static ConnectionPtr ConnectAddEntity(T _subscriber)
141  { return addEntity.Connect(_subscriber); }
145  public: static void DisconnectAddEntity(ConnectionPtr _subscriber)
146  GAZEBO_DEPRECATED(8.0)
147  { addEntity.Disconnect(_subscriber->Id()); }
148 
153  public: template<typename T>
155  { return worldUpdateBegin.Connect(_subscriber); }
156 
160  public: static void DisconnectWorldUpdateBegin(
161  ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0);
162 
171  public: template<typename T>
173  { return beforePhysicsUpdate.Connect(_subscriber); }
174 
178  public: static void DisconnectBeforePhysicsUpdate(
179  ConnectionPtr _subscriber)
180  GAZEBO_DEPRECATED(8.0)
181  { beforePhysicsUpdate.Disconnect(_subscriber->Id()); }
182 
187  public: template<typename T>
188  static ConnectionPtr ConnectWorldUpdateEnd(T _subscriber)
189  { return worldUpdateEnd.Connect(_subscriber); }
193  public: static void DisconnectWorldUpdateEnd(ConnectionPtr _subscriber)
194  GAZEBO_DEPRECATED(8.0)
195  { worldUpdateEnd.Disconnect(_subscriber->Id()); }
196 
201  public: template<typename T>
202  static ConnectionPtr ConnectWorldReset(T _subscriber)
203  { return worldReset.Connect(_subscriber); }
204 
208  public: static void DisconnectWorldReset(ConnectionPtr _subscriber)
209  GAZEBO_DEPRECATED(8.0)
210  { worldReset.Disconnect(_subscriber->Id()); }
211 
216  public: template<typename T>
217  static ConnectionPtr ConnectTimeReset(T _subscriber)
218  { return timeReset.Connect(_subscriber); }
219 
223  public: static void DisconnectTimeReset(ConnectionPtr _subscriber)
224  GAZEBO_DEPRECATED(8.0)
225  { timeReset.Disconnect(_subscriber->Id()); }
226 
231  public: template<typename T>
232  static ConnectionPtr ConnectRemoveSensor(T _subscriber)
233  { return removeSensor.Connect(_subscriber); }
234 
238  public: static void DisconnectRemoveSensor(ConnectionPtr _subscriber)
239  GAZEBO_DEPRECATED(8.0)
240  { removeSensor.Disconnect(_subscriber->Id()); }
241 
246  public: template<typename T>
247  static ConnectionPtr ConnectCreateSensor(T _subscriber)
248  { return createSensor.Connect(_subscriber); }
249 
253  public: static void DisconnectCreateSensor(ConnectionPtr _subscriber)
254  GAZEBO_DEPRECATED(8.0)
255  { createSensor.Disconnect(_subscriber->Id()); }
256 
261  public: template<typename T>
262  static ConnectionPtr ConnectPreRender(T _subscriber)
263  { return preRender.Connect(_subscriber); }
267  public: static void DisconnectPreRender(ConnectionPtr _subscriber)
268  GAZEBO_DEPRECATED(8.0)
269  { preRender.Disconnect(_subscriber->Id()); }
274  public: template<typename T>
275  static ConnectionPtr ConnectRender(T _subscriber)
276  { return render.Connect(_subscriber); }
280  public: static void DisconnectRender(ConnectionPtr _subscriber)
281  GAZEBO_DEPRECATED(8.0)
282  { render.Disconnect(_subscriber->Id()); }
287  public: template<typename T>
288  static ConnectionPtr ConnectPostRender(T _subscriber)
289  { return postRender.Connect(_subscriber); }
293  public: static void DisconnectPostRender(ConnectionPtr _subscriber)
294  GAZEBO_DEPRECATED(8.0)
295  { postRender.Disconnect(_subscriber->Id()); }
300  public: template<typename T>
301  static ConnectionPtr ConnectDiagTimerStart(T _subscriber)
302  { return diagTimerStart.Connect(_subscriber); }
306  public: static void DisconnectDiagTimerStart(ConnectionPtr _subscriber)
307  GAZEBO_DEPRECATED(8.0)
308  { diagTimerStart.Disconnect(_subscriber->Id()); }
309 
314  public: template<typename T>
315  static ConnectionPtr ConnectDiagTimerStop(T _subscriber)
316  { return diagTimerStop.Connect(_subscriber); }
320  public: static void DisconnectDiagTimerStop(ConnectionPtr _subscriber)
321  GAZEBO_DEPRECATED(8.0)
322  { diagTimerStop.Disconnect(_subscriber->Id()); }
323 
328  public: template<typename T>
329  static ConnectionPtr ConnectSigInt(T _subscriber)
330  { return sigInt.Connect(_subscriber); }
334  public: static void DisconnectSigInt(ConnectionPtr _subscriber)
335  GAZEBO_DEPRECATED(8.0)
336  { sigInt.Disconnect(_subscriber->Id()); }
337 
339  public: static EventT<void (bool)> pause;
340 
342  public: static EventT<void ()> step;
343 
345  public: static EventT<void ()> stop;
346 
348  public: static EventT<void ()> sigInt;
349 
352 
355 
358 
361 
364 
367 
371 
374 
376  public: static EventT<void ()> worldReset;
377 
379  public: static EventT<void ()> timeReset;
380 
382  public: static EventT<void ()> preRender;
383 
385  public: static EventT<void ()> render;
386 
388  public: static EventT<void ()> postRender;
389 
392 
395 
400 
409  public: static EventT<void (sdf::ElementPtr,
410  const std::string &,
411  const std::string &,
412  const uint32_t)> createSensor;
413  };
415  }
416 }
417 #endif
static void DisconnectPause(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the pause signal.
Definition: Events.hh:50
static ConnectionPtr ConnectSigInt(T _subscriber)
Connect a callback to the sigint event.
Definition: Events.hh:329
static EventT< void(std::string, std::string)> setSelectedEntity
An entity has been selected.
Definition: Events.hh:357
static ConnectionPtr ConnectBeforePhysicsUpdate(T _subscriber)
Connect a callback to the before physics update signal.
Definition: Events.hh:172
static void DisconnectDeleteEntity(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the delete entity signal.
Definition: Events.hh:132
static void DisconnectRemoveSensor(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect from the remove sensor signal.
Definition: Events.hh:238
static ConnectionPtr ConnectStop(T _subscriber)
Connect a callback to the stop signal.
Definition: Events.hh:73
static void DisconnectSigInt(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the sigint event.
Definition: Events.hh:334
An Event class to get notifications for simulator events.
Definition: Events.hh:37
static void DisconnectDiagTimerStart(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the diagnostic timer start signal.
Definition: Events.hh:306
static void DisconnectRender(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the render update signal.
Definition: Events.hh:280
static ConnectionPtr ConnectWorldUpdateBegin(T _subscriber)
Connect a callback to the world update start signal.
Definition: Events.hh:154
static void DisconnectAddEntity(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the add entity signal.
Definition: Events.hh:145
static void DisconnectPostRender(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the post render update signal.
Definition: Events.hh:293
static void DisconnectPreRender(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a render start signal.
Definition: Events.hh:267
static ConnectionPtr ConnectCreateSensor(T _subscriber)
Connect to the create sensor signal.
Definition: Events.hh:247
static ConnectionPtr ConnectTimeReset(T _subscriber)
Connect to the time reset signal.
Definition: Events.hh:217
static void DisconnectSetSelectedEntity(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the set selected entity signal.
Definition: Events.hh:119
static ConnectionPtr ConnectWorldReset(T _subscriber)
Connect to the world reset signal.
Definition: Events.hh:202
static EventT< void()> worldUpdateEnd
World update has ended.
Definition: Events.hh:373
static EventT< void(const common::UpdateInfo &)> worldUpdateBegin
World update has started.
Definition: Events.hh:366
static EventT< void(const common::UpdateInfo &)> beforePhysicsUpdate
Collision detection has been done, physics update not yet.
Definition: Events.hh:370
static void DisconnectWorldReset(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect from the world reset signal.
Definition: Events.hh:208
static ConnectionPtr ConnectWorldUpdateEnd(T _subscriber)
Connect a callback to the world update end signal.
Definition: Events.hh:188
static ConnectionPtr ConnectPreRender(T _subscriber)
Render start signal.
Definition: Events.hh:262
static EventT< void()> timeReset
Time reset signal.
Definition: Events.hh:379
static EventT< void(std::string)> diagTimerStart
Diagnostic timer start.
Definition: Events.hh:391
static ConnectionPtr ConnectRemoveSensor(T _subscriber)
Connect to the remove sensor signal.
Definition: Events.hh:232
static ConnectionPtr ConnectPause(T _subscriber)
Connect a callback to the pause signal.
Definition: Events.hh:44
static ConnectionPtr ConnectDiagTimerStop(T _subscriber)
Connect a callback to the diagnostic timer stop signal.
Definition: Events.hh:315
static EventT< void(std::string)> deleteEntity
An entity has been deleted.
Definition: Events.hh:363
static ConnectionPtr ConnectRender(T _subscriber)
Connect a callback to the render update signal.
Definition: Events.hh:275
static EventT< void(bool)> pause
Pause signal.
Definition: Events.hh:339
static ConnectionPtr ConnectDiagTimerStart(T _subscriber)
Connect a callback to the diagnostic timer start signal.
Definition: Events.hh:301
static EventT< void(sdf::ElementPtr, const std::string &, const std::string &, const uint32_t)> createSensor
Create a sensor.
Definition: Events.hh:412
static EventT< void()> preRender
Pre-render.
Definition: Events.hh:382
static EventT< void()> stop
Simulation stop signal.
Definition: Events.hh:345
static EventT< void(std::string)> addEntity
An entity has been added.
Definition: Events.hh:360
static EventT< void()> sigInt
Simulation stop signal.
Definition: Events.hh:348
static ConnectionPtr ConnectPostRender(T _subscriber)
Connect a callback to the post render update signal.
Definition: Events.hh:288
static void DisconnectWorldUpdateEnd(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the world update end signal.
Definition: Events.hh:193
static void DisconnectStep(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the step signal.
Definition: Events.hh:64
static ConnectionPtr ConnectWorldCreated(T _subscriber)
Connect a callback to the world created signal.
Definition: Events.hh:87
static void DisconnectWorldCreated(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the world created signal.
Definition: Events.hh:91
static void DisconnectBeforePhysicsUpdate(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the before physics update signal.
Definition: Events.hh:178
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
static EventT< void()> render
Render.
Definition: Events.hh:385
static void DisconnectTimeReset(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect from the time reset signal.
Definition: Events.hh:223
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:302
static EventT< void()> step
Step the simulation once signal.
Definition: Events.hh:342
static EventT< void(std::string)> entityCreated
An entity has been created.
Definition: Events.hh:354
static ConnectionPtr ConnectDeleteEntity(T _subscriber)
Connect a callback to the delete entity signal.
Definition: Events.hh:127
static ConnectionPtr ConnectSetSelectedEntity(T _subscriber)
Connect a callback to the set selected entity signal.
Definition: Events.hh:114
static void DisconnectDiagTimerStop(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the diagnostic timer stop signal.
Definition: Events.hh:320
static ConnectionPtr ConnectAddEntity(T _subscriber)
Connect a callback to the add entity signal.
Definition: Events.hh:140
static EventT< void()> worldReset
World reset signal.
Definition: Events.hh:376
static EventT< void(std::string)> removeSensor
Remove a sensor.
Definition: Events.hh:399
static void DisconnectStop(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the stop signal.
Definition: Events.hh:78
static EventT< void(std::string)> diagTimerStop
Diagnostic timer stop.
Definition: Events.hh:394
static void DisconnectCreateSensor(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect from the create sensor signal.
Definition: Events.hh:253
static ConnectionPtr ConnectStep(T _subscriber)
Connect a callback to the step signal.
Definition: Events.hh:59
static EventT< void(std::string)> worldCreated
A world has been created.
Definition: Events.hh:351
static ConnectionPtr ConnectCreateEntity(T _subscriber)
Connect a callback to the add entity signal.
Definition: Events.hh:100
static void DisconnectCreateEntity(ConnectionPtr _subscriber) GAZEBO_DEPRECATED(8.0)
Disconnect a callback from the add entity signal.
Definition: Events.hh:105
static EventT< void()> postRender
Post-Render.
Definition: Events.hh:388