Add way to get a list of DelugeEvent classes

This commit is contained in:
Andrew Resch 2009-11-14 23:42:04 +00:00
parent 1a1ab4e780
commit ad04b2a137

View File

@ -41,6 +41,16 @@ and subsequently emitted to the clients.
"""
event_list = []
class DelugeEventMetaClass(type):
"""
This metaclass simply keeps a list of all events classes created.
"""
def __init__(cls, name, bases, dct):
event_list.append(name)
super(DelugeEventMetaClass, cls).__init__(name, bases, dct)
class DelugeEvent(object):
"""
The base class for all events.
@ -49,6 +59,8 @@ class DelugeEvent(object):
:prop args: a list of the attribute values
"""
__metaclass__ = DelugeEventMetaClass
def _get_name(self):
return self.__class__.__name__