| Directory: | ./ | 
|---|---|
| File: | include/tsid/bindings/python/solvers/HQPData.hpp | 
| Date: | 2025-05-10 01:12:46 | 
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 23 | 23 | 100.0% | 
| Branches: | 20 | 40 | 50.0% | 
| Line | Branch | Exec | Source | 
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2018 CNRS, NYU, MPI Tübingen | ||
| 3 | // | ||
| 4 | // This file is part of tsid | ||
| 5 | // tsid is free software: you can redistribute it | ||
| 6 | // and/or modify it under the terms of the GNU Lesser General Public | ||
| 7 | // License as published by the Free Software Foundation, either version | ||
| 8 | // 3 of the License, or (at your option) any later version. | ||
| 9 | // tsid is distributed in the hope that it will be | ||
| 10 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
| 11 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | // General Lesser Public License for more details. You should have | ||
| 13 | // received a copy of the GNU Lesser General Public License along with | ||
| 14 | // tsid If not, see | ||
| 15 | // <http://www.gnu.org/licenses/>. | ||
| 16 | // | ||
| 17 | |||
| 18 | #ifndef __tsid_python_test_hpp__ | ||
| 19 | #define __tsid_python_test_hpp__ | ||
| 20 | |||
| 21 | #include "tsid/bindings/python/fwd.hpp" | ||
| 22 | |||
| 23 | #include "tsid/bindings/python/utils/container.hpp" | ||
| 24 | |||
| 25 | namespace tsid { | ||
| 26 | namespace python { | ||
| 27 | namespace bp = boost::python; | ||
| 28 | |||
| 29 | template <typename T> | ||
| 30 | struct ConstPythonVisitor | ||
| 31 | : public boost::python::def_visitor<ConstPythonVisitor<T> > { | ||
| 32 | template <class PyClass> | ||
| 33 | |||
| 34 | 8 | void visit(PyClass& cl) const { | |
| 35 | 
        1/2✓ Branch 2 taken 8 times. 
          ✗ Branch 3 not taken. 
         | 
      8 | cl.def(bp::init<>("Default Constructor")) | 
| 36 | 16 | .def("print_all", &T::print) | |
| 37 | 
        2/4✓ Branch 1 taken 8 times. 
          ✗ Branch 2 not taken. 
          ✓ Branch 4 taken 8 times. 
          ✗ Branch 5 not taken. 
         | 
      8 | .def("append", &T::append_eq, bp::arg("data")) | 
| 38 | 
        2/4✓ Branch 1 taken 8 times. 
          ✗ Branch 2 not taken. 
          ✓ Branch 4 taken 8 times. 
          ✗ Branch 5 not taken. 
         | 
      16 | .def("append", &T::append_ineq, bp::arg("data")) | 
| 39 | 
        3/6✓ Branch 1 taken 8 times. 
          ✗ Branch 2 not taken. 
          ✓ Branch 4 taken 8 times. 
          ✗ Branch 5 not taken. 
          ✓ Branch 7 taken 8 times. 
          ✗ Branch 8 not taken. 
         | 
      8 | .def("append", &T::append_bound, bp::arg("data")); | 
| 40 | 8 | } | |
| 41 | |||
| 42 | 8 | static void expose(const std::string& class_name) { | |
| 43 | 
        1/2✓ Branch 2 taken 8 times. 
          ✗ Branch 3 not taken. 
         | 
      8 | std::string doc = "ConstraintLevel info."; | 
| 44 | 
        1/2✓ Branch 3 taken 8 times. 
          ✗ Branch 4 not taken. 
         | 
      8 | bp::class_<T>(class_name.c_str(), doc.c_str(), bp::no_init) | 
| 45 | 
        1/2✓ Branch 1 taken 8 times. 
          ✗ Branch 2 not taken. 
         | 
      8 | .def(ConstPythonVisitor<T>()); | 
| 46 | 8 | } | |
| 47 | }; | ||
| 48 | |||
| 49 | template <typename T> | ||
| 50 | struct HQPPythonVisitor | ||
| 51 | : public boost::python::def_visitor<HQPPythonVisitor<T> > { | ||
| 52 | template <class PyClass> | ||
| 53 | |||
| 54 | 8 | void visit(PyClass& cl) const { | |
| 55 | 
        1/2✓ Branch 2 taken 8 times. 
          ✗ Branch 3 not taken. 
         | 
      8 | cl.def(bp::init<>("Default Constructor")) | 
| 56 | 16 | .def("print_all", &T::print) | |
| 57 | 
        2/4✓ Branch 1 taken 8 times. 
          ✗ Branch 2 not taken. 
          ✓ Branch 4 taken 8 times. 
          ✗ Branch 5 not taken. 
         | 
      8 | .def("resize", &T::resize, bp::arg("i")) | 
| 58 | 
        3/6✓ Branch 1 taken 8 times. 
          ✗ Branch 2 not taken. 
          ✓ Branch 4 taken 8 times. 
          ✗ Branch 5 not taken. 
          ✓ Branch 7 taken 8 times. 
          ✗ Branch 8 not taken. 
         | 
      8 | .def("append", &T::append_helper, bp::arg("constraintLevel")); | 
| 59 | 8 | } | |
| 60 | |||
| 61 | 8 | static void expose(const std::string& class_name) { | |
| 62 | 
        1/2✓ Branch 2 taken 8 times. 
          ✗ Branch 3 not taken. 
         | 
      8 | std::string doc = "HQPdata info."; | 
| 63 | 
        1/2✓ Branch 3 taken 8 times. 
          ✗ Branch 4 not taken. 
         | 
      8 | bp::class_<T>(class_name.c_str(), doc.c_str(), bp::no_init) | 
| 64 | 
        1/2✓ Branch 1 taken 8 times. 
          ✗ Branch 2 not taken. 
         | 
      8 | .def(HQPPythonVisitor<T>()); | 
| 65 | 8 | } | |
| 66 | }; | ||
| 67 | |||
| 68 | } // namespace python | ||
| 69 | } // namespace tsid | ||
| 70 | |||
| 71 | #endif // ifndef __tsid_python_test_hpp__ | ||
| 72 |