Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Model-to-Model Transformation » [QVTo] Constructor calling constructor
[QVTo] Constructor calling constructor [message #1783493] Tue, 13 March 2018 15:48
Francesco Bedini is currently offline Francesco BediniFriend
Messages: 3
Registered: March 2018
Junior Member
Is it possible to make a constructor build an object of the same type it is currently constructing?

constructor Inscription::Inscription(){
	id := "my_inscription_id";
	text := "1";
	graphics := new Graphics();
}

constructor Inscription::Inscription(g : Graphics){
	var inscr := new Inscription();
	id := inscr.id;
	text := inscr.text;
	graphics := g.clone();
	log("Created Inscription with given graphics");
}

Which is fine with few attributes, but it gets crazy when the number of attributes gets higher. I am looking for something like this:
constructor Inscription::Inscription(g : Graphics){
        result := new Inscription(); //Call the other constructor
	//id := inscr.id;
	//text := inscr.text;
	graphics := g.clone();
	log("Created Inscription with given graphics");
}

Previous Topic:[ATL] Ask for help problem rule atl beginnner level
Next Topic:XTEND import function
Goto Forum:
  


Current Time: Sun Sep 23 16:24:14 GMT 2018

Powered by FUDForum. Page generated in 0.09848 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top