-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
232 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,9 @@ | |
*.lai | ||
*.la | ||
*.a | ||
|
||
# YCM files | ||
*.ycm* | ||
|
||
# Syntastic files | ||
*.syntastic_cpp_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef EVENT_EVENT_HPP_ | ||
#define EVENT_EVENT_HPP_ | ||
#include <SFML/Window/Event.hpp> | ||
namespace event { | ||
struct Event { | ||
sf::Event event_; | ||
}; | ||
} // namespace event | ||
|
||
#endif // EVENT_EVENT_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef EVENT_FILTER_INL_HPP_ | ||
#define EVENT_FILTER_INL_HPP_ | ||
#include <event/filter_source.hpp> | ||
#include <event/handle.hpp> | ||
|
||
using sf::Event::EventType; | ||
using std::function; | ||
|
||
namespace event { | ||
//===----------------------------------------------------------------------===// | ||
// Filter | ||
//===----------------------------------------------------------------------===// | ||
template<typename EventType> | ||
Filter::Filter(HandleFactory const& hf) : handle_factory_(hf) { | ||
} | ||
|
||
template<typename EventType> | ||
Handle Filter::register(void) { | ||
return handle_factory_.build(); | ||
} | ||
|
||
template<typename EventType> | ||
void Filter::unregister(Handle const handle) { | ||
// TODO(@anyone) implement. | ||
} | ||
|
||
template<typename EventType> | ||
bool Filter::send_events(std::vector<Event> const events) const { | ||
for (auto const& event : events) { | ||
// TODO(@anyone) implement | ||
} | ||
return false; | ||
} | ||
} // namespace event | ||
|
||
#endif // EVENT_FILTER_INL_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef EVENT_FILTER_HPP_ | ||
#define EVENT_FILTER_HPP_ | ||
#include "handle.hpp" | ||
#include "event.hpp" | ||
#include <vector> | ||
namespace event { | ||
struct HandleFactory; | ||
|
||
struct Filter { | ||
virtual ~Filter(void) { } | ||
virtual bool send_events(std::vector<Event> const events) const = 0; | ||
}; | ||
|
||
template<typename EventType> | ||
struct EventFilter : public Filter { | ||
EventFilter(HandleFactory const& hf); | ||
Handle register_filter(void); | ||
void unregister(Handle const handle); | ||
bool send_events(std::vector<Event> const events) const; | ||
private: | ||
HandleFactory const& handle_factory_; | ||
std::vector<Handle> handles_; | ||
}; | ||
|
||
} // namespace event | ||
#endif // EVENT_FILTER_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef EVENT_HANDLE_HPP_ | ||
#define EVENT_HANDLE_HPP_ | ||
#include <cstdint> | ||
|
||
namespace event { | ||
class Handle { | ||
friend class HandleFactory; | ||
explicit Handle(uint64_t const id); | ||
uint64_t const id_; | ||
}; | ||
|
||
struct HandleFactory { | ||
HandleFactory(void); | ||
Handle Build(void); | ||
private: | ||
uint64_t index_; | ||
}; | ||
} // namespace event_ | ||
|
||
#endif // EVENT_HANDLE_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef EVENT_SYSTEM_HPP_ | ||
#define EVENT_SYSTEM_HPP_ | ||
#include "handle.hpp" | ||
#include "filter.hpp" | ||
#include <vector> | ||
|
||
namespace sf { | ||
class Window; | ||
} // namespace sf | ||
|
||
namespace event { | ||
struct System { | ||
virtual void add_filter(Filter &&f) = 0; | ||
virtual void enumerate(void) const = 0; | ||
}; | ||
|
||
struct SfmlSystem : public System { | ||
SfmlSystem(sf::Window &window); | ||
virtual void add_filter(Filter &&f) override; | ||
virtual void enumerate(void) const override; | ||
private: | ||
sf::Window &window_; | ||
std::vector<Filter> filters_; | ||
}; | ||
|
||
} // namespace event | ||
|
||
#endif // EVENT_SYSTEM_HPP_ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
set (SRCROOT ${PROJECT_SOURCE_DIR}/lib/event) | ||
|
||
# list of source files | ||
set(SRC | ||
${SRCROOT}/event.cxx | ||
${SRCROOT}/handle.cxx | ||
${SRCROOT}/system.cxx | ||
) | ||
source_group("" FILES ${SRC}) | ||
add_library(event_lib ${SRC}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <event/event.hpp> | ||
#include <stdexcept> | ||
|
||
using Event = sf::Event::EventType; | ||
|
||
namespace event { | ||
|
||
} // namespace event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <event/handle.hpp> | ||
#include <cstdint> | ||
|
||
namespace event { | ||
//===----------------------------------------------------------------------===// | ||
// Handle | ||
//===----------------------------------------------------------------------===// | ||
Handle::Handle(uint64_t const id) : id_(id) { | ||
} | ||
|
||
//===----------------------------------------------------------------------===// | ||
// HandleFactory | ||
//===----------------------------------------------------------------------===// | ||
HandleFactory::HandleFactory(void) : index_(0U) { | ||
} | ||
|
||
Handle HandleFactory::Build(void) { | ||
return Handle(index_++); | ||
} | ||
} // namespace event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <event/system.hpp> | ||
#include <event/filter.hpp> | ||
#include <event/event.hpp> | ||
#include <stdexcept> | ||
#include <vector> | ||
|
||
using Event = sf::Event::EventType; | ||
|
||
namespace event { | ||
SfmlSystem::SfmlSystem(sf::Window &window) : window_(window) { | ||
} | ||
|
||
void SfmlSystem::add_filter(Filter &&f) { | ||
filters_.push_back(f); | ||
} | ||
|
||
void SfmlSystem::enumerate(void) const { | ||
/*for (auto const& filter : filters_) { | ||
std::vector<Event> const empty_events; | ||
bool const result = filter.send_events(empty_events); | ||
} | ||
(*/ | ||
//throw std::runtime_error("Unimplemented"); | ||
} | ||
|
||
} // namespace event |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters