I have a class that needs to be able to look up values in a global stl map object. However, I don't want each class to have a copy since the global object is pretty large. My current implementation is like this:
#include obj.h
#include init.h
map <string, vector<float> > gMap;
main() {int argc, char* argv[1]) {
gMap = init(); // function in init.h that simply creates a map and returns it
MyObj ();
}
in obj.h, there is an extern to gMap.
I'm curious if there are better ways to accomplish what I want to here. Ideas?
I also plan to export this to Python via SWIG, and this presents a little problem in the current situation (this is some of the motivation for rethinking this). So if any solutions are simple enough to work with minimal problems in SWIG, that would be very good.
Thanks!