02-02-2012 05:15 AM
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
02-02-2012 07:00 AM
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:
The Decisions Behind the Design
09-06-2013 10:25 AM
> 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?
09-06-2013 10:38 AM
@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.