[great-users] Adding copy child objects to a parent overwrites ononly one child

Kevin Smyth ksmyth at isis.vanderbilt.edu
Fri Jan 8 11:43:58 CST 2010


Hi Gürkan,

I think the problem is this line:

FAMM::LSC newLsc = FAMM::LSC::LSC(FamLSC);

I don't think this creates a new object, rather a reference to the old
object.

Try this instead:
FAMM::LSC newLsc = FAMM::LSC::Create(FamMSC);

Hope to help,
Kevin

-----Original Message-----
From: great-users-bounces at list.isis.vanderbilt.edu
[mailto:great-users-bounces at list.isis.vanderbilt.edu] On Behalf Of Gürkan
Özhan
Sent: Friday, January 08, 2010 11:11 AM
To: great-users
Subject: [great-users] Adding copy child objects to a parent overwrites
ononly one child

Dear All,
   I have a child object of type LSC, under a parent object of type MSC.
(Please see the attachment) In my attribute mapping code, I would like to
create a number of copies of the child object into the parent, and in the
following rule, want to delete the original child and continue manipulating
the new children. However, at the end of the transformation run, I see only
one child onder the parent having a name that is the concatenation of the
names of all the would be child objects. I suspect that the child objects
are created, but all are overwritten on a single object.. Here is my code
below:

			FAMM::LSC newLsc = FAMM::LSC::LSC(FamLSC);
	
newLsc.name()=(std::string)FamLSC.name()+"_"+(std::string)FamFederateApplica
tion.name();
			FamMSC.GetChildObjects().insert(newLsc);

   At the end of the transformation run, I get a single child LSC object
under the parent, named CFFLSC_FwdObserverFd_BatteryRadioNetFd_BatteryFDCFd,
which is a concatenation of the original child + 3 copy children's names.


Alternatively I tried the CreateInstance solution;
			FAMM::LSC newLsc = FamLSC.CreateInstance(FamMSC);
	
newLsc.name()=(std::string)FamLSC.name()+"_"+(std::string)FamFederateApplica
tion.name();

which worked as I expected and created 3 child objects, however, since these
are Instances of the original child, when I delete the original child in the
next rule, I lose all of the children. I must not lose the newly created
children.

   In the attachment, you can find an image of my rule.

Could you please help me to solve this issue?


Best regards,

Gurkan Ozhan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5192 bytes
Desc: not available
Url : http://list.isis.vanderbilt.edu/pipermail/great-users/attachments/20100108/feb41864/attachment.bin 


More information about the great-users mailing list