Rammer Posted September 4, 2009 Report Share Posted September 4, 2009 Hello, OOP developers. I am trying to develop a class that is essentially a repository for classes created in an application. Then by simply passing this single class I can gain access to any class in the application. However I am struggling. I use the Endevo GOOP for my class development. For the ObjectManager class I created an attribute that is essentially an array of LabVIEW Object classes since any and all classes derive from this class. I can successfully cast my custom classes to a more generic labVIEW Object; however searching and retrieving the specific class later becomes an issue. Below is a screen capture I take a specific class and cast it down to it's fundamental parent. With the objects being debuged I can see the actual data type of the class, however the comparison is never true. I am guessing that somehow it retains the reference data information and that is why it is not being found. Has anyone tried this? J Hello, OOP developers. I am trying to develop a class that is essentially a repository for classes created in an application. Then by simply passing this single class I can gain access to any class in the application. However I am struggling. I use the Endevo GOOP for my class development. For the ObjectManager class I created an attribute that is essentially an array of LabVIEW Object classes since any and all classes derive from this class. I can successfully cast my custom classes to a more generic labVIEW Object; however searching and retrieving the specific class later becomes an issue. Below is a screen capture I take a specific class and cast it down to it's fundamental parent. With the objects being debuged I can see the actual data type of the class, however the comparison is never true. I am guessing that somehow it retains the reference data information and that is why it is not being found. Has anyone tried this? J Yes - the array does include one of the classes being searched for. The probes just show the last element of the array which is another class... Quote Link to comment
Aristos Queue Posted September 5, 2009 Report Share Posted September 5, 2009 The equals operation is a *value* comparison, not a reference comparision. All of the fields of the object must match exactly for equals to return true. We do not have any concept of a reference of the object. Quote Link to comment
K-node Posted September 6, 2009 Report Share Posted September 6, 2009 I am developing something similar. For simplicity I added a string variable to the base object representing a name and also had the 'ObjectManager' keep a separate array of strings. So, I search for an object by name using the 1D array search function. The index found is used in the return the object from the ObjectManager's list. I am doing this in LV2009 not Endevo so I cannot help you on that front. And I don't actually pass around the ObjectManager. I actually have several ObjectManagers and have ManagerOfManagers so to speak to handle the sharing of the ObjectManagers. This in the end may have been overkill but the implementation was fun. Quote Link to comment
Rammer Posted September 6, 2009 Author Report Share Posted September 6, 2009 I am developing something similar. For simplicity I added a string variable to the base object representing a name and also had the 'ObjectManager' keep a separate array of strings. So, I search for an object by name using the 1D array search function. The index found is used in the return the object from the ObjectManager's list. I am doing this in LV2009 not Endevo so I cannot help you on that front. And I don't actually pass around the ObjectManager. I actually have several ObjectManagers and have ManagerOfManagers so to speak to handle the sharing of the ObjectManagers. This in the end may have been overkill but the implementation was fun. NI - Isn't there a way to compare the data types as equal "values"? There are many ways around the problem. Adding the string as you said works good, you just need to make sure you know the name and spell it correctly . However, there fundamentally should be a way to say give me this object by just inputing the object itself, thus using the power of true OO design.... I have not moved to 2009 yet (waiting for GOOP release to match). Has the LabVIEW Object expanded? Is there a way to get some information about an object inherently - like what it's name is or it's actual data type? Right now the only way I can see to get the class name is to use the Get LV Class Path and strip the name. -J Quote Link to comment
ShaunR Posted September 6, 2009 Report Share Posted September 6, 2009 (edited) NI - Isn't there a way to compare the data types as equal "values"? Try using the "To Variant" function then comparing. Edited September 6, 2009 by ShaunR Quote Link to comment
Aristos Queue Posted September 7, 2009 Report Share Posted September 7, 2009 NI - Isn't there a way to compare the data types as equal "values"? The Equals primitive compares values and returns true if the values are equal. All of the comparison primitives (=, !=, <, >, >=, <=, and Sort 1D Array) compare based on the value of the private data cluster. Online help includes details on how comparison works when the underlying clusters aren't the same.If you're wanting to say "is this object of this particular type", then you use the Two More Specific primitive. If you're wanting to say "are these two objects the same type", use the Preserve Run-Time Class primitive (new in LV 2009). "Get LV Class Path.vi" can also give you the exact class info. Very few of these should ever be needed in your code. "Using the full power of OO" means never* doing type testing -- that road leads straight back into the world of enums and case structures. * 'never' of course is relatively never, since we wouldn't have the prims if it was truly never. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.