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 
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 
150  public: template<typename T>
151  static ConnectionPtr ConnectWorldUpdateEnd(T _subscriber)
152  { return worldUpdateEnd.Connect(_subscriber); }
155  public: static void DisconnectWorldUpdateEnd(ConnectionPtr _subscriber)
156  { worldUpdateEnd.Disconnect(_subscriber); }
157 
162  public: template<typename T>
163  static ConnectionPtr ConnectWorldReset(T _subscriber)
164  { return worldReset.Connect(_subscriber); }
165 
168  public: static void DisconnectWorldReset(ConnectionPtr _subscriber)
169  { worldReset.Disconnect(_subscriber); }
170 
175  public: template<typename T>
176  static ConnectionPtr ConnectTimeReset(T _subscriber)
177  { return timeReset.Connect(_subscriber); }
178 
181  public: static void DisconnectTimeReset(ConnectionPtr _subscriber)
182  { timeReset.Disconnect(_subscriber); }
183 
188  public: template<typename T>
189  static ConnectionPtr ConnectRemoveSensor(T _subscriber)
190  { return removeSensor.Connect(_subscriber); }
191 
194  public: static void DisconnectRemoveSensor(ConnectionPtr _subscriber)
195  { removeSensor.Disconnect(_subscriber); }
196 
201  public: template<typename T>
202  static ConnectionPtr ConnectCreateSensor(T _subscriber)
203  { return createSensor.Connect(_subscriber); }
204 
207  public: static void DisconnectCreateSensor(ConnectionPtr _subscriber)
208  { createSensor.Disconnect(_subscriber); }
209 
214  public: template<typename T>
215  static ConnectionPtr ConnectPreRender(T _subscriber)
216  { return preRender.Connect(_subscriber); }
219  public: static void DisconnectPreRender(ConnectionPtr _subscriber)
220  { preRender.Disconnect(_subscriber); }
225  public: template<typename T>
226  static ConnectionPtr ConnectRender(T _subscriber)
227  { return render.Connect(_subscriber); }
230  public: static void DisconnectRender(ConnectionPtr _subscriber)
231  { render.Disconnect(_subscriber); }
236  public: template<typename T>
237  static ConnectionPtr ConnectPostRender(T _subscriber)
238  { return postRender.Connect(_subscriber); }
241  public: static void DisconnectPostRender(ConnectionPtr _subscriber)
242  { postRender.Disconnect(_subscriber); }
247  public: template<typename T>
248  static ConnectionPtr ConnectDiagTimerStart(T _subscriber)
249  { return diagTimerStart.Connect(_subscriber); }
252  public: static void DisconnectDiagTimerStart(ConnectionPtr _subscriber)
253  { diagTimerStart.Disconnect(_subscriber); }
254 
259  public: template<typename T>
260  static ConnectionPtr ConnectDiagTimerStop(T _subscriber)
261  { return diagTimerStop.Connect(_subscriber); }
264  public: static void DisconnectDiagTimerStop(ConnectionPtr _subscriber)
265  { diagTimerStop.Disconnect(_subscriber); }
266 
271  public: template<typename T>
272  static ConnectionPtr ConnectSigInt(T _subscriber)
273  { return sigInt.Connect(_subscriber); }
276  public: static void DisconnectSigInt(ConnectionPtr _subscriber)
277  { sigInt.Disconnect(_subscriber); }
278 
280  public: static EventT<void (bool)> pause;
281 
283  public: static EventT<void ()> step;
284 
286  public: static EventT<void ()> stop;
287 
289  public: static EventT<void ()> sigInt;
290 
293 
296 
299 
302 
305 
308 
311 
313  public: static EventT<void ()> worldReset;
314 
316  public: static EventT<void ()> timeReset;
317 
319  public: static EventT<void ()> preRender;
320 
322  public: static EventT<void ()> render;
323 
325  public: static EventT<void ()> postRender;
326 
329 
332 
337 
346  public: static EventT<void (sdf::ElementPtr,
347  const std::string &,
348  const std::string &,
349  const uint32_t)> createSensor;
350  };
352  }
353 }
354 #endif
static void DisconnectTimeReset(ConnectionPtr _subscriber)
Disconnect from the time reset signal.
Definition: Events.hh:181
static ConnectionPtr ConnectPreRender(T _subscriber)
Render start signal.
Definition: Events.hh:215
static EventT< void(std::string)> deleteEntity
An entity has been deleted.
Definition: Events.hh:304
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:153
static void DisconnectPause(ConnectionPtr _subscriber)
Disconnect a boost::slot the the pause signal.
Definition: Events.hh:49
static EventT< void(std::string)> diagTimerStop
Diagnostic timer stop.
Definition: Events.hh:331
static EventT< void()> stop
Simulation stop signal.
Definition: Events.hh:286
static void DisconnectDiagTimerStop(ConnectionPtr _subscriber)
Disconnect a boost::slot the diagnostic timer stop signal.
Definition: Events.hh:264
An Event class to get notifications for simulator events.
Definition: Events.hh:37
static ConnectionPtr ConnectAddEntity(T _subscriber)
Connect a boost::slot the the add entity signal.
Definition: Events.hh:126
static EventT< void()> worldUpdateEnd
World update has ended.
Definition: Events.hh:310
static void DisconnectSigInt(ConnectionPtr _subscriber)
Disconnect a boost::slot to the sigint event.
Definition: Events.hh:276
static void DisconnectStop(ConnectionPtr _subscriber)
Disconnect a boost::slot the the stop signal.
Definition: Events.hh:73
static ConnectionPtr ConnectWorldCreated(T _subscriber)
Connect a boost::slot the the world created signal.
Definition: Events.hh:81
static EventT< void(sdf::ElementPtr, const std::string &, const std::string &, const uint32_t)> createSensor
Create a sensor.
Definition: Events.hh:349
static void DisconnectDeleteEntity(ConnectionPtr _subscriber)
Disconnect a boost::slot the delete entity.
Definition: Events.hh:119
static EventT< void(std::string)> diagTimerStart
Diagnostic timer start.
Definition: Events.hh:328
static EventT< void()> timeReset
Time reset signal.
Definition: Events.hh:316
static ConnectionPtr ConnectRemoveSensor(T _subscriber)
Connect to the remove sensor signal.
Definition: Events.hh:189
static ConnectionPtr ConnectStop(T _subscriber)
Connect a boost::slot the the stop signal.
Definition: Events.hh:69
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:292
#define GZ_COMMON_VISIBLE
Definition: system.hh:84
static ConnectionPtr ConnectDeleteEntity(T _subscriber)
Connect a boost::slot the delete entity.
Definition: Events.hh:115
static ConnectionPtr ConnectDiagTimerStop(T _subscriber)
Connect a boost::slot the diagnostic timer stop signal.
Definition: Events.hh:260
static void DisconnectStep(ConnectionPtr _subscriber)
Disconnect a boost::slot the the step signal.
Definition: Events.hh:61
static ConnectionPtr ConnectTimeReset(T _subscriber)
Connect to the time reset signal.
Definition: Events.hh:176
static void DisconnectDiagTimerStart(ConnectionPtr _subscriber)
Disconnect a boost::slot the diagnostic timer start signal.
Definition: Events.hh:252
GZ_GUI_VISIBLE void stop()
static ConnectionPtr ConnectRender(T _subscriber)
Connect a boost::slot the render update signal.
Definition: Events.hh:226
static EventT< void()> postRender
Post-Render.
Definition: Events.hh:325
static void DisconnectWorldReset(ConnectionPtr _subscriber)
Disconnect from the world reset signal.
Definition: Events.hh:168
static ConnectionPtr ConnectWorldUpdateBegin(T _subscriber)
Connect a boost::slot the the world update start signal.
Definition: Events.hh:138
static EventT< void(std::string, std::string)> setSelectedEntity
An entity has been selected.
Definition: Events.hh:298
static ConnectionPtr ConnectWorldReset(T _subscriber)
Connect to the the world reset signal.
Definition: Events.hh:163
static void DisconnectPostRender(ConnectionPtr _subscriber)
Disconnect a boost::slot the post render update signal.
Definition: Events.hh:241
static void DisconnectCreateEntity(ConnectionPtr _subscriber)
Disconnect a boost::slot the the add entity signal.
Definition: Events.hh:96
static EventT< void()> step
Step the simulation once signal.
Definition: Events.hh:283
static EventT< void(bool)> pause
Pause signal.
Definition: Events.hh:280
static ConnectionPtr ConnectPostRender(T _subscriber)
Connect a boost::slot the post render update signal.
Definition: Events.hh:237
static ConnectionPtr ConnectSigInt(T _subscriber)
Connect a boost::slot to the sigint event.
Definition: Events.hh:272
static ConnectionPtr ConnectSetSelectedEntity(T _subscriber)
Connect a boost::slot the set selected entity.
Definition: Events.hh:104
static void DisconnectRemoveSensor(ConnectionPtr _subscriber)
Disconnect from the remove sensor signal.
Definition: Events.hh:194
static EventT< void(const common::UpdateInfo &)> worldUpdateBegin
World update has started.
Definition: Events.hh:307
static void DisconnectWorldCreated(ConnectionPtr _subscriber)
Disconnect a boost::slot the the world created signal.
Definition: Events.hh:84
static EventT< void()> sigInt
Simulation stop signal.
Definition: Events.hh:289
static EventT< void()> render
Render.
Definition: Events.hh:322
static void DisconnectWorldUpdateEnd(ConnectionPtr _subscriber)
Disconnect a boost::slot the the world update end signal.
Definition: Events.hh:155
static EventT< void()> preRender
Pre-render.
Definition: Events.hh:319
static ConnectionPtr ConnectDiagTimerStart(T _subscriber)
Connect a boost::slot the diagnostic timer start signal.
Definition: Events.hh:248
static EventT< void(std::string)> addEntity
An entity has been added.
Definition: Events.hh:301
static void DisconnectCreateSensor(ConnectionPtr _subscriber)
Disconnect from the create sensor signal.
Definition: Events.hh:207
static ConnectionPtr ConnectCreateSensor(T _subscriber)
Connect to the create sensor signal.
Definition: Events.hh:202
static void DisconnectRender(ConnectionPtr _subscriber)
Disconnect a boost::slot the render update signal.
Definition: Events.hh:230
static void DisconnectPreRender(ConnectionPtr _subscriber)
Disconnect a render start signal.
Definition: Events.hh:219
static EventT< void(std::string)> removeSensor
Remove a sensor.
Definition: Events.hh:336
static ConnectionPtr ConnectCreateEntity(T _subscriber)
Connect a boost::slot the the add entity signal.
Definition: Events.hh:92
static EventT< void()> worldReset
World reset signal.
Definition: Events.hh:313
static ConnectionPtr ConnectWorldUpdateEnd(T _subscriber)
Connect a boost::slot the the world update end signal.
Definition: Events.hh:151
static void DisconnectSetSelectedEntity(ConnectionPtr _subscriber)
Disconnect a boost::slot the set selected entity.
Definition: Events.hh:108
static EventT< void(std::string)> entityCreated
An entity has been created.
Definition: Events.hh:295
static void DisconnectAddEntity(ConnectionPtr _subscriber)
Disconnect a boost::slot the the add entity signal.
Definition: Events.hh:130
static ConnectionPtr ConnectPause(T _subscriber)
Connect a boost::slot the the pause signal.
Definition: Events.hh:44