I need to create an object that will represent the state of the table, and I want to be able to use that same object from other QActions, however my object needs to be declared on an element level, meaning each element of that protocol will have it's own single instance(singleton). I cannot use static as that would mean that all elements running that protocol will share the instance, and their table states may differ. I would like to avoid having to store the state in a dummy parameter within the actual table because that would beat the purpose of storing the state of the table in the object in the first place. Would this even be possible? I'm open to creative solutions as well, even if just as a though experiment.
Could you elaborate a bit more on the reason for needing to have the info in memory?
Is it because the table is changing from different sources? Or too slow to read from within the QAction due to size?
Because having to maintain 2 copies of the same data can present some challenges especially if you start to have to deal with concurrency.
In any case, you could still use a static object as long as you have a way of indexing the data, so something like a static Dictionary where the key is the element ID in the format of <dataminerId>/<elementId> to ensure uniqueness even when dealing with migrated elements.
You would also need to make sure when the element is stopping or gets deleted that you delete the static data entry.
Another alternative would be to have an instanced QAction with a local field/property that would store the value in between executions.
Do note that with this last approach, you would need to have all your entry points in the same QAction