Why can't we just write a simple collection of interfaces. That's what I did for some classes.
Take for example TStringList:
IARCStringList = Inteface
procedure Add( aString : string );
procedure AddStrings( aString : string );
function AsStringList : TStringList;
...
end;
TARCStringList = Class( TInterfacedObject, IARCStringList )
private
FList : TStringList;
public
// Implement all IStringListARC methods and properties.
destructor destroy; // Will call FList.Free;
end;
Usage would be very simple:
procedure DoSomething;
Var
S : IARCStringList;
begin
S := TARCStringList.Create;
S.Add('One');
S.Add('Two');
ListBox1.Items.AddString( S.AsStringList ); // Will return FList
end;
I wrote for other classes such as TARCDictionary, TARCObjectDictionary, TARCDictionary<K,V>, TARCObjectDictionary<K,O>, etc.
I use "const" wherever is required when I use those ARC interfaces.
What problems do you see with such implementations (other than writing a lot of code)?