"""This module contains the point generation class."""
import uuid
import random
from selector.generators.base_point_generator import base_point


class PointGen:
    """
    Interface for point generation.

    Parameters
    ----------
    scenario : selector.scenario.Scenario
        AC scenario.
    gm : selector.generators.base_point_generator.base_point
        Function to generate Configurations.
    seed : int
        Random seed.
    """

    def __init__(self, scenario, gm=base_point, seed=False):
        self.s = scenario
        self.gen_method = gm
        self.seed = seed

    def point_generator(self, **kwargs):
        """
        Running point generation according to object setting.

        Other Parameters
        ----------------        
        n_samples : int
            Number of picks from the parameter space.
        seed: int
            Random seed.
        lhs_type: selector.generators.lhs_point_generator.LHSType
            Type of LHC sampling.
        criterion: selector.generators.lhs_point_generator.Criterion
            Criterions of LHC optimizatio.
        mode : selector.generators.variable_graph_point_generator.Mode
            Mode of parent selection.
        data : dict of selector.pool.Tournament
            Tournament data to select parents from.
        lookback : int
            Number of past tournaments included.
        seed : int
            Random seed.

        Returns
        -------
        selector.pool.Configuration
            Configuration generated by self.gen_method (gm).

        :param meta: meta data a point generator requires
        :param **kwargs: depend on gen_method
        return: configuration/point generated
        """
        if self.seed:
            self.id = uuid.UUID(int=random.getrandbits(self.seed))
        else:
            self.id = uuid.uuid4()
        configuration = self.gen_method(self.s, self.id, **kwargs)

        return configuration
