From: Jim K. <ji...@ji...> - 2003-10-14 02:30:14
|
> In fact you used the technique yourself Ah, yes :-)) -Jim > -----Original Message----- > From: ope...@li... > [mailto:ope...@li...]=20 > On Behalf Of Jean-Pierre Drolet > Sent: Monday, October 13, 2003 6:23 PM > To: ope...@li... > Subject: Re: [opengoop] "Variant To Data" downcasts Class=20 > Type Inheritance Refnums >=20 >=20 > Jim, >=20 > In fact you used the technique yourself in "EXAMPLE - Get Obj > Info From Ref.vi" and that made me post the message about=20 > "Class Downcast to Self.vi". This VI should indeed check if=20 > the object is valid and return an error for invalid object=20 > even if the class downcast succeeds. >=20 > Jean-Pierre >=20 >=20 > ----- Message d'origine ----- > De : "Jim Kring" <ji...@ji...> > =C0 : <ope...@li...> > Envoy=E9 : 13 octobre, 2003 20:28 > Objet : [opengoop] "Variant To Data" downcasts Class Type=20 > Inheritance Refnums >=20 >=20 > > Based on Jean-Pierre's comments about using "Variant to Data" for > > downcasting an inheritable data structure, I realized that=20 > "Variant to > > Data" can be used for downcasting Class Type Inheritance Refnums > > (analagous to "To More Specific Class" fuction). It will=20 > 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 =3D=3D> DeLorian is OK, but Truck =3D=3D> > 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=20 > specific type. > > However, this check will have to be done in any downstream VI that > > operates on the more specific type. > > > > -Jim > > > > >=20 >=20 >=20 |