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: 32
Registered: March 2018
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: Fri Apr 26 04:27:23 GMT 2024

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

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

Back to the top