diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-02-23 12:02:00 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-02-23 12:02:00 -0500 |
| commit | 15b511e694f976686fdec1fb9f959f8a92f3b594 (patch) | |
| tree | 18c0a234bbbfd34592a371d15dbfbecbede906c8 /src/views.h | |
| parent | 26fbd8c1edaf94513d9750681edbe449b699efe4 (diff) | |
| download | dispatcher-15b511e694f976686fdec1fb9f959f8a92f3b594.tar.gz dispatcher-15b511e694f976686fdec1fb9f959f8a92f3b594.tar.bz2 dispatcher-15b511e694f976686fdec1fb9f959f8a92f3b594.zip | |
More ranges stuff! Now with custom views
Diffstat (limited to 'src/views.h')
| -rw-r--r-- | src/views.h | 62 |
1 files changed, 62 insertions, 0 deletions
| diff --git a/src/views.h b/src/views.h new file mode 100644 index 0000000..69bd2b5 --- /dev/null +++ b/src/views.h | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | #ifndef VIEWS_H_98651096 | ||
| 2 | #define VIEWS_H_98651096 | ||
| 3 | |||
| 4 | #include "entity.h" | ||
| 5 | #include <range/v3/all.hpp> | ||
| 6 | |||
| 7 | namespace views { | ||
| 8 | |||
| 9 | inline auto isMoving() | ||
| 10 | { | ||
| 11 | return ranges::view::filter([] (const Entity& entity) { | ||
| 12 | return entity.moving; | ||
| 13 | }); | ||
| 14 | } | ||
| 15 | |||
| 16 | inline auto isNotMoving() | ||
| 17 | { | ||
| 18 | return ranges::view::filter([] (const Entity& entity) { | ||
| 19 | return !entity.moving; | ||
| 20 | }); | ||
| 21 | } | ||
| 22 | |||
| 23 | inline auto isControllable() | ||
| 24 | { | ||
| 25 | return ranges::view::filter([] (const Entity& entity) { | ||
| 26 | return entity.controllable; | ||
| 27 | }); | ||
| 28 | } | ||
| 29 | |||
| 30 | inline auto isTrack() | ||
| 31 | { | ||
| 32 | return ranges::view::filter([] (const Entity& entity) { | ||
| 33 | return entity.isTrack; | ||
| 34 | }); | ||
| 35 | } | ||
| 36 | |||
| 37 | inline auto isScheduled() | ||
| 38 | { | ||
| 39 | return ranges::view::filter([] (const Entity& entity) { | ||
| 40 | return entity.scheduled; | ||
| 41 | }); | ||
| 42 | } | ||
| 43 | |||
| 44 | inline auto isOnLayer(Layer layer) | ||
| 45 | { | ||
| 46 | return ranges::view::filter([layer] (const Entity& entity) { | ||
| 47 | return entity.layer == layer; | ||
| 48 | }); | ||
| 49 | } | ||
| 50 | |||
| 51 | inline auto canBePushedBy(ColliderType ctype) | ||
| 52 | { | ||
| 53 | return ranges::view::filter([ctype] (const Entity& entity) { | ||
| 54 | return entity.canBePushedBy.count(ctype); | ||
| 55 | }); | ||
| 56 | } | ||
| 57 | |||
| 58 | |||
| 59 | |||
| 60 | } | ||
| 61 | |||
| 62 | #endif /* end of include guard: VIEWS_H_98651096 */ | ||
