2012/11/29 luiz americo pereira camara <luiz...@oi.com.br>: > > There's a more concrete example about the duplicate typecast. > > I'm developing a model manager that would be responsible to easily > create LCL forms/frames, html forms, LazReport reports etc with the > same set of data/models > > Each project has a TModels collection with a TModel item > Each TMode item has a TFields collection with a TField item > Each TField has a unique Id managed per project > Currently to set the id of new Fields i have a circular reference > TField <> Project > My idea is to isolate TModel/TField to be independent of TProject > I can add a intermediate class to connect each other > But i could also takes advantage of Observer so i could observe the > Fields collection of each TModel to update the id when is added > The idea is add a FieldsObserver property to TModels and attach it to > each TModel > > It can be done as today?. Sure. My concerns are > > - I cannot define FieldsObserver as IFPObserver (the reasons why do i > prefer as it are above) > - Using FieldsObserver as TObject each time i attach/dettach from a > TFields there will be a type cast that i know before hand is not > necessary and could avoid.
Attached is the classes as is today. I'll try to get rid of circular dependency from TProject using the observer pattern. I 'll post the result later Luiz
datamodelclasses.pas
Description: Binary data
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel