Hi all,
I'm writing a program that pulls data from lots of sources and assembles the results into a TComponent descendent class via published properties. I've then been using ReadComponent and WriteComponent to store the component's published properties into a blob field in a local table for caching. All of that works. Sorta.
The data itself makes up, for example, an invoice. All the invoice header details (date, invoice number, etc.) are being handled fine, but the line details of the invoice are not (eg StockCode, Quantity, etc.). I was using a TObjectList to hold each detail class instance (also a descendant of TComponent), but this was getting ignored, because there was no owner link between the TInvoiceDetail class and the TInvoice class.
I switched from TObjectList to TComponentList, but it made no difference, and I'm quickly getting confused. Only the header properties are getting to and from the blob field.
I've considered dispensing with the TComponentList container entirely, and relying on each TInvoiceDetail.Owner property (set to TInvoice) and FindComponent, etc. to search through them as required, but this seems kinda dangerous.
How should I structure things so I can use ReadComponent and WriteComponent to store and restore everything? Is there another approach I should be using? Any advice is appreciated.
I'm writing a program that pulls data from lots of sources and assembles the results into a TComponent descendent class via published properties. I've then been using ReadComponent and WriteComponent to store the component's published properties into a blob field in a local table for caching. All of that works. Sorta.
The data itself makes up, for example, an invoice. All the invoice header details (date, invoice number, etc.) are being handled fine, but the line details of the invoice are not (eg StockCode, Quantity, etc.). I was using a TObjectList to hold each detail class instance (also a descendant of TComponent), but this was getting ignored, because there was no owner link between the TInvoiceDetail class and the TInvoice class.
I switched from TObjectList to TComponentList, but it made no difference, and I'm quickly getting confused. Only the header properties are getting to and from the blob field.
I've considered dispensing with the TComponentList container entirely, and relying on each TInvoiceDetail.Owner property (set to TInvoice) and FindComponent, etc. to search through them as required, but this seems kinda dangerous.
How should I structure things so I can use ReadComponent and WriteComponent to store and restore everything? Is there another approach I should be using? Any advice is appreciated.