Wagner,
Up to know I was happy with the centralized factory that I have created for the Entities. I use it fo the TDataSet and for "manual" direct operations.
However I left behind the case where the data comes from Find, returning a Criteria or a Cursor.
I have created an object to transport these results from the different tiers of the software:
INaharDataView = interface
['{A98D1B38-5F9E-4C9A-844B-66FF349E4055}']
procedure SetAsSourceCriteria(const Value: TCriteria);
procedure SetAsSourceCursor(const Value: ICriteriaCursor);
procedure SetAsSourceList(const Value: TObject);
procedure SetAsSourceObject(const Value: TObject);
function GetAsSourceCriteria: TCriteria;
function GetAsSourceCursor: ICriteriaCursor;
function GetAsSourceList: TObject;
function GetAsSourceObject: TObject;
function IsEmpty: Boolean;
property AsList: TObject read GetAsSourceList write SetAsSourceList;
property AsObject: TObject read GetAsSourceObject write SetAsSourceObject;
property AsCursor: ICriteriaCursor read GetAsSourceCursor write SetAsSourceCursor;
property AsCriteria: TCriteria read GetAsSourceCriteria write SetAsSourceCriteria;
end;
Then the Model layer creates and sets the proper result, sometimes is AsCriteria or AsCursor.
Then the viewer get that on the TAureliusDataSet. It is just a transport, for now.
However I need to initialize the Entities. The entities are created by Aurelius without father and mother :)
I believe that for the cases AsList and AsObject I have real entities constructed already.
But what about AsCursor and AsCriteria? if I understand those are only guidelines to retrieve the entities, it is not constructed entities yet.
otherwise, I could use a singleton and from the constructor of the entity get a way to retrieve contextual information.
But that is a problem also, since I have a multi thread environment, and many contexts. This solution only works if I have only one context only.
For example, when getting a TCriteria and setting it to the TAureliusDataSet it will be ready to share the data, and connected to a bindsource I have the TListView going thru all the records showing the values. At this moment there are some information that needs to be prepared according the context that is unknown by the entity since was created by Aurelius.
Any clues?