dev/vala/abstract_abstract/abstract_abstract.vala

39 lines
761 B
Vala

using GObject.Plugins;
namespace GObject.Plugins {
public interface IPlugabble : Object {
public abstract string get_name ();
}
public abstract class Plugin : Object, IPlugabble {
public abstract string get_name ();
}
public abstract class PluginTypeA : Plugin {
// don't write anything here
}
public class PluginTypeA1 : PluginTypeA {
public override string get_name () { return "Any object of PluginTypeA1 class"; }
}
public class Module {
Type t;
public Module (Type t) {
this.t = t;
}
public IPlugabble create_instance () {
return Object.new (t) as IPlugabble;
}
}
}
void main () {
var m = new Module (typeof (PluginTypeA1));
var o = m.create_instance ();
stdout.printf ("o.get_name () = %s", o.get_name ());
}