Git Product home page Git Product logo

Comments (5)

joaoleal avatar joaoleal commented on August 22, 2024

Hello Adjel,

The function is returning a LinuxDynamicLib by value but this class has no copy or move constructor implemented.
I can consider adding a move constructor to make it easier to return it from functions or move it as an argument to functions/methods.

You could return a smart pointer from your function instead:

std::unique_ptr<LinuxDynamicLib<Scalar>> loadLibrary(std::vector<std::unique_ptr<GenericModel<Scalar>>> & models){

        std::unique_ptr<LinuxDynamicLib<Scalar>> myLib(new LinuxDynamicLib<Scalar>("./fkine_angular_IMU1.so"));  //Instantiation of the dynamic library
        std::unique_ptr<GenericModel<Scalar>> myModel = myLib->model("fkine_angular_IMU1"); //Instantiation of the model, from the dynamic library
        models.push_back(std::move(myModel));
        return myLib;
    }

If you are using C++14 you may be insterested in using

auto myLib = std::make_unique<LinuxDynamicLib<Scalar>>("./fkine_angular_IMU1.so");

from cppadcodegen.

mohamdev avatar mohamdev commented on August 22, 2024

Thank you very much for your fast feedback, I will try this as soon as possible and tell you if it worked in my case

from cppadcodegen.

mohamdev avatar mohamdev commented on August 22, 2024

I just tried it and it worked wonderfully, thank you very much. By the way, when generating and compiling the DynamicLibrary, do you think that it's possible to add several models based on different ADfun in a single library ? Allowing me then to instantiate all my models from a single library this way :

        std::unique_ptr<LinuxDynamicLib<Scalar>> myLib(new LinuxDynamicLib<Scalar>("./nameMyLib.so"));  //Instantiation of the dynamic library
        std::unique_ptr<GenericModel<Scalar>> myModel1 = myLib->model("nameModel1");  //Instantiation model 1
        std::unique_ptr<GenericModel<Scalar>> myModel2 = myLib->model("nameModel2"); //Instantiation model 2
        std::unique_ptr<GenericModel<Scalar>> myModelN = myLib->model("nameModelN"); //Instantiation model N

from cppadcodegen.

joaoleal avatar joaoleal commented on August 22, 2024

This is already possible.
You can add multiple models to a ModelLibraryCSourceGen by either adding them to the constructor:

ModelCSourceGen<double> model1(adFun1, "nameModel1");
ModelCSourceGen<double> model2(adFun2, "nameModel2");
ModelCSourceGen<double> model3(adFun3, "nameModel3");

ModelLibraryCSourceGen<double> modelLibGen(model1, model2, model3);

or afterwars:

ModelCSourceGen<double> model3(fun1, "nameModel3");
modelLibGen.addModel(model3);

from cppadcodegen.

mohamdev avatar mohamdev commented on August 22, 2024

It worked great ! Thank you very much for your fast feedback :) have a nice day

from cppadcodegen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.