Am Montag, 8. September 2014, 10:53:27 schrieb Barry Smith: > > On Sep 8, 2014, at 2:19 AM, Florian Lindner <[email protected]> wrote: > > > > > I want to offer an interface that uses some Petsc types (like Vec and Mat) > > but I do not want to import all petsc symbols into the global namespace for > > anyone using the interface. That does not seam possible though... > > > > Thanks, > > > > Florian > > Which symbols do you want to have available and which ones not? Do you not > want to use the other symbols but not let the user use them, for example, you > want to use KSP but don’t want the user to have access to them? Or something > else. Note that you can configure PETSc into several libraries and then use > only the ones you want with -with-single-library=no it creates a separate > TS, SNES, KSP, DM, Mat,and Vec library. > > Let us know what you want in more detail and we may have suggestions on > how to achieve it.
Thanks for your help! If a user of my class library does an #include "mypetsc.h" he should not get all the petsc symbols in his global namespace, e.g. #include "mypetsc.h" Vector v; // is an object of my class lib Vec pv; // should not work, since I do not want petsc symbols in my global namespace petsc::Vec pv; // fine, since petsc symbols are contained in namespace petsc. But this does not seem to be possible. petsc::Vec = v.vector // vector of type petsc::Vec is a public member of Vector. That's why "mypetsc.h" needs to #include "petscvec.h". Because of that an #include "mypetsc" imports all the symbols of "petscvec" into anyone wanting to use Vector. Since "mypetsc.h" only contains declarations and no code I tried it with forward declarations of Vec, but no success. At the end an #include "mypetsc.h" should import only my own symbols like Vector and Matrix. It would be ok, if it also imports Vec and Mat (which are types of public members / return types of public functions). It would also be ok, if it imports all other petsc symbols (like VecGetOwnershipRange) in a seperate namespace. I hope I was able to convey what I want... Thx, Florian
