curious_one said:
Hi,
Is there a way to access a single instance of an object(singleton
class) across different processes ?
thanks
curious.one
cross posting to 4 groups is going to annoy some people.
comp.lang.c++ answer : c++ has no knowledge of process. What your
question got to do with the c++ language ?
comp.unix.internals : what's an object ? what's a singleton ?
comp.unix.programmer : no answer
comp.unix.solaris : java has JVM's and you can't do anything a JVM can't
do !
So the true answer to your question is that if you want to share a
singleton you need to allocate it in shared memory. Now you run into
problems of address mapping. The object may be in a different address
in different processes. Not only that, any virtual methods almost
certainly will cause trouble since they won't be mapped to the same
addresses either (if they exist at all).
So far, your singleton is very limited in ability.
So, if you're still interested because this is really what you need,
then you may get some help from some mutex library.
So there are some C++ template classes that could help (like a
relocating smart pointer that relocates addresses dynamically) and a few
others to deal with finding the right methods in a process.
More than this is hard to specuate ...
G