c++ - How do I register global variables independently in a single global array -


i'm writing this, well, call library guess. offers set of global variables of type mytype. now, want write source of each of these mytype's in own .cpp , .h files, unaware of rest, without needing central header file saying mytype* offerings = { &global1, &global2, /*... */ }.

now, had these been different classes want able instantiate, want use factory pattern; here they're of same type, , don't need instantiate anything. think each variable needs 'registered' global array (or unordered set) somewhere in sources.

so, what's idiomatic way this?

you take @ registry pattern , create manager filesystem or folder manage these objects.

the registry have related filesystem handling insert object names , properties in model in 1 config file or database. registry , instantiate objects on runtime.

now need mechanism communicate objects rest of system. if objects not going change registry compile time objects do.

the registry pattern handle global objects in similar fashion singleton.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -