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

Gürkan Özhan gurkanozhan at gmail.com
Fri Jan 8 13:58:06 CST 2010


Hello,
   I have already tried FAMM::LSC::Create(FamMSC). It creates a new,
but empty object under FamMSC. What I would like to have is to have a
clone/copy of the matched child object, FamLSC, put under the parent.
  If the only way to obtain a non-empty child object is to use
newChild = child.CreateInstance(parent), then is there a way to detach
the new child objects from the original child, so that I can later
delete the original child safely, without also deleting the new ones.
  Regards,

Gurkan

2010/1/8 Kevin Smyth <ksmyth at isis.vanderbilt.edu>:
> 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
>
> _______________________________________________
> great-users mailing list
> great-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/great-users
>
>


More information about the great-users mailing list