Is there a way to assign a stored state to a process node?

I have a rather non-trivial question.
Is there a way to turn an object stored in a pad into a process node?
Roughly speaking, assign this state to a process node
I’m almost certainly missing something obvious… or am I?

processnode_pad_to_node.vl (8.1 KB)

No. The job of a process node is mainly to take care of the lifetime of one single instance of that type - at least when it is a mutable object (Class).

Taking care of the lifetime of this object can involve some necessary steps at the end of the lifetime. A process node allows you to get a hand on that managed instance via the state output pin as you show in your patch, but it doesn’t allow you to change it.

In theory, swapping out the managed instance for another one could be implemented by disposing of the formerly managed instance and then taking over the ownership of the newly assigned instance - making sure that this one now gets disposed of at the end of the lifetime of the surrounding patch.

So in theory we could have that feature, but currently, it is not possible and I have no use case in mind. Why would we need that?

If you need a more dynamic lifetime management of a single instance maybe the ManagedProcess region can help out. In this case, you can still use the original process node inside the region.
processnode_pad_to_node_1.vl (12.5 KB)

Thanks!
This is a very hypothetical question. I was just experimenting with TryCreateService and noticed that I could get the class but not the node. Seemed like a small loss, but I thought, what if there is such a way?

What I really don’t understand is why there is a ManageProcess region? I have tried many times to understand why it is needed and some scenarios of its use. I have seen this region being discussed on the forum and in the chat. I feel like all the grown up guys understand it, but I don’t) Can you explain in a nutshell why it might be needed and why it was created? By the way, maybe as you mentioned, in some scenarios I’ve imagined, ManageProcess is needed instead of reassigning an instance in the Process node.

By the way, it looks like the Lifespan input doesn’t do much:

Wait a second. Let’s stick with the topic of the thread.
What is it that you wanted to do in the first place? I am confused.

offtopic:
ManageProcess in short: Normally all process node in your patch have the same lifespan as the patch itself. ManageProcess allows you to change that for the nodes inside the region and give them a shorter lifespan, recreate that part of your patch when necessary. It allows you to disable the region - the nodes still are alive but not running (Update not called)… If lifespan = short and disabled or reset called then stuff gets disposed of, otherwise it only doesn’t get updated.
We invented it very early when it became obvious that white pins sometimes can get in your way. With ManageProcess you can move process nodes to update. ManageProcess will create them in the first frame on update.