16
General discussions / Re: SFML Blueprints - Another SFML book
« on: December 19, 2016, 10:15:04 pm »
I've been working through your book and I'm getting this error.... ActionTarget is not a template type. Followed exactly how you have it in the book if you need the code here it is. Any suggestions? I'm using CodeLite I don't know if that makes a difference.
#ifndef _ACTIONTARGET_H
#define _ACTIONTARGET_H
#include "ActionMap.h"
#include <functional>
#include <utility>
#include <list>
template<typename T = int>
class ActionTarget
{
public:
ActionTarget(const ActionTarget<T>&) = delete;
ActionTarget<T>& operator=(const ActionTarget<T>&) = delete;
using FuncType = std::function<void(const sf::Event&)>;
ActionTarget(const ActionMap<T>& map);
bool ProcessEvent(const sf::Event& event) const;
void ProcessEvents() const;
void Bind(const T& key, const FuncType& callback);
void Unbind(const T& key);
private:
std::list<std::pair<T, FuncType>> m_EventsRealTime;
std::list<std::pair<T, FuncType>> m_EventsPoll;
const ActionMap<T>& m_ActionMap;
};
#include "ActionTarget.tpl"
#endif // _ACTIONTARGET_H
#define _ACTIONTARGET_H
#include "ActionMap.h"
#include <functional>
#include <utility>
#include <list>
template<typename T = int>
class ActionTarget
{
public:
ActionTarget(const ActionTarget<T>&) = delete;
ActionTarget<T>& operator=(const ActionTarget<T>&) = delete;
using FuncType = std::function<void(const sf::Event&)>;
ActionTarget(const ActionMap<T>& map);
bool ProcessEvent(const sf::Event& event) const;
void ProcessEvents() const;
void Bind(const T& key, const FuncType& callback);
void Unbind(const T& key);
private:
std::list<std::pair<T, FuncType>> m_EventsRealTime;
std::list<std::pair<T, FuncType>> m_EventsPoll;
const ActionMap<T>& m_ActionMap;
};
#include "ActionTarget.tpl"
#endif // _ACTIONTARGET_H