On Sun, Nov 18, 2012 at 3:13 AM, leledumbo <leledumbo_c...@yahoo.co.id> wrote: >> Tell the user of the framework to do something like this for every >> class of your model: >> >> initialization >> TUser.RegisterClass; >> TProduct.RegisterClass; >> ... >> >> or >> >> initialization >> RegisterClasses([TUser, TProduct, ...]); > > Seems like this is the most feasible way, there should be an internal data > structure that maps registered classes with their respective table name.
Both RegisterClass procedures I pointed out are methods of the framework, eg: // The framework type TBaseModelClass = class of TBaseModel; TBaseModel = class(TObject) public class procedure RegisterClass; end; procedure FWRegisterClass(AClasses: array of TBaseModelClass); ... class procedure TBaseModel.RegisterClass; begin // Initialize the class metadata. "ClassName" works. writeln('Registering ', ClassName); end; procedure FWRegisterClass(AClasses: array of TBaseModelClass); var I: Integer; begin for I := 0 to Pred(Length(AClasses)) do AClasses[I].RegisterClass; end; // The application type TUser = class(TBaseModel); TContact = class(TBaseModel); implementation initialization FWRegisterClass([TUser, TContact]); Joao Morais _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal