LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

singletone inheritance

Hi!

I implemented a framework based on pluggins, in which there is a GeneralPluggin and five child pluggins that adds some funcionality. I realized that these pluggins coorespond to the singleton pattern so I used the Goop tool to create them in this way. Due to they inherit from a not singletone class to use the parent vis I made public the "Get_Instance" vi despite I knew it was wrong, the problem with it is that the program creates some instances with the same reference, but ones are filled with the correct data and the other are empty. To solve this issue I'm trying to redo the Genericpluggin class in the singletone pattern and inherit from it again.

 

But I have some questions, how can the child classes access to the parent atributes and vi's? And how can they know which class is the proper child class which is calling the paret funcionality if there is not " class reference In "  in the vi, as it is singleton....

For instance in a normal class you wire the child class calling a parent vi, and as you wire the class in, it knows which child function should call but in this case... I'm a bit confused!!!

 

Thanks in advance!!!

0 Kudos
Message 1 of 6
(2,378 Views)

You should be able to call parents attributes and VIs just by using the corresponding functions of the parent class with the wire of the child.

The fact that you use a singleton design should not change this behaviour as it only allows one instance of that class during runtime.

 

Or am I completely wrong here?

Also confused (:

0 Kudos
Message 2 of 6
(2,372 Views)

I saw in other thread a possible solution, inherit from a normal class and make the children singleton should work. I could try to make the GenericPlugin with goop (after it is done by LabView normal class) which I think it will work better. But I have the same doubts... How can I call the children instances? Implementing a "Must Override" method "GetInstance" and calling this method inside the funcional father Vi...?

0 Kudos
Message 3 of 6
(2,371 Views)

Well, the point is that in singletone structures you don't have to wire an object like an input to the vi's because it calls internally to the GetInstance structure, so if I want to use the same parent funcionality from two different children, how does it work?

For instance, I have in the parent class an atribute called name, and to different pluging which inherit from this one, one is called acquisition, and the other one tracking, If I drag the parent vi "GetName" which does not recieve an input specifying the class type and inside this Vi it calls to the parent "GetInstance" to have access to its attributes how LabView know if I asking for "Tracking" or for "Acquisition" atributte??

 

THANKS!!!!

0 Kudos
Message 4 of 6
(2,370 Views)

Hm sorry for my comment,

I still try to learn LV OOP by desperately trying to understand these posts (https://decibel.ni.com/content/docs/DOC-13462)... I did not even realize from the NI post that your class works without class wires afterwards. Smiley Sad

Without a class wire or something like this I can not imagine a way to call parent functions on children. Maybe just inherit the function by creating a Vi calling the GetInstance and then the parent function as a (dumb) work-around.

0 Kudos
Message 5 of 6
(2,366 Views)

Nevermind it is nice at least you tried 🙂

 

I have thought about it, but i still have to point somehow which is the child class calling, and without a wire nor I know how to manage it. :S

0 Kudos
Message 6 of 6
(2,361 Views)