> I want to inherit from the TList and create my own default array property
> like:
> property Neuron[iIndex : integer] : TNeuron read GetNeuron write SetNeuron;
> default;
> And later add some searching behaviour. This means that I can stop typing
> the TObject returned from the TList:
>
> Neuron.LinkedNeuron[i].Fire;
> Makes my code easier to read etc... Basiclly I got annoyed with having to
> set its type all the time. :-) Yes I could read it into a var and then use
> the var, I even do that where possible. But there is a signifigant number
> of places where that would clutter up the code more. So I thought I would
> get the list to return the right type rather than TObject as TList does.
> Nope its not a very reusable concept, but its not designed to be.
My GenericCollection (Items are not restricted by heritage) I created internally
here has 2 levels to it
TJAbstractBaseList
Implements all functionality of being a list without declaring a storage
mechanism. It
declares things like Delete(Index), Exchange(Index)...
TJAbstractObjectList
Implements all functionality of carrying a list of records (in a dynamic array) of
Objects
There is a GetItem(Index :Integer):Tobject and it's Set equivelent but no Items
property
Does include Add(O :TObject);
Also implements an Accepts(O :TObject):Boolean which controlls allowing duplicates,
and restricts which classes can be added (disallowing Nil etc)
These are implemented in LIB_Lists.
an example of use is a TPeopleList object which adds the Items[Index
:Integer]:TPersonItem
property and overrides Accepts to restrict adding anything except TPersonItem
instances.
TPeopleList and TPersonItem are implemented in the same unit.
Can this mechanism aid you at all?
--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz