# This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.1.1
#
# Do not make changes to this file unless you know what you are doing - modify
# the SWIG interface file instead.

from sys import version_info as _swig_python_version_info
# Import the low-level C/C++ module
if __package__ or "." in __name__:
    from . import _progress
else:
    import _progress

try:
    import builtins as __builtin__
except ImportError:
    import __builtin__

def _swig_repr(self):
    try:
        strthis = "proxy of " + self.this.__repr__()
    except __builtin__.Exception:
        strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)


def _swig_setattr_nondynamic_instance_variable(set):
    def set_instance_attr(self, name, value):
        if name == "this":
            set(self, name, value)
        elif name == "thisown":
            self.this.own(value)
        elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
            set(self, name, value)
        else:
            raise AttributeError("You cannot add instance attributes to %s" % self)
    return set_instance_attr


def _swig_setattr_nondynamic_class_variable(set):
    def set_class_attr(cls, name, value):
        if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
            set(cls, name, value)
        else:
            raise AttributeError("You cannot add class attributes to %s" % cls)
    return set_class_attr


def _swig_add_metaclass(metaclass):
    """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
    def wrapper(cls):
        return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
    return wrapper


class _SwigNonDynamicMeta(type):
    """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
    __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)


DEFINITE = _progress.DEFINITE
LOGDEFINITE = _progress.LOGDEFINITE
INDEFINITE = _progress.INDEFINITE
class Progress(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _progress.delete_Progress

    def setProgressBar(self, arg2):
        return _progress.Progress_setProgressBar(self, arg2)

    def hasProgressBar(self):
        return _progress.Progress_hasProgressBar(self)

    def started(self):
        return _progress.Progress_started(self)

    def finish(self):
        return _progress.Progress_finish(self)

    def finished(self):
        return _progress.Progress_finished(self)

    def stop(self):
        return _progress.Progress_stop(self)

    def stopped(self):
        return _progress.Progress_stopped(self)

    def setMessage(self, arg2):
        return _progress.Progress_setMessage(self, arg2)

    def setFraction(self, arg2):
        return _progress.Progress_setFraction(self, arg2)

    def message(self):
        return _progress.Progress_message(self)

    def name(self):
        return _progress.Progress_name(self)

    def id(self):
        return _progress.Progress_id(self)

    def acquireThreadLock(self):
        return _progress.Progress_acquireThreadLock(self)

    def releaseThreadLock(self):
        return _progress.Progress_releaseThreadLock(self)

    def disconnectBar(self, arg2):
        return _progress.Progress_disconnectBar(self, arg2)

    def __eq__(self, other):
        return _progress.Progress___eq__(self, other)

    def __hash__(self):
        return _progress.Progress___hash__(self)

# Register Progress in _progress:
_progress.Progress_swigregister(Progress)
class DefiniteProgress(Progress):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr

    def getFraction(self):
        return _progress.DefiniteProgress_getFraction(self)
    __swig_destroy__ = _progress.delete_DefiniteProgress

# Register DefiniteProgress in _progress:
_progress.DefiniteProgress_swigregister(DefiniteProgress)
class LogDefiniteProgress(DefiniteProgress):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr

    def setRange(self, arg2, arg3):
        return _progress.LogDefiniteProgress_setRange(self, arg2, arg3)
    __swig_destroy__ = _progress.delete_LogDefiniteProgress

# Register LogDefiniteProgress in _progress:
_progress.LogDefiniteProgress_swigregister(LogDefiniteProgress)
class IndefiniteProgress(Progress):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr

    def pulse(self):
        return _progress.IndefiniteProgress_pulse(self)

    def pulsecount(self):
        return _progress.IndefiniteProgress_pulsecount(self)
    __swig_destroy__ = _progress.delete_IndefiniteProgress

# Register IndefiniteProgress in _progress:
_progress.IndefiniteProgress_swigregister(IndefiniteProgress)

def getProgress(arg1, arg2):
    return _progress.getProgress(arg1, arg2)

def findProgress(arg1):
    return _progress.findProgress(arg1)

def findProgressByID(arg1):
    return _progress.findProgressByID(arg1)
# -*- python -*-

# This software was produced by NIST, an agency of the U.S. government,
# and by statute is not subject to copyright in the United States.
# Recipients of this software assume all responsibilities associated
# with its operation, modification and maintenance. However, to
# facilitate maintenance we ask that before distributing modified
# versions of this software, you first contact the authors at
# oof_manager@nist.gov.

# ProgressIterator is a base class for iterators that are compatible
# with progress bars and Progress objects. They have the benefits of a
# simple generator while also giving information about how the
# iteration is progressing.

# Subclasses must define self.targets(), which returns an iterable
# object that returns the set of things to be examined or an iterator
# for it, and self.ntotal(), which returns the total number of things
# that will be returned.

# Use it something like this:
#   iter = SomeSubClassOfProgressIterator()
#   prog = progress.getProgress(...)
#   for obj in iter:
#      ....
#      prog.setFraction(iter.fraction())
#      prog.setMessage(f"{iter.nexamined()}/{iter.ntotal()}")
#

# The ProgressIterator constructor has an optional "condition"
# argument.  If provided, only objects obj for which condition(obj) is
# true will be returned by the iterator.

class ProgressIterator:
    def __init__(self, condition=None):
        self.condition = condition # predicate
        self.count = 0          # number examined
        self.nret = 0           # number returned
    def fraction(self):
        return self.count/self.ntotal()
    def nexamined(self):
        return self.count
    def nreturned(self):
        return self.nret
    def __iter__(self):
        if self.condition is not None:
            for self.count, target in enumerate(self.targets()):
                if self.condition(target):
                    self.nret += 1
                    yield target
        else:
            for self.count, target in enumerate(self.targets()):
                self.nret += 1
                yield target
    def __len__(self):
        return self.ntotal()

# ContainerIterator turns a regular container object (or other
# iterable that defines __len__) into a ProgressIterator.

class ContainerIterator(ProgressIterator):
    def __init__(self, data, condition=None):
        self.data = data
        ProgressIterator.__init__(self, condition)
    def ntotal(self):
        return len(self.data)
    def targets(self):
        return self.data




