# This file was generated by mettle.genes.db.GenPy3 [ver 2.1] on Mon Feb 15 23:21:02 2021
#

import copy
import datetime
import uuid
import time
import mettle.lib
import mettle.io
import mettle.db

class iMsgReqUpdateStatus(mettle.io.ISerializable):

    def __init__(self,
                 id: int = 0,
                 status: str = '',
                 time_proc: datetime.datetime = datetime.datetime.min,
                 modified_by: str = ''):
        """
        Constructor.

        :param id: int
        :param status: str
        :param time_proc: datetime.datetime
        :param modified_by: str
        """
        self.id = id
        self.status = status
        self.time_proc = time_proc
        self.modified_by = modified_by

    def clear(self):
        """
        Clears all member variables for this database record.
        """
        self.id = 0
        self.status = ''
        self.time_proc = datetime.datetime.min
        self.modified_by = ''

    def _name(self) -> str:
        """
        Name of the record.

        :return: The name.
        """
        return 'iMsgReqUpdateStatus'

    def _serialize(self, _w: mettle.io.IWriter, _oname: str = None):
        """
        Serialize record to a stream.

        :param _w:
        :param _oname:
        """
        if _oname == None:
            _oname = self._name()

        _w.write_start(_oname)
        _w.write_int64("id", self.id)
        _w.write_char("status", self.status)
        _w.write_datetime("time_proc", self.time_proc)
        _w.write_string("modified_by", self.modified_by)
        _w.write_end(_oname)

    def _deserialize(self, _r: mettle.io.IReader, _oname: str = None):
        """
        Deserialize record from a stream.

        :param _r:
        :param _oname:
        """
        if _oname == None:
            _oname = self._name()

        _r.read_start(_oname)
        self.id = _r.read_int64("id")
        self.status = _r.read_char("status")
        self.time_proc = _r.read_datetime("time_proc")
        self.modified_by = _r.read_string("modified_by")
        _r.read_end(_oname)

    def _copy_from(self, rec: "iMsgReqUpdateStatus"):
        """
        Copies the column from the rec into this record.

        :param rec: The source record.
        """
        self.id = rec.id
        self.status = rec.status
        self.time_proc = rec.time_proc
        self.modified_by = rec.modified_by

    @staticmethod
    def _cache_davs(dvc=None):
        """
        Cache the DAV into the dav cache (or create one) and return it.

        :param dvc: (mettle.lib.DavCache), target cache, if None a new one is created and returned.
        """
        if dvc is None:
            dvc = mettle.lib.DavCache()

        dvc.add_targ("id", mettle.lib.Dav(mettle.lib.Dav.eDavType.Min, 1))
        dvc.add_targ("id", mettle.lib.Dav(mettle.lib.Dav.eDavType.NotNull))
        dvc.add_targ("id", mettle.lib.Dav(mettle.lib.Dav.eDavType.Min, 1))
        dvc.add_targ("id", mettle.lib.Dav(mettle.lib.Dav.eDavType.NotNull))
        dvc.add_targ("status", mettle.lib.Dav(mettle.lib.Dav.eDavType.Min, 1))
        dvc.add_targ("status", mettle.lib.Dav(mettle.lib.Dav.eDavType.Max, 1))
        dvc.add_targ("status", mettle.lib.Dav(mettle.lib.Dav.eDavType.NotNull))
        dvc.add_targ("status", mettle.lib.Dav(mettle.lib.Dav.eDavType.In, ['P','B','R','C']))
        dvc.add_targ("modified_by", mettle.lib.Dav(mettle.lib.Dav.eDavType.NotNull))
        dvc.add_targ("modified_by", mettle.lib.Dav(mettle.lib.Dav.eDavType.Max, 128))

        return dvc

    def _get_davs(self, dvc=None):
        iMsgReqUpdateStatus._cache_davs(dvc)

    def __repr__(self) -> str:
        return '<MsgReq [id:%r, status:%.32s, time_proc:%s, modified_by:%.32s]>' % (
            self.id, self.status, self.time_proc, self.modified_by)


    class List(list, mettle.io.ISerializable):
        """
        List Class
        """

        def _name(self) -> str:
            """
            Name of the list.

            :return: The name
            """
            return 'iMsgReqUpdateStatus.List'

        def _serialize(self, _w: mettle.io.IWriter, _oname: str = None):
            """
            Serialize the list to a stream.

            :param _w:
            :param _oname:
            """
            if _oname == None:
                _oname = self._name()

            _w.write_start_list(_oname, len(self))

            for _rec in self:
                _rec._serialize(_w)

            _w.write_end(_oname)

        def _deserialize(self, _r: mettle.io.IReader, _oname: str = None):
            """
            Deserialize the list from a stream.

            :param _r:
            :param _oname:
            """
            if _oname == None:
                _oname = self._name()

            _cnt = _r.read_start_list(_oname)

            while _cnt >= 1:
                _rec  = iMsgReqUpdateStatus()
                _cnt -= 1
                _rec._deserialize(_r)
                self.append(_rec)

            _r.read_end(_oname)

        def __repr__(self) -> str:
            return '<iMsgReqUpdateStatus.List[%d]>' % (len(self))

        def _get_davs(self, dvc=None):
            return iMsgReqUpdateStatus._cache_davs(dvc)

