05-11-2010 09:25 AM
Hi,everyone
Is there any way to get the reference of a member in OOP ?
After creating a class and insert a member control into the cluster, I find that, when right click on it, there is no item of "creat -> reference" or "create -> property node" ?
So, How to get the reference or the property node of a member in OOP ?
Solved! Go to Solution.
05-11-2010 09:38 AM
Are you asking about LVOOP?
If so take a look at the shipping example for "Singlton" to see how you can work in a manner similar to 'by reference".
Ben
05-11-2010 11:18 AM
Hi
There are a few reasons you cant do what you want to do:
1. In regular LVOOP (as opposed to DVRs in LabVIEW 2009, or some other framework / design pattern) LabVIEW Objects are by-value, just like a cluster and therefore you cannot create a reference to a class.
2. A object control (ie what you get when you drop an object on a front panel) is a "black box" in that you cannot look inside. This is to support the notion that a class's data is private. This means that you cannot get a reference to any internal controls when its on a front panel
3. Control references are only valid for front panel controls, and therefore any class (or other LabVIEW data item) on a wire / shift register / constant / anywhere other than the front panel, will only have the data part of the control available.
To gain access to the elements inside a class, you need to create accessor VIs (you can easily create them by right clicking a the class (or folder within the class) in the Project Browser and choosing New->VI for Data Member Access. This VI would at least have an unbundle / bundle node (depending on whether its read/write) and could, if you want, have much more functionality such as range checking. You would then use this VI whenever you want to read the member your intersted in.
I hope this helps,
Shaun
05-11-2010 11:12 PM
Thanks Ben and shew82.
It's very helpful for me.