I've run into this problem a couple of times in the past few years trying to put various frameworks together using Matlab OO. One was an extension of the popular "xunit" framework on the File Exchange, and another is a framework to support save/load of object and nested trees to XML. The problem arises in that I want to define a static method in a base class to support some basic functionality, but it needs to know something about the subclass that originally created the function call.
There seems to be no way of doing this out of the box. Consider a base class called "Shape" and a subclass "Square". Consider "Shape" defines a static method "LoadFromFile". In this scenario, you could call "LoadFromFile" using: square.LoadFromFile(); However, within LoadFromFile, there is no way of knowing that this was called using the "Square" class.
An example of a use case for this is the XML save/load example. Consider the Shape save/load method. It is possble to create a generic load capability that can create a Shape object from a file. That file presumably knows what kind of shape it is. The static method "LoadFromFile" can then possibly create many different kind of Shapes, however if we called the method from "Square" class, we would want to make sure that we loaded a Square, and throw an error if the file happened to be for a Circle. Sure, I could overload LoadFromFile() within Square to accomplish this, but that type of thing could be handled in one place without duplicating code in every shape subclass if it was possible to infer the calling classname from within LoadFromFile.
I've gotten around this somewhat by requiring that subclasses overload the static method, then explicitly call the superclass static method. In this case, the superclass can query "dbstack" to determine the calling subclass. However this seems rather kludgy and fragile. Was wondering if anyone else has tackled this problem, or if there are any plans on adding this kind of capability.