Skip to main content



      Home
Home » Modeling » Model-to-Model Transformation » [QVTo] Constructor calling constructor
[QVTo] Constructor calling constructor [message #1783493] Tue, 13 March 2018 11:48
Eclipse UserFriend
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: Thu May 22 03:45:00 EDT 2025

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

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

Back to the top