eventy/source/eventy/signal.d

57 lines
1.0 KiB
D
Raw Normal View History

2021-08-27 15:12:48 +01:00
module eventy.signal;
import eventy.event : Event;
/**
* Signal
*
* Represents a signal handler that handles a given set of typeIDs
* which means that it contains an associated function to be run
* on handling of a given Event
*/
2022-01-16 12:32:00 +00:00
//alias EventHandler = void function(Event);
2021-08-27 15:12:48 +01:00
2022-01-16 12:32:00 +00:00
public abstract class Signal
2021-08-27 15:12:48 +01:00
{
/* TypeIDs this signal handler associates with */
2021-08-27 15:12:48 +01:00
private ulong[] typeIDs;
/* Signal handler */
2022-01-16 12:32:00 +00:00
//private EventHandler handler;
2022-01-16 12:32:00 +00:00
this(ulong[] typeIDs)
{
this.typeIDs = typeIDs;
}
/**
* Returns true if this signal handles the given typeID
* false otherwise
*/
public bool handles(ulong typeID)
{
/* FIXME: Implement */
foreach(ulong id; typeIDs)
{
if(id == typeID)
{
return true;
}
}
return false;
}
public void registerTypeID(ulong typeID)
2021-08-27 15:12:48 +01:00
{
}
public void deregisterTypeID(ulong typeID)
{
}
2022-01-16 12:32:00 +00:00
public abstract void handler(Event);
}