#!/usr/bin/env python
# coding=utf-8

# Copyright © 2016 ButenkoMS. All rights reserved. Contacts: <<EMAIL>>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from cengal.system import PLATFORM_NAME
if 'PyPy' != PLATFORM_NAME:
    import uuid
from enum import Enum

"""
Module Docstring
Docstrings: http://www.python.org/dev/peps/pep-0257/
"""

__author__ = "ButenkoMS <<EMAIL>>"
__copyright__ = "Copyright © 2016 ButenkoMS. All rights reserved. Contacts: <<EMAIL>>"
__credits__ = ["ButenkoMS <<EMAIL>>", ]
__license__ = "Apache License, Version 2.0"
__version__ = "1.0.0"
__maintainer__ = "ButenkoMS <<EMAIL>>"
__email__ = "<EMAIL>"
# __status__ = "Prototype"
__status__ = "Development"
# __status__ = "Production"


class TypeOfGenerator(Enum):
    INTEGER = 0
    GUID_STRING = 1

    # _VALUES_TO_NAMES = {
    #     0: "INTEGER",
    #     1: "GUID_STRING",
    # }
    #
    # _NAMES_TO_VALUES = {
    #     "INTEGER": 0,
    #     "GUID_STRING": 1,
    # }


class IDGenerator:

    def __init__(self, type=TypeOfGenerator.INTEGER):
        self.counter = 0
        self.type = type

    def get_new_ID(self):
        currentCounter = None
        if TypeOfGenerator.INTEGER == self.type:
            currentCounter = self.counter
            self.counter += 1
        elif TypeOfGenerator.GUID_STRING == self.type:
            seq = self.counter
            self.counter += 1
            currentCounter = uuid.uuid1(clock_seq=seq).hex
        return currentCounter

    def remove_ID(self, ID):
        pass

    def clear(self):
        self.counter = 0

    def __call__(self):
        return self.get_new_ID()

#!/usr/bin/env python
# coding=utf-8

# Copyright © 2016 ButenkoMS. All rights reserved. Contacts: <<EMAIL>>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from cengal.system import PLATFORM_NAME
if 'PyPy' != PLATFORM_NAME:
    import uuid
from enum import Enum

"""
Module Docstring
Docstrings: http://www.python.org/dev/peps/pep-0257/
"""

__author__ = "ButenkoMS <<EMAIL>>"
__copyright__ = "Copyright © 2016 ButenkoMS. All rights reserved. Contacts: <<EMAIL>>"
__credits__ = ["ButenkoMS <<EMAIL>>", ]
__license__ = "Apache License, Version 2.0"
__version__ = "1.0.0"
__maintainer__ = "ButenkoMS <<EMAIL>>"
__email__ = "<EMAIL>"
# __status__ = "Prototype"
__status__ = "Development"
# __status__ = "Production"


class TypeOfGenerator(Enum):
    INTEGER = 0
    GUID_STRING = 1

    # _VALUES_TO_NAMES = {
    #     0: "INTEGER",
    #     1: "GUID_STRING",
    # }
    #
    # _NAMES_TO_VALUES = {
    #     "INTEGER": 0,
    #     "GUID_STRING": 1,
    # }


class IDGenerator:

    def __init__(self, type=TypeOfGenerator.INTEGER):
        self.counter = 0
        self.type = type

    def get_new_ID(self):
        currentCounter = None
        if TypeOfGenerator.INTEGER == self.type:
            currentCounter = self.counter
            self.counter += 1
        elif TypeOfGenerator.GUID_STRING == self.type:
            seq = self.counter
            self.counter += 1
            currentCounter = uuid.uuid1(clock_seq=seq).hex
        return currentCounter

    def remove_ID(self, ID):
        pass

    def clear(self):
        self.counter = 0

    def __call__(self):
        return self.get_new_ID()

#!/usr/bin/env python # coding=utf-8 # Copyright © 2016 ButenkoMS. All rights reserved. Contacts: <<EMAIL>> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # #     http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. Module Docstring Docstrings: http://www.python.org/dev/peps/pep-0257/ # __status__ = "Prototype" # __status__ = "Production" # _VALUES_TO_NAMES = { #     0: "INTEGER", #     1: "GUID_STRING", # } # # _NAMES_TO_VALUES = { #     "INTEGER": 0, #     "GUID_STRING": 1, # }