... | @@ -29,7 +29,7 @@ You can find the complete implementation of EventHandler in `src/shared/events/E |
... | @@ -29,7 +29,7 @@ You can find the complete implementation of EventHandler in `src/shared/events/E |
|
### Example
|
|
### Example
|
|
This example shows how to define a very simple custom EventHandler.
|
|
This example shows how to define a very simple custom EventHandler.
|
|
|
|
|
|
#### MyEventHandler.h
|
|
##### MyEventHandler.h
|
|
The first thing we need to do is to import the required modules and to define a set of events. For more details you can look at the [Events](Events) page.
|
|
The first thing we need to do is to import the required modules and to define a set of events. For more details you can look at the [Events](Events) page.
|
|
Here we define three possible events: `EV_1`, `EV_2` and `EV_3`.
|
|
Here we define three possible events: `EV_1`, `EV_2` and `EV_3`.
|
|
```cpp
|
|
```cpp
|
... | @@ -78,7 +78,7 @@ private: |
... | @@ -78,7 +78,7 @@ private: |
|
};
|
|
};
|
|
```
|
|
```
|
|
|
|
|
|
#### test-myeventhandler.cpp
|
|
##### test-myeventhandler.cpp
|
|
In order to test that our class works we can create a MyEventHandler object and start it.
|
|
In order to test that our class works we can create a MyEventHandler object and start it.
|
|
We can then post some events and see what the output is.
|
|
We can then post some events and see what the output is.
|
|
```cpp
|
|
```cpp
|
... | @@ -112,7 +112,7 @@ int main() |
... | @@ -112,7 +112,7 @@ int main() |
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
```
|
|
```
|
|
#### Output
|
|
##### Output
|
|
Remember to add the `test-myeventhandler.cpp` to `sbs.conf` and to specify all the needed includes.
|
|
Remember to add the `test-myeventhandler.cpp` to `sbs.conf` and to specify all the needed includes.
|
|
After you run the example you should see the following output:
|
|
After you run the example you should see the following output:
|
|
```
|
|
```
|
... | | ... | |