#1 2011-01-30 13:02:22

ingoberg
Member
Registered: 2010-11-20
Posts: 17

CopyRecord

Would you mind making the CopyRecord method of the TSQLRecord virtual so that i can override it?

Offline

#2 2011-01-30 15:07:31

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,225
Website

Re: CopyRecord

I guess you spoke about the CreateCopy method (there is no such CopyRecord method)?

I'm not so fast to make TSQLRecord methods virtual, because each virtual method will use a pointer for every object instance.
I made some code refactoring so that every TSQLRecord has an Instance size of 20 bytes for private and protected fields (such as fID or fProps e.g.)... and I don't want this size to grow without imperial need.

Since I guess that this method won't be called often, I guess dynamic instead of virtual will be enough for you.

Delphi help wrote:

Virtual versus dynamic

Virtual and dynamic methods are semantically equivalent. They differ only in the implementation of method-call dispatching at runtime. Virtual methods optimize for speed, while dynamic methods optimize for code size.

In general, virtual methods are the most efficient way to implement polymorphic behavior. Dynamic methods are useful when a base class declares many overridable methods which are inherited by many descendant classes in an application, but only occasionally overridden.

So here is the patch:
http://synopse.info/fossil/info/37d5c99bf8

Just to be curious: what is it for?

Offline

#3 2011-02-04 03:25:17

ingoberg
Member
Registered: 2010-11-20
Posts: 17

Re: CopyRecord

I was going to override the method because it did not copy blob fields.

Offline

#4 2011-02-04 06:54:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,225
Website

Re: CopyRecord

I don't understand because in the current implementation, BLOB fields are copied.

The CreateCopy method copies all COPIABLE_FIELDS, i.e. all fields excluding tftMany (because those fields don't contain any data, but a TSQLRecordMany instance which allow to access to the data).

See

  /// kind of fields which can be copied from one TSQLRecord instance to another
  COPIABLE_FIELDS: TSQLFieldTypes =
    [low(TSQLFieldType)..high(TSQLFieldType)] - [sftUnknown, sftMany];

So BLOB fields should be copied.... no need to override the method...

I've just made this CreateCopy method faster (using the new TPropInfo.CopyValue method).

Offline

#5 2014-12-09 10:59:29

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: CopyRecord

Hi Arnaud,

It seems that TSQLRecord.CreateCopy doesn't copy published properties of type TStrings?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#6 2014-12-09 19:24:26

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,225
Website

Re: CopyRecord

Should be the case now thanks to http://synopse.info/fossil/info/744fef8868

Offline

#7 2014-12-10 06:59:40

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: CopyRecord

You are so quick, AB!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB