Events.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 
49  public: static void DisconnectPause(ConnectionPtr _subscriber)
50  { pause.Disconnect(_subscriber); }
51 
56  public: template<typename T>
57  static ConnectionPtr ConnectStep(T _subscriber)
58  { return step.Connect(_subscriber); }
61  public: static void DisconnectStep(ConnectionPtr _subscriber)
62  { step.Disconnect(_subscriber); }
63 
68  public: template<typename T>
69  static ConnectionPtr ConnectStop(T _subscriber)
70  { return stop.Connect(_subscriber); }
73  public: static void DisconnectStop(ConnectionPtr _subscriber)
74  { stop.Disconnect(_subscriber); }
75 
80  public: template<typename T>
81  static ConnectionPtr ConnectWorldCreated(T _subscriber)
82  { return worldCreated.Connect(_subscriber); }
84  public: static void DisconnectWorldCreated(ConnectionPtr _subscriber)
85  { worldCreated.Disconnect(_subscriber); }
86 
91  public: template<typename T>
92  static ConnectionPtr ConnectCreateEntity(T _subscriber)
93  { return entityCreated.Connect(_subscriber); }
96  public: static void DisconnectCreateEntity(ConnectionPtr _subscriber)
97  { entityCreated.Disconnect(_subscriber); }
98 
103  public: template<typename T>
105  { return setSelectedEntity.Connect(_subscriber); }
108  public: static void DisconnectSetSelectedEntity(ConnectionPtr _subscriber)
109  { setSelectedEntity.Disconnect(_subscriber); }
114  public: template<typename T>
115  static ConnectionPtr ConnectDeleteEntity(T _subscriber)
116  { return deleteEntity.Connect(_subscriber); }
119  public: static void DisconnectDeleteEntity(ConnectionPtr _subscriber)
120  { deleteEntity.Disconnect(_subscriber); }
125  public: template<typename T>
126  static ConnectionPtr ConnectAddEntity(T _subscriber)
127  { return addEntity.Connect(_subscriber); }
130  public: static void DisconnectAddEntity(ConnectionPtr _subscriber)
131  { addEntity.Disconnect(_subscriber); }
132 
137  public: template<typename T>
139  { return worldUpdateBegin.Connect(_subscriber); }
140 
143  public: static void DisconnectWorldUpdateBegin(
144  ConnectionPtr _subscriber);
145 
154  public: template<typename T>
156  { return beforePhysicsUpdate.Connect(_subscriber); }
157 
160  public: static void DisconnectBeforePhysicsUpdate(
161  ConnectionPtr _subscriber)
162  { beforePhysicsUpdate.Disconnect(_subscriber); }
163 
168  public: template<typename T>
169  static ConnectionPtr ConnectWorldUpdateEnd(T _subscriber)
170  { return worldUpdateEnd.Connect(_subscriber); }
173  public: static void DisconnectWorldUpdateEnd(ConnectionPtr _subscriber)
174  { worldUpdateEnd.Disconnect(_subscriber); }
175 
180  public: template<typename T>
181  static ConnectionPtr ConnectWorldReset(T _subscriber)
182  { return worldReset.Connect(_subscriber); }
183 
186  public: static void DisconnectWorldReset(ConnectionPtr _subscriber)
187  { worldReset.Disconnect(_subscriber); }
188 
193  public: template<typename T>
194  static ConnectionPtr ConnectTimeReset(T _subscriber)
195  { return timeReset.Connect(_subscriber); }
196 
199  public: static void DisconnectTimeReset(ConnectionPtr _subscriber)
200  { timeReset.Disconnect(_subscriber); }
201 
206  public: template<typename T>
207  static ConnectionPtr ConnectRemoveSensor(T _subscriber)
208  { return removeSensor.Connect(_subscriber); }
209 
212  public: static void DisconnectRemoveSensor(ConnectionPtr _subscriber)
213  { removeSensor.Disconnect(_subscriber); }
214 
219  public: template<typename T>
220  static ConnectionPtr ConnectCreateSensor(T _subscriber)
221  { return createSensor.Connect(_subscriber); }
222 
225  public: static void DisconnectCreateSensor(ConnectionPtr _subscriber)
226  { createSensor.Disconnect(_subscriber); }
227 
232  public: template<typename T>
233  static ConnectionPtr ConnectPreRender(T _subscriber)
234  { return preRender.Connect(_subscriber); }
237  public: static void DisconnectPreRender(ConnectionPtr _subscriber)
238  { preRender.Disconnect(_subscriber); }
243  public: template<typename T>
244  static ConnectionPtr ConnectRender(T _subscriber)
245  { return render.Connect(_subscriber); }
248  public: static void DisconnectRender(ConnectionPtr _subscriber)
249  { render.Disconnect(_subscriber); }
254  public: template<typename T>
255  static ConnectionPtr ConnectPostRender(T _subscriber)
256  { return postRender.Connect(_subscriber); }
259  public: static void DisconnectPostRender(ConnectionPtr _subscriber)
260  { postRender.Disconnect(_subscriber); }
265  public: template<typename T>
266  static ConnectionPtr ConnectDiagTimerStart(T _subscriber)
267  { return diagTimerStart.Connect(_subscriber); }
270  public: static void DisconnectDiagTimerStart(ConnectionPtr _subscriber)
271  { diagTimerStart.Disconnect(_subscriber); }
272 
277  public: template<typename T>
278  static ConnectionPtr ConnectDiagTimerStop(T _subscriber)
279  { return diagTimerStop.Connect(_subscriber); }
282  public: static void DisconnectDiagTimerStop(ConnectionPtr _subscriber)
283  { diagTimerStop.Disconnect(_subscriber); }
284 
289  public: template<typename T>
290  static ConnectionPtr ConnectSigInt(T _subscriber)
291  { return sigInt.Connect(_subscriber); }
294  public: static void DisconnectSigInt(ConnectionPtr _subscriber)
295  { sigInt.Disconnect(_subscriber); }
296 
298  public: static EventT<void (bool)> pause;
299 
301  public: static EventT<void ()> step;
302 
304  public: static EventT<void ()> stop;
305 
307  public: static EventT<void ()> sigInt;
308 
311 
314 
317 
320 
323 
326 
330 
333 
335  public: static EventT<void ()> worldReset;
336 
338  public: static EventT<void ()> timeReset;
339 
341  public: static EventT<void ()> preRender;
342 
344  public: static EventT<void ()> render;
345 
347  public: static EventT<void ()> postRender;
348 
351 
354 
359 
368  public: static EventT<void (sdf::ElementPtr,
369  const std::string &,
370  const std::string &,
371  const uint32_t)> createSensor;
372  };
374  }
375 }
376 #endif
static ConnectionPtr ConnectSigInt(T _subscriber)
Connect a boost::slot to the sigint event.
Definition: Events.hh:290
static void DisconnectDiagTimerStart(ConnectionPtr _subscriber)
Disconnect a boost::slot the diagnostic timer start signal.
Definition: Events.hh:270
static EventT< void(std::string, std::string)> setSelectedEntity
An entity has been selected.
Definition: Events.hh:316
static void DisconnectCreateEntity(ConnectionPtr _subscriber)
Disconnect a boost::slot the the add entity signal.
Definition: Events.hh:96
static ConnectionPtr ConnectBeforePhysicsUpdate(T _subscriber)
Connect a boost::slot to the before physics update signal.
Definition: Events.hh:155
static void DisconnectSigInt(ConnectionPtr _subscriber)
Disconnect a boost::slot to the sigint event.
Definition: Events.hh:294
static ConnectionPtr ConnectStop(T _subscriber)
Connect a boost::slot the the stop signal.
Definition: Events.hh:69
static void DisconnectRender(ConnectionPtr _subscriber)
Disconnect a boost::slot the render update signal.
Definition: Events.hh:248
An Event class to get notifications for simulator events.
Definition: Events.hh:37
static ConnectionPtr ConnectWorldUpdateBegin(T _subscriber)
Connect a boost::slot the the world update start signal.
Definition: Events.hh:138
static ConnectionPtr ConnectCreateSensor(T _subscriber)
Connect to the create sensor signal.
Definition: Events.hh:220
static ConnectionPtr ConnectTimeReset(T _subscriber)
Connect to the time reset signal.
Definition: Events.hh:194
static ConnectionPtr ConnectWorldReset(T _subscriber)
Connect to the the world reset signal.
Definition: Events.hh:181
static EventT< void()> worldUpdateEnd
World update has ended.
Definition: Events.hh:332
static void DisconnectDiagTimerStop(ConnectionPtr _subscriber)
Disconnect a boost::slot the diagnostic timer stop signal.
Definition: Events.hh:282
static EventT< void(const common::UpdateInfo &)> worldUpdateBegin
World update has started.
Definition: Events.hh:325
static void DisconnectCreateSensor(ConnectionPtr _subscriber)
Disconnect from the create sensor signal.
Definition: Events.hh:225
static EventT< void(const common::UpdateInfo &)> beforePhysicsUpdate
Collision detection has been done, physics update not yet.
Definition: Events.hh:329
static ConnectionPtr ConnectWorldUpdateEnd(T _subscriber)
Connect a boost::slot the the world update end signal.
Definition: Events.hh:169
static ConnectionPtr ConnectPreRender(T _subscriber)
Render start signal.
Definition: Events.hh:233
static EventT< void()> timeReset
Time reset signal.
Definition: Events.hh:338
static void DisconnectWorldUpdateEnd(ConnectionPtr _subscriber)
Disconnect a boost::slot the the world update end signal.
Definition: Events.hh:173
static void DisconnectStep(ConnectionPtr _subscriber)
Disconnect a boost::slot the the step signal.
Definition: Events.hh:61
static EventT< void(std::string)> diagTimerStart
Diagnostic timer start.
Definition: Events.hh:350
static ConnectionPtr ConnectRemoveSensor(T _subscriber)
Connect to the remove sensor signal.
Definition: Events.hh:207
static ConnectionPtr ConnectPause(T _subscriber)
Connect a boost::slot the the pause signal.
Definition: Events.hh:44
static ConnectionPtr ConnectDiagTimerStop(T _subscriber)
Connect a boost::slot the diagnostic timer stop signal.
Definition: Events.hh:278
static void DisconnectPause(ConnectionPtr _subscriber)
Disconnect a boost::slot the the pause signal.
Definition: Events.hh:49
static EventT< void(std::string)> deleteEntity
An entity has been deleted.
Definition: Events.hh:322
static ConnectionPtr ConnectRender(T _subscriber)
Connect a boost::slot the render update signal.
Definition: Events.hh:244
static EventT< void(bool)> pause
Pause signal.
Definition: Events.hh:298
static ConnectionPtr ConnectDiagTimerStart(T _subscriber)
Connect a boost::slot the diagnostic timer start signal.
Definition: Events.hh:266
static void DisconnectDeleteEntity(ConnectionPtr _subscriber)
Disconnect a boost::slot the delete entity.
Definition: Events.hh:119
static EventT< void(sdf::ElementPtr, const std::string &, const std::string &, const uint32_t)> createSensor
Create a sensor.
Definition: Events.hh:371
static void DisconnectRemoveSensor(ConnectionPtr _subscriber)
Disconnect from the remove sensor signal.
Definition: Events.hh:212
static EventT< void()> preRender
Pre-render.
Definition: Events.hh:341
static EventT< void()> stop
Simulation stop signal.
Definition: Events.hh:304
static void DisconnectWorldCreated(ConnectionPtr _subscriber)
Disconnect a boost::slot the the world created signal.
Definition: Events.hh:84
static void DisconnectBeforePhysicsUpdate(ConnectionPtr _subscriber)
Disconnect a boost::slot from the before physics update signal.
Definition: Events.hh:160
static EventT< void(std::string)> addEntity
An entity has been added.
Definition: Events.hh:319
static EventT< void()> sigInt
Simulation stop signal.
Definition: Events.hh:307
static ConnectionPtr ConnectPostRender(T _subscriber)
Connect a boost::slot the post render update signal.
Definition: Events.hh:255
static ConnectionPtr ConnectWorldCreated(T _subscriber)
Connect a boost::slot the the world created signal.
Definition: Events.hh:81
static void DisconnectSetSelectedEntity(ConnectionPtr _subscriber)
Disconnect a boost::slot the set selected entity.
Definition: Events.hh:108
static void DisconnectWorldReset(ConnectionPtr _subscriber)
Disconnect from the world reset signal.
Definition: Events.hh:186
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:153
static EventT< void()> render
Render.
Definition: Events.hh:344
static void DisconnectStop(ConnectionPtr _subscriber)
Disconnect a boost::slot the the stop signal.
Definition: Events.hh:73
static EventT< void()> step
Step the simulation once signal.
Definition: Events.hh:301
static EventT< void(std::string)> entityCreated
An entity has been created.
Definition: Events.hh:313
static ConnectionPtr ConnectDeleteEntity(T _subscriber)
Connect a boost::slot the delete entity.
Definition: Events.hh:115
static void DisconnectAddEntity(ConnectionPtr _subscriber)
Disconnect a boost::slot the the add entity signal.
Definition: Events.hh:130
static void DisconnectTimeReset(ConnectionPtr _subscriber)
Disconnect from the time reset signal.
Definition: Events.hh:199
static ConnectionPtr ConnectSetSelectedEntity(T _subscriber)
Connect a boost::slot the set selected entity.
Definition: Events.hh:104
static ConnectionPtr ConnectAddEntity(T _subscriber)
Connect a boost::slot the the add entity signal.
Definition: Events.hh:126
static EventT< void()> worldReset
World reset signal.
Definition: Events.hh:335
static EventT< void(std::string)> removeSensor
Remove a sensor.
Definition: Events.hh:358
static EventT< void(std::string)> diagTimerStop
Diagnostic timer stop.
Definition: Events.hh:353
static void DisconnectPreRender(ConnectionPtr _subscriber)
Disconnect a render start signal.
Definition: Events.hh:237
static ConnectionPtr ConnectStep(T _subscriber)
Connect a boost::slot the the step signal.
Definition: Events.hh:57
static EventT< void(std::string)> worldCreated
A world has been created.
Definition: Events.hh:310
static ConnectionPtr ConnectCreateEntity(T _subscriber)
Connect a boost::slot the the add entity signal.
Definition: Events.hh:92
static void DisconnectPostRender(ConnectionPtr _subscriber)
Disconnect a boost::slot the post render update signal.
Definition: Events.hh:259
static EventT< void()> postRender
Post-Render.
Definition: Events.hh:347