# Path: gridsim/decorators.py
# def accepts(*atypes):
#     """
#     accepts()
# 
#     Type Enforcement. Verifies types of parameters given to the function.
#     
#     *Example:*
#     ::
# 
#         @accepts((0,int), (1,(int,float)))
#         def func(arg1, arg2):
#             return arg1 * arg2
# 
#     .. warning::
#         In a class function, the current class cannot be used (e.g.: ``self``
#         type cannot be defined with ``accepts``)
#     """
# 
#     if __debug__:
#         def check_accepts(func):
# 
#             @wraps(func)
#             def new_func(*args, **keywords):
# 
#                 if len(atypes) != 0 and type(atypes[0]) is not tuple:
#                     raise AttributeError("Missing brackets in accepts of function "
#                                          + func.__name__)
# 
#                 for atype in atypes:
# 
#                     if type(atype[0]) is tuple:
#                         for apos in atype[0]:
# 
#                             default_param = False
#                             try:
#                                 args[apos]
#                             except IndexError:
#                                 default_param = True
# 
#                             if not default_param \
#                                     and not isinstance(args[apos], atype[1]):
#                                 raise TypeError(
#                                     "In '"+func.__name__+"', "
#                                     "params value %r does not "
#                                     "match %s" % (args[apos], atype[1]))
#                     else:
# 
#                         default_param = False
#                         try:
#                             args[atype[0]]
#                         except IndexError:
#                             default_param = True
# 
#                         if not default_param \
#                                 and not isinstance(args[atype[0]], atype[1]):
#                             raise TypeError(
#                                 "In"+func.__name__+", "
#                                 "params value %r does not "
#                                 "match %s" % (args[atype[0]], atype[1]))
# 
#                 return func(*args, **keywords)
# 
#             return new_func
#     else:
#         def check_accepts(func):
#             return func
# 
#     return check_accepts
# 
# def returns(rtype=type(None)):
#     """
#     returns()
# 
#     Type Enforcement. Verifies return type of the function.
#     
#     *Example:*
#     ::
# 
#         @returns((int,float))
#         def func(arg1, arg2):
#             return arg1 * arg2
# 
#     """
#     if __debug__:
#         def check_returns(func):
# 
#             @wraps(func)
#             def new_f(*args, **keywords):
# 
#                 result = func(*args, **keywords)
#                 if not isinstance(result, rtype):
#                     raise TypeError(
#                         "return value %r does not match %s" % (result, rtype))
#                 return result
# 
#             return new_f
#     else:
#         def check_returns(func):
#             return func
# 
#     return check_returns


from .decorators import accepts, returns
Likewise, when the user calls the :func:`gridsim.simulation.Simulator.step` the
simulator calls first the :func:`gridsim.core.AbstractSimulationModule.calculate`
of every loaded modules then their :func:`gridsim.core.AbstractSimulationModule.update`.

Finally the :func:`gridsim.simulation.Simulator.run` function of the simulator
is only a set of sequential calls of :func:`gridsim.simulation.Simulator.step`
incrementing the time.
"""


class AbstractSimulationModule(object):

    def __init__(self):
        """
        __init__(self)

        Interface for simulation modules. Gridsim groups different simulation
        aspects into different Python modules in oder to separate and
        organize the implementations.

        All Gridsim simulation modules have to implement the pure abstract
        methods of this interface class.

        *Example of a minimal simulation module:*

        .. literalinclude:: ../../demo/minimalmodule.py
        """
        super(AbstractSimulationModule, self).__init__()
        self.simulator = None


# Path: gridsim/decorators.py
# def accepts(*atypes):
#     """
#     accepts()
# 
#     Type Enforcement. Verifies types of parameters given to the function.
#     
#     *Example:*
#     ::
# 
#         @accepts((0,int), (1,(int,float)))
#         def func(arg1, arg2):
#             return arg1 * arg2
# 
#     .. warning::
#         In a class function, the current class cannot be used (e.g.: ``self``
#         type cannot be defined with ``accepts``)
#     """
# 
#     if __debug__:
#         def check_accepts(func):
# 
#             @wraps(func)
#             def new_func(*args, **keywords):
# 
#                 if len(atypes) != 0 and type(atypes[0]) is not tuple:
#                     raise AttributeError("Missing brackets in accepts of function "
#                                          + func.__name__)
# 
#                 for atype in atypes:
# 
#                     if type(atype[0]) is tuple:
#                         for apos in atype[0]:
# 
#                             default_param = False
#                             try:
#                                 args[apos]
#                             except IndexError:
#                                 default_param = True
# 
#                             if not default_param \
#                                     and not isinstance(args[apos], atype[1]):
#                                 raise TypeError(
#                                     "In '"+func.__name__+"', "
#                                     "params value %r does not "
#                                     "match %s" % (args[apos], atype[1]))
#                     else:
# 
#                         default_param = False
#                         try:
#                             args[atype[0]]
#                         except IndexError:
#                             default_param = True
# 
#                         if not default_param \
#                                 and not isinstance(args[atype[0]], atype[1]):
#                             raise TypeError(
#                                 "In"+func.__name__+", "
#                                 "params value %r does not "
#                                 "match %s" % (args[atype[0]], atype[1]))
# 
#                 return func(*args, **keywords)
# 
#             return new_func
#     else:
#         def check_accepts(func):
#             return func
# 
#     return check_accepts
# 
# def returns(rtype=type(None)):
#     """
#     returns()
# 
#     Type Enforcement. Verifies return type of the function.
#     
#     *Example:*
#     ::
# 
#         @returns((int,float))
#         def func(arg1, arg2):
#             return arg1 * arg2
# 
#     """
#     if __debug__:
#         def check_returns(func):
# 
#             @wraps(func)
#             def new_f(*args, **keywords):
# 
#                 result = func(*args, **keywords)
#                 if not isinstance(result, rtype):
#                     raise TypeError(
#                         "return value %r does not match %s" % (result, rtype))
#                 return result
# 
#             return new_f
#     else:
#         def check_returns(func):
#             return func
# 
#     return check_returns


# Path: gridsim/core.py
from .decorators import accepts, returns

Likewise, when the user calls the :func:`gridsim.simulation.Simulator.step` the
simulator calls first the :func:`gridsim.core.AbstractSimulationModule.calculate`
of every loaded modules then their :func:`gridsim.core.AbstractSimulationModule.update`.

Finally the :func:`gridsim.simulation.Simulator.run` function of the simulator
is only a set of sequential calls of :func:`gridsim.simulation.Simulator.step`
incrementing the time.
"""


class AbstractSimulationModule(object):

    def __init__(self):
        """
        __init__(self)

        Interface for simulation modules. Gridsim groups different simulation
        aspects into different Python modules in oder to separate and
        organize the implementations.

        All Gridsim simulation modules have to implement the pure abstract
        methods of this interface class.

        *Example of a minimal simulation module:*

        .. literalinclude:: ../../demo/minimalmodule.py
        """
        super(AbstractSimulationModule, self).__init__()
        self.simulator = None


    @returns(str)