diff --git a/src/backend/pyloader/Abstract.py b/src/backend/pyloader/Abstract.py index fa4d4fe..2356e23 100644 --- a/src/backend/pyloader/Abstract.py +++ b/src/backend/pyloader/Abstract.py @@ -1,59 +1,63 @@ +## @brief Defines a class to create abstract methods +# +# @author Ivo Timmermans +# @date 2004/01/23 +# @version 1.1 +# +# Example: +# @code +# import Abstract; +# class Foo: +# __metaclass__ = Abstract.Metaclass +# foo = Abstract.AbstractMethod('foo') +# @endcode class AbstractMethod (object): - """Defines a class to create abstract methods - - @example: - class Foo: - foo = AbstractMethod('foo') - """ + ## @brief Constructor + # + # @param func name of the function (used when raising an + # exception). Its type is str. def __init__(self, func): - """Constructor - - @params func: name of the function (used when raising an - exception). - @type func: str - """ self._function = func + ## @brief Get callable object + # + # @return An instance of AbstractMethodHelper. + # This trickery is needed to get the name of the class for which + # an abstract method was requested, otherwise it would be + # sufficient to include a __call__ method in the AbstractMethod + # class itself. def __get__(self, obj, type): - """Get callable object - - @returns An instance of AbstractMethodHelper. - - This trickery is needed to get the name of the class for which - an abstract method was requested, otherwise it would be - sufficient to include a __call__ method in the AbstractMethod - class itself. - """ return self.AbstractMethodHelper(self._function, type) + ## @brief Abstract method helper class + # + # An AbstractMethodHelper instance is a callable object that + # represents an abstract method. class AbstractMethodHelper (object): - """Abstract method helper class - - An AbstractMethodHelper instance is a callable object that - represents an abstract method. - """ def __init__(self, func, cls): self._function = func self._class = cls + ## @brief Call abstract method + # + # Raises a TypeError, because abstract methods can not be + # called. def __call__(self, *args, **kwargs): - """Call abstract method - - Raises a TypeError, because abstract methods can not be - called. - """ raise TypeError('Abstract method `' + self._class.__name__ \ + '.' + self._function + '\' called') - +## @brief Configure a new class to be abstract +# +# @author Ivo Timmermans +# @date 2004/01/23 +# @version 1.1 class Metaclass (type): + ## Configure a new class + # + # @param cls Class object + # @param name Name of the class + # @param bases All base classes for cls def __init__(cls, name, bases, *args, **kwargs): - """Configure a new class - - @param cls: Class object - @param name: Name of the class - @param bases: All base classes for cls - """ super(Metaclass, cls).__init__(cls, name, bases, *args, **kwargs) # Detach cls.new() from class Metaclass, and make it a method @@ -77,14 +81,12 @@ class Metaclass (type): abstractmethods.sort() setattr(cls, '__abstractmethods__', abstractmethods) + ## @brief Allocator for class cls + # + # @param self Class object for which an instance should be + # created. + # @param cls Same as self. def new(self, cls): - """Allocator for class cls - - @param self: Class object for which an instance should be - created. - - @param cls: Same as self. - """ if len(cls.__abstractmethods__): raise NotImplementedError('Can\'t instantiate class `' + \ cls.__name__ + '\';\n' + \ diff --git a/src/backend/pyloader/Policy.py b/src/backend/pyloader/Policy.py index e38a8b3..d54b39a 100644 --- a/src/backend/pyloader/Policy.py +++ b/src/backend/pyloader/Policy.py @@ -1,11 +1,9 @@ -''' from sgpem import SchedulableQueue, PolicyParameters ''' +# from sgpem import SchedulableQueue, PolicyParameters from Abstract import * class Policy: - ''' - Avoid instantiation of an abstract class. - ''' + ## @var Avoid instantiation of an abstract class __metaclass__ = Metaclass configure = AbstractMethod('configure')