LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert an abstract method in a parent class and child classes?

Dear all,

 

I am converting a java project in Labview but i have an issue that I am not sure how to convert. 

I have an abstract class called Attribute and there is two type of attribute : Description and Legend.

The problem is about the method called dumpHTML that produces nothing in the abstract class Attribute :

 

public abstract class Attribute {

...

public abstract String dumpHTML(HashMap<Integer, String> anchors);

...

}

 

But in the child classes Description and Legend, the method is doing something as follow ( i have only written the Description class but it is the same for the Legend class)

 

public class Description extends Attribute {

...

public String dumpHTML(HashMap<Integer, String> anchors) {

String html = "<div class=\"group\">\n";

.... do something ...

html += "</div>";

return html;

}

 

}

 

Maybe my question is very stupid but I really do not know how to write the abstract method in the class Attribute with nothing in output. 

Please help me.

 

regards

mnemo

 

0 Kudos
Message 1 of 4
(3,099 Views)

LV doesn't have abstract classes, but you can simply create them by creating a parent class which has no functionality.

 

The connector pane for override VIs has to be the same, so all you need to do is create the Dump HTML VI in the abstract class as dynamic dispatch (right click on the class and select New from DD template or go into the connector pane and set the class input and output to be DD) and have a string indicator which will be connected to the connector pane. You don't have to anything with that indicator, since the VI will never run.

 

If you then want to make sure that child classes have to override the VI, go into the class properties dialog and in the Item Settings page select the VI and set the relevant check box to T.

 

You should also read these two documents:

LVOOP FAQ

The Decisions Behind the Design


___________________
Try to take over the world!
Message 2 of 4
(3,090 Views)

> LV doesn't have abstract classes

 

Isn't this incorrect? You can design a class with abstract method VIs, doesn't that mean the class becomes abstract?

 

 

Lars Melander
Uppsala Database Laboratory, Uppsala University
0 Kudos
Message 3 of 4
(3,002 Views)

@LarsM wrote:

> LV doesn't have abstract classes

 

Isn't this incorrect? You can design a class with abstract method VIs, doesn't that mean the class becomes abstract?

 

 


This is an old thread...but no. There is no such thing as a truley abstract class in LabVIEW. You can technically instantiate any class, so when abstract classes are needed, it's purely by convention. 

0 Kudos
Message 4 of 4
(3,000 Views)