Open xcasas opened 3 years ago
I have used a similar pattern in a Python library (nplab
) where we had a method to return an instance, and also a method to return all instances (e.g. if you have more than one camera or stage). I guess there is already a notion of the default camera/stage in MMCore, so unlike my implementation, there's a well-defined behaviour for which device you get if you have several!
That's exactly what I was thinking actually, I think it's a really nice implementation you have in the class Instrument
in nplab/init.py, since all your devices (I think) are a subclass of Instrument
then that function will be inherited. That could be done similarly in MMCore with MMDevice, although it probably needs to be a bit different since it will be called from other programming languages like Java or Python, but I guess it could be done the same way pymmcore
returns a pointer to MMCore.
As you said I think for MMCore initially there was a clear behaviour, but I'm thinking if people want to use the device layer exclusively, they could highly benefit from that. I have been trying myself to do that but since I have one class per device it was hard to think of an architecture compatible with MMCore.
Hey :)
I was reading the manuscript and you mention that it should be possible to have other implementations where pointers to the devices would be possible and I just thought of this idea:
You could have a function in MMCore called getInstance or getPointer, for example, and send as a parameter the device name. I think that would be very beneficial for languages like python, where we could do something like:
And then, one could directly have that pointer associated with an object in some object-oriented language like Python. The only thing is that:
It would be nice if it is then possible to call functions from that device directly by using the pointer. So in that case, then the class could directly call, for example, camera.snapImage(), instead of core.snapImage(). That would be nice for using multiple cameras, in my opinion.
I don't know if it makes sense. I hope I understood the scope correctly. But in this case, you could keep the same architecture as now, everything going through the MMCore but at the same time enable modularity from other languages.