Jump to content

Generic Object Manager


Recommended Posts

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...

post-11089-125209813883_thumb.jpg

Link to comment

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.

Link to comment

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 rolleyes.gif . 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

Link to comment
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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.