| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- //
- // condition.hpp
- // pokemon-engine
- //
- // Created by Sam Jaffe on 7/6/22.
- // Copyright © 2022 Sam Jaffe. All rights reserved.
- //
- #pragma once
- #include <functional>
- #include <string>
- #include <vector>
- #include <reflection/forward.h>
- #include <reflection/property.h>
- #include <engine/forwards.h>
- namespace engine {
- class Condition {
- public:
- using Predicate = std::function<bool(engine::Event const &)>;
- enum class Comparator { NOT_EQUAL = 0, EQUAL = 1, LESS = 2, GREATER = 4 };
- private:
- std::string event_type_;
- std::vector<Predicate> predicates_;
- public:
- Condition() = default;
- Condition(std::string event_type, std::vector<Predicate> predicates);
- std::string_view event_type() const { return event_type_; }
- bool operator()(Event const & on) const;
- template <typename T>
- static Predicate make_predicate(reflection::Property const & scope,
- Comparator cmp, T const & value);
- };
- }
|