From: Jim K. <ji...@ji...> - 2003-10-14 00:28:36
|
Based on Jean-Pierre's comments about using "Variant to Data" for downcasting an inheritable data structure, I realized that "Variant to Data" can be used for downcasting Class Type Inheritance Refnums (analagous to "To More Specific Class" fuction). It will even output an error at run-time (Error 91, "The data type of the variant is not compatible with the data type wired to the type input."), if the class information in the variant does not match the more specific type. For example, this prevents one from trying to Downcast to a class from the classes uncle (Car ==> DeLorian is OK, but Truck ==> Delorian produces an ERROR). Adopting this technique means that a class does not have to provide a polymorphic VI for downcasting to each descendant type. The only downside, is that this method does not rely on the object reference to check if the object is really of the more specific type. However, this check will have to be done in any downstream VI that operates on the more specific type. -Jim |