#  Copyright (C) 2017 The authors of Py-ChemShell
#
#  This file is part of Py-ChemShell.
#
#  Py-ChemShell is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Lesser General Public License as
#  published by the Free Software Foundation, either version 3 of the
#  License, or (at your option) any later version.
#
#  Py-ChemShell is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with Py-ChemShell.  If not, see
#  <http://www.gnu.org/licenses/>.

from ctypes    import Structure
from ..io      import keyword
from ..dl_py2f.utils import objutils

class Objects(Structure):
    '''Template of ChemShell object types (Fragment, Shell, BackgroundQ, etc.)'''

    # user attributes (will be received by Fortran)
    _kwargs = {}
    _keywords = {}

    # internal attributes (will not be received by Fortran)
    _internals = {}

    # synonyms
    _synons = {}

    # priorities for initialisation and keyword arguments
    _priorities = ()

    # anything in this list will be converted to a @property with setter
    _properties = ()

    # to inherit: only sequences allowed here!
    _inherit = '_init', '_priorities', '_properties'

    # to initialise: all items in dicts and sequences themselves such as `_fields` (rather than items in sequences)
    _init = '_kwargs', '_internals'


    # initialise defaults
    @objutils.init()
    def __init__(self, *args, **kwargs):
        '''Initialise'''

        # initialise keyword arguments
        keyword.parseKeys(self, *args, **kwargs)


    # protect internal attributes, see: https://docs.python.org/3/reference/datamodel.html
#    __all__ = list(_kwargs.keys())

    @property
    def __all__(self):
        ''''''

        return sorted(list(self._kwargs.keys()))


    def getDtype(self, field):
        '''Return dtype.descr'''

        return getattr(self, field).dtype.descr




