Quick.Data.Custom.pas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. { ***************************************************************************
  2. Copyright (c) 2016-2019 Kike Pérez
  3. Unit : Quick.Data.Base
  4. Description : Data Metrics
  5. Author : Kike Pérez
  6. Version : 1.0
  7. Created : 08/04/2019
  8. Modified : 08/04/2019
  9. This file is part of QuickLogger: https://github.com/exilon/QuickLogger
  10. ***************************************************************************
  11. Licensed under the Apache License, Version 2.0 (the "License");
  12. you may not use this file except in compliance with the License.
  13. You may obtain a copy of the License at
  14. http://www.apache.org/licenses/LICENSE-2.0
  15. Unless required by applicable law or agreed to in writing, software
  16. distributed under the License is distributed on an "AS IS" BASIS,
  17. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. See the License for the specific language governing permissions and
  19. limitations under the License.
  20. *************************************************************************** }
  21. unit Quick.Data.Custom;
  22. {$i QuickLib.inc}
  23. interface
  24. uses
  25. SysUtils,
  26. Quick.Commons;
  27. type
  28. TOutputOptions = class
  29. private
  30. fUseUTCTime : Boolean;
  31. public
  32. property UseUTCTime : Boolean read fUseUTCTime write fUseUTCTime;
  33. end;
  34. IDataProvider = interface
  35. ['{D4D03D84-9BD7-49A0-8A46-0E89E0988F58}']
  36. function Send(const aName, aValue : string): Boolean; overload;
  37. function Send(const aName : string; aValue : Integer): Boolean; overload;
  38. function Send(const aName : string; aValue : Extended): Boolean; overload;
  39. function Send(const aName : string; aValue : TDateTime): Boolean; overload;
  40. end;
  41. TDataProvider = class(TInterfacedObject,IDataProvider)
  42. private
  43. fOutputOptions : TOutputOptions;
  44. protected
  45. fInitiated : Boolean;
  46. public
  47. constructor Create; virtual;
  48. destructor Destroy; override;
  49. property OutputOptions : TOutputOptions read fOutputOptions write fOutputOptions;
  50. procedure Init; virtual;
  51. procedure Stop; virtual;
  52. procedure Restart; virtual; abstract;
  53. function Send(const aName, aValue : string): Boolean; overload; virtual; abstract;
  54. function Send(const aName : string; aValue : Integer): Boolean; overload; virtual; abstract;
  55. function Send(const aName : string; aValue : Extended): Boolean; overload; virtual; abstract;
  56. function Send(const aName : string; aValue : TDateTime): Boolean; overload; virtual; abstract;
  57. end;
  58. const
  59. DEF_USER_AGENT = 'Quick.Data.Base Agent';
  60. implementation
  61. { TDataProvider }
  62. constructor TDataProvider.Create;
  63. begin
  64. fOutputOptions := TOutputOptions.Create;
  65. fInitiated := False;
  66. end;
  67. destructor TDataProvider.Destroy;
  68. begin
  69. fOutputOptions.Free;
  70. fInitiated := False;
  71. inherited;
  72. end;
  73. procedure TDataProvider.Init;
  74. begin
  75. fInitiated := True;
  76. end;
  77. procedure TDataProvider.Stop;
  78. begin
  79. fInitiated := False;
  80. end;
  81. end.