#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# michael a.g. aïvázis
# orthologue
# (c) 1998-2023 all rights reserved
#


# access to the framework
import pyre

# declare the gauss application
class Gauss(pyre.application):
    """
    Builds and invokes an integrator
    """

    # types
    from gauss.integrators import integrator, montecarlo

    # public state
    engine = integrator()

    # interface
    @pyre.export
    def main(self):
        """
        Invoke my {integrator} to perform some integral
        """
        # carry out the integration and print out the result
        self.info.line("integral = {}".format(self.engine.integrate()))
        # return with success
        return 0


# main
if __name__ == "__main__":
    # check whether the user supplied a name for the application
    name = pyre.executive.nameserver.get(name='name', default='sample')
    # instantiate
    app = Gauss(name=name)
    # get the engine
    engine = app.engine
    # print out the application configuration
    app.info.line("application {!r}".format(app.pyre_name))
    app.info.line("  integrator: {!r}".format(engine.pyre_family()))
    app.info.line("  region: {!r}".format(engine.region.pyre_family()))
    app.info.line("  integrand: {!r}".format(engine.integrand.pyre_family()))
    # invoke
    status = app.main()
    # flush
    app.info.log()
    # return the status to the os
    raise SystemExit(status)


# end of file
