home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue49 / Factory / FactoryConcreteReport.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-06-16  |  2.1 KB  |  71 lines

  1. {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2.   TechInsite Pty. Ltd.
  3.   PO Box 429, Abbotsford, Melbourne. 3067 Australia
  4.   Phone: +61 3 9419 6456
  5.   Fax:   +61 3 9419 1682
  6.   Web:   www.techinsite.com.au
  7.   EMail: peter_hinrichsen@techinsite.com.au
  8.  
  9.   Created: 01/06/1999
  10.  
  11.   Notes: Concrete report factory. The TFactoryAbstract is descended from with
  12.          the additional function CreateInstanceExt being added. This function
  13.          calls the concrete factory's CreateInstance and adds some type casting.
  14.  
  15. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
  16.  
  17. unit FactoryConcreteReport;
  18.  
  19. interface
  20. uses
  21.   FactoryAbstract,
  22.   FReportAbstract
  23.   ;
  24.  
  25. type
  26.  
  27.   // The report factory
  28.   //----------------------------------------------------------------------------
  29.   TFactoryConcreteReport = class( TFactoryAbstract )
  30.   private
  31.   public
  32.     Function CreateInstanceExt( const pStrClassID : string ) :
  33.                                        TFormReportAbstract ;
  34.  
  35.   end ;
  36.  
  37. // A function with application wide visibility to surfact the unit wide
  38. // variable uFactoryConcreteReport
  39. function gFactoryConcreteReport : TFactoryConcreteReport ;
  40.  
  41. implementation
  42. var
  43.   // Hold a single instance of our report factory
  44.   uFactoryConcreteReport : TFactoryConcreteReport ;
  45.  
  46. // Make sure there is always an report factory available
  47. //------------------------------------------------------------------------------
  48. function gFactoryConcreteReport : TFactoryConcreteReport ;
  49. begin
  50.   if uFactoryConcreteReport = nil then
  51.     uFactoryConcreteReport := TFactoryConcreteReport.Create ;
  52.   result := uFactoryConcreteReport ;
  53. end ;
  54.  
  55. // Create an instance of the required class, but add some type casting
  56. //------------------------------------------------------------------------------
  57. function TFactoryConcreteReport.CreateInstanceExt(
  58.             const pStrClassID: string): TFormReportAbstract;
  59. begin
  60.   result := TFormReportAbstract(
  61.                             CreateInstance( pStrClassID )) ;
  62. end;
  63.  
  64. initialization
  65.   gFactoryConcreteReport ;
  66.  
  67. finalization
  68.   uFactoryConcreteReport.Free ;
  69.  
  70. end.
  71.