Record Cloning

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

Re: Record Cloning

Post by Zini »

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: 2159
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka »

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: 5538
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini »

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: 2159
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka »

Right! Sorry for those questions, I just don't feel quite selfconfident when facing OpenCS ;-)
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini »

No problem.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka »

hey, ArgumentType (in UniversalId) stores information if record is indexed or has any unique id, right?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini »

Right.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka »

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: 5538
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini »

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: 2159
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka »

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