Record Cloning

Involved development of the OpenMW construction set.
User avatar
Zini
Posts: 5134
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini » 17 Jan 2014, 09:20

The record we are getting the ID from is the new one, that just has been created. This is the copy that exists outside of the container. Therefore the newly created record in the container needs to have the same ID.

The procedure is:
- Get the ID of the record to be inserted.
- Create a new record with this ID and store its index.
- Copy the record to be inserted to that index.

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka » 17 Jan 2014, 10:29

Ah, I see. I'm wonder why we are not simply inserting already created record directly.

Anyway: it seems that I need to create new method in collectionbase: clonerecord that will ask data containers to create copy of the record, change it's id and insert. Is that correct?

User avatar
Zini
Posts: 5134
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini » 17 Jan 2014, 11:20

Ah, I see. I'm wonder why we are not simply inserting already created record directly.
To keep the RefIdData interface minimal. We would need a separate function to create a new non-empty record. With the current implementation this function is not needed.
Anyway: it seems that I need to create new method in collectionbase: clonerecord that will ask data containers to create copy of the record, change it's id and insert. Is that correct?
Yes, that is the obvious way to do it. I was considering if it is possible to implement cloning without extending the interface of CollectionBase, but that is probably more trouble than it is worth.

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka » 17 Jan 2014, 12:05

Right! Sorry for those questions, I just don't feel quite selfconfident when facing OpenCS ;-)

User avatar
Zini
Posts: 5134
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini » 17 Jan 2014, 12:25

No problem.

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka » 19 Jan 2014, 17:41

hey, ArgumentType (in UniversalId) stores information if record is indexed or has any unique id, right?

User avatar
Zini
Posts: 5134
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini » 19 Jan 2014, 23:02

Right.

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka » 20 Jan 2014, 14:12

Hello, I have another silly questions ;-)

Cloning works now for single record type collections, however I need to alter mId of References and Referencables (multi-type ) tables records and to that, It seems i have to cast those to appropariate classes. I can do this with simple if/else stairway, but I'm wonder if we have more convienient way of doing this.

PS
Also, where do we handle automatic index generation?

User avatar
Zini
Posts: 5134
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini » 20 Jan 2014, 14:20

References are not multi-type.

For referecenables RefIdAdpater might help. There is currently only a function for getting the ID, but you should be able to add one for setting the ID.

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka » 20 Jan 2014, 14:48

ok, thanks. Can you also provide any hint for the PS question?

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests