// Copyright (C) 2026 EDF
// All Rights Reserved
// This code is published under the GNU Lesser General Public License (GNU LGPL)
#include <pybind11/pybind11.h>
#include "StOpt/core/utils/version.h"

namespace py = pybind11;

//  declare functons defined elsewhere
void initTree(py::module_ &);
void initRegression(py::module_ &);
void initGeners(py::module_ &);
void initCDF(py::module_ &);
void initGlobal(py::module_ &);
void initGrids(py::module_ &);
#ifdef SDDPPYTHON
void initSDDP(py::module_ &);
#endif

PYBIND11_MODULE(pystopt, m)
{
    m.doc() = "Bindings Pybind11 for StOpt";
    // version
    m.def("getVersion", StOpt::getStOptVersion);

    // Submodule
    auto mTree         = m.def_submodule("tree",         "Tree module");
    auto mRegression   = m.def_submodule("regression",   "Regression module");
    auto mGeners       = m.def_submodule("geners", "Geners serialization module");
    auto mCDF          = m.def_submodule("cdf", "fast cdf module");
    auto mGlobal       = m.def_submodule("glob", "high level python binding module");
    auto mGrids        = m.def_submodule("grids", "grids module");
    // initialisation
    initTree(mTree);
    initRegression(mRegression);
    initGeners(mGeners);
    initCDF(mCDF);
    initGlobal(mGlobal);
    initGrids(mGrids);
#ifdef SDDPPYTHON
    auto mSDDP         = m.def_submodule("sddp", "stochastic dual dynamic programming  module");
    initSDDP(mSDDP);
#endif
}
