forked from gabr42/OmniThreadLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OtlCommon.pas
4046 lines (3608 loc) · 128 KB
/
OtlCommon.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
///<summary>Stuff common to the OmniThreadLibrary project.</summary>
///<author>Primoz Gabrijelcic</author>
///<license>
///This software is distributed under the BSD license.
///
///Copyright (c) 2015, Primoz Gabrijelcic
///All rights reserved.
///
///Redistribution and use in source and binary forms, with or without modification,
///are permitted provided that the following conditions are met:
///- Redistributions of source code must retain the above copyright notice, this
/// list of conditions and the following disclaimer.
///- Redistributions in binary form must reproduce the above copyright notice,
/// this list of conditions and the following disclaimer in the documentation
/// and/or other materials provided with the distribution.
///- The name of the Primoz Gabrijelcic may not be used to endorse or promote
/// products derived from this software without specific prior written permission.
///
///THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
///ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
///WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
///DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
///ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
///(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
///LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
///ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
///(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
///SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
///</license>
///<remarks><para>
/// Home : http://www.omnithreadlibrary.com
/// Support : https://plus.google.com/communities/112307748950248514961
/// Author : Primoz Gabrijelcic
/// E-Mail : [email protected]
/// Blog : http://thedelphigeek.com
/// Contributors : GJ, Lee_Nover, scarre, Sean B. Durkin
/// Creation date : 2008-06-12
/// Last modification : 2015-10-03
/// Version : 1.39
///</para><para>
/// History:
/// 1.39: 2015-10-03
/// - [Sean] Implemented TOmniAlignedInt32 (clone of GpStuff.TGp4AlignedInt)
/// and TOmniAlignedInt64 (clone of GpStuff.TGp8AlignedInt64).
/// 1.38: 2015-09-28
/// - [Sean] Introduced non-Windows compatibility.
/// 1.37b: 2015-08-30
/// - Fixed record type handling in FromArray<T> and ToArray<T>.
/// 1.37a: 2015-04-17
/// - Added vtWideChar and vtPWideChar handling to TOmniValue.Create and .CreateNamed.
/// 1.37: 2015-02-09
/// - Added writer for TOmniExecutable.Delegate.
/// 1.36: 2015-02-03
/// - Type of TOmniValue data is now an external type - TOmniValueDataType. That
/// way causes less internal errors in the compiler.
/// - Added TOmniValue.DataType property.
/// 1.35: 2014-09-23
/// - Implemented TOmniValueContainer.AssignNamed.
/// 1.34: 2014-01-13
/// - Implemented TOmniValue.HasArrayItem.
/// 1.33: 2014-01-10
/// - TOmniValue can 'own' a TObject (object gets destroyed when a TOmniValue goes
/// out of scope). Supporting properties: IsOwnedObject, AsOwnedObject,
/// OwnsObject.
/// 1.32b: 2013-10-17
/// - Fixed exception format string in TOmniValue.SetAsTValue.
/// 1.32a: 2013-10-14
/// - Removed XE5 compilation warnings.
/// 1.32: 2013-10-13
/// - ToObject<T> is working in D2010 again (thx to [Tomasso Ercole]).
/// 1.31a: 2013-10-07
/// - Compiles with D2009 and D2010 again.
/// 1.31: 2013-05-06
/// - AnsiString type is supported in TOmniValue.
/// - Implemented FromArray<T> and ToArray<T>.
/// - CastAs<T> renamed to CastTo<T>.
/// - AsRecord<T> renamed to ToRecord<T>.
/// - CastFrom<T> and CastTo<T> work for byte- and word-sized integer types.
/// 1.30: 2013-04-29
/// - GetAsXXX family renamed to CastToXXX.
/// - TryGetAsXXX familiy renamed to TryCastToXXX.
/// 1.29: 2013-04-26
/// - Added TOmniValue.TryGetAsXXX family of functions.
/// - Added TOmniValue.GetAsXXXDef family of functions.
/// 1.28a: 2013-02-27
/// - Fixed TOmniValue._AddRef and _Release when 'nil' interface was stored in
/// the TOmniValue.
/// 1.28: 2012-07-30
/// - Implemented TOmniValue.IsRecord.
/// 1.27: 2012-05-18
/// - Added property CountPhysical to the IOmniAffinity.
/// 1.26c: 2012-02-28
/// - Fixed object and interface casting in TOmniValue.CreateNamed.
/// 1.26b: 2012-02-25
/// - TOmniValue.CreateNamed was casting pointer to integer.
/// 1.26a: 2012-02-03
/// - TOmniValueContainer.Insert did not update internal 'count' field.
/// Big thanks to [andi] for bug report and fix.
/// 1.26: 2012-01-19
/// - Added TOmniValueObj, class wrapper for TOmniValue.
/// 1.25g: 2011-12-20
/// - TOmniValue.AsInteger, AsString and AsWideString now work if the TOmniValue
/// contains a Variant of the appropriate type.
/// 1.25f: 2011-12-18
/// - Fixed various TOmniInterfaceDictionary bugs (big tnx to Zarko Gajic).
/// - Clear properly clears interface refence before destroying the bucket.
/// - Resize properly clears interface reference in old bucket after copy.
/// - Resize preserves the internal item count.
/// - Resize releases old buckets.
/// 1.25e: 2011-12-09
/// - Removed compilation hint "Private symbol 'GetAsRecord' declared but never used".
/// 1.25d: 2011-12-02
/// - Removed compilation hint "Private symbol 'GetAsArrayItem' declared but never used".
/// 1.25c: 2011-11-29
/// - Reference count handling in TOmniValue was ignoring array and record wrappers.
/// 1.25b: 2011-11-18
/// - Overloaded property getters in TOmniValue are not inlined on 2009/
/// 2010 because of the buggy compiler.
/// 1.25a: 2011-11-15
/// - Some inlining removed because it would not work reliably.
/// 1.25: 2011-11-08
/// - Less casting in TOmniValue.Create.
/// - TOmniValue can store records by using FromRecord<T> and AsRecord<T>.
/// - Added a class which can wrap any record - TOmniRecordWrapper<T>.
/// - Added an interface which can wrap any object and destroy it when the
/// interface goes out of scope - IOmniAutoDestroyObject.
/// 1.24: 2011-11-05
/// - TOmniValue.Create now internally creates TOmniValueContainer to store values.
/// Variant arrays are no longer used. IsArray tests it TOmniValue contains an
/// array and AsArray returns this internal container. Default indexed property
/// still accesses individual elements in this container. See demo
/// 50_OmniValueArray for an example.
/// - TOmniValue.Create creates internal TOmniValueContainer containing named items.
/// See demo 50_OmniValueArray for an example.
/// 1.23: 2011-09-06
/// - Implemented IOmniCounter.Take.
/// 1.22: 2011-08-31
/// - [Lee_Nover] SetThreadName implementation moved into a separate unit with debug
/// info disabled. That way, debugger doesn't stop on SetThreadName while
/// single-stepping in another thread.
/// 1.21: 2011-08-28
/// - TOmniValue can natively store exception objects (AsException, IsException).
/// 1.20: 2011-07-14
/// - Removed EXIT_EXCEPTION error code.
/// 1.19a: 2010-12-12
/// - Define implicit TOmniValue<->TDateTime conversion operators only for Delphi XE
/// and higher.
/// 1.19: 2010-12-03
/// - [scarre] Added TDateTime support to TOmniValue.
/// 1.18a: 2010-09-21
/// - IOmniWaitableValue fully compatible with TOmniWaitableValue.
/// 1.18: 2010-09-20
/// - Declared interface IOmniWaitableValue and added function CreateWaitableValue.
/// - Implemented TOmniMessageID.AsString.
/// 1.17a: 2010-07-08
/// - TOmniValue.CastAs<T> and .CastFrom<T> are partially supported in D2009.
/// 1.17: 2010-07-01
/// - Includes OTLOptions.inc.
/// 1.16: 2010-05-12
/// - TOmniValue can be cast as Int64.
/// - Implemented TOmniValue.CastFrom<T> and .CastAs<T>.
/// 1.15: 2010-05-08
/// - Implemented conversions from/to TOmniValue to/from TValue (Delphi 2010 and newer).
/// 1.14: 2010-05-06
/// - Implemented TOmniValue._AddRef, _Release, _ReleaseAndClear.
/// 1.13: 2010-04-14
/// - Removed TOmniEnumerableRange and associated code.
/// 1.12: 2010-03-16
/// - Implemented TOmniMessageID record, used internally to implement timers.
/// 1.11: 2010-03-10
/// - Implemented TOmniCounter, auto-initialized wrapper around the IOmniCounter.
/// 1.10b: 2010-03-03
/// - Replacement AnonCopy, by Serg.
/// 1.10a: 2010-02-22
/// - D2009-compatible way of setting a delegate in TOmniExecutable.
/// 1.10: 2010-02-09
/// - Implemented TOmniExecutor - a record that can store TProcedure, TMethod, or
/// TProc.
/// 1.09: 2010-02-01
/// - TOmniValue getters know how to process empty TOmniValue.
/// - Added Environment.Thread interface.
/// - Environment.SystemAffinity moved to Environment.System.Affinity.
/// 1.08: 2010-01-14
/// - Added TOmniValue.IsInteger.
/// - Refactored and enhanced TOmniValueContainer.
/// - Defined IOmniValueEnumerable interface.
/// 1.07: 2010-01-05
/// - Renamed: IInterfaceDictionary -> IOmniInterfaceDictionary,
/// IInterfaceDictionaryEnumerator -> IOmniInterfaceDictionaryEnumerator,
/// TInterfaceDictionaryPair -> TOmniInterfaceDictionaryPair.
/// - Implemented IOmniEnvironment interface and function Environment returning
/// some information on system and process.
/// 1.06: 2009-12-21
/// - Added pointer conversions and AsPointer cast to TOmniValue.
/// 1.05: 2009-11-15
/// - Removed lots of stuff that is now implemented using container observers.
/// 1.04: 2009-04-18
/// - Added WideString support to TOmniValue.
/// 1.03a: 2009-04-05
/// - Bug fixed: TInterfaceDictionaryEnumerator was ignoring first bucket.
/// 1.03: 2009-03-30
/// - TOmniCS and IOmniCriticalSection moved to the OtlSync unit.
/// 1.02a: 2009-02-09
/// - Simplified TOmniCS.Initialize.
/// 1.02: 2009-02-03
/// - Added accessor to the internal critical section to the TOmniCS record.
/// 1.01: 2009-01-26
/// - Implemented TOmniCS critical section wrapper.
/// - Added TOmniWaitableValue class.
/// 1.0d: 2008-10-05
/// - Use GetGoodHashSize from GpStringHash unit.
/// 1.0c: 2008-09-26
/// - Check PostMessage result.
/// 1.0b: 2008-09-19
/// - Bug fixed: TOmniValue.Null was not really initialized to Null.
/// 1.0a: 2008-09-02
/// - Fixed memory leak that could occur in TOmniMonitorSupport.Notify (in fact it
/// was possible to cause it in demo 11).
/// 1.0: 2008-08-26
/// - First official release.
///</para></remarks>
unit OtlCommon;
{$I OtlOptions.inc}
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Classes,
Variants,
TypInfo,
SyncObjs,
{$IFDEF MSWINDOWS}
Windows,
DSiWin32,
{$ENDIF}
{$IFDEF POSIX}
Posix.Pthread,
{$ENDIF}
{$IFDEF OTL_ERTTI}
RTTI,
{$ENDIF OTL_ERTTI}
{$IFDEF OTL_Generics}
Generics.Collections,
{$ENDIF OTL_Generics}
SysUtils;
const
// reserved exit statuses
EXIT_OK = 0;
EXIT_INTERNAL = integer($80000000);
EXIT_THREADPOOL_QUEUE_TOO_LONG = EXIT_INTERNAL + 0;
EXIT_THREADPOOL_STALE_TASK = EXIT_INTERNAL + 1;
EXIT_THREADPOOL_CANCELLED = EXIT_INTERNAL + 2;
EXIT_THREADPOOL_INTERNAL_ERROR = EXIT_INTERNAL + 3;
type
{$IFNDEF OTL_HasCorrectNativeInt}
NativeInt = integer;
NativeUInt = cardinal;
PNativeInt = PInteger;
PNativeUInt = PCardinal;
{$ENDIF}
//:TOmniValue conversion exception.
EOmniValueConv = class(Exception);
TOmniValueContainer = class;
IOmniAutoDestroyObject = interface;
TOmniValueDataType = (ovtNull,
{ovData} ovtBoolean, ovtInteger, ovtDouble, ovtObject, ovtPointer, ovtDateTime, ovtException,
{ovIntf} ovtExtended, ovtString, ovtInterface, ovtVariant, ovtArray, ovtRecord, ovtOwnedObject
{$IFDEF MSWINDOWS}
, ovtWideString, ovtAnsiString
{$ENDIF});
TOmniValue = packed record // 13 bytes in 32-bit, 17 bytes in 64-bits
private
ovData: int64;
ovIntf: IInterface;
ovType: TOmniValueDataType;
function CastToBoolean: boolean; inline;
function CastToCardinal: cardinal; inline;
function CastToDouble: Double;
function CastToDateTime: TDateTime;
function CastToException: Exception;
function CastToExtended: Extended;
function CastToInt64: int64; inline;
function CastToInteger: integer; inline;
function CastToInterface: IInterface; inline;
function CastToObject: TObject; overload; inline;
function CastToPointer: pointer;
function CastToRecord: IOmniAutoDestroyObject; inline;
function CastToString: string;
function CastToVariant: Variant;
function GetAsArray: TOmniValueContainer; inline;
function GetAsArrayItem(idx: integer): TOmniValue; overload; {$IF CompilerVersion >= 22}inline;{$IFEND}
function GetAsArrayItem(const name: string): TOmniValue; overload; {$IF CompilerVersion >= 22}inline;{$IFEND}
{$IF CompilerVersion >= 19}//D2007 has problems understanding this overload
function GetAsArrayItem(const param: TOmniValue): TOmniValue; overload; {$IF CompilerVersion >= 22}inline;{$IFEND}
//GetAsArrayItemOV is used in D2007 instead
{$IFEND}
function GetAsArrayItemOV(const param: TOmniValue): TOmniValue; overload; {$IF CompilerVersion >= 22}inline;{$IFEND}
procedure SetAsArray(value: TOmniValueContainer); inline;
procedure SetAsArrayItem(idx: integer; const value: TOmniValue); overload; {$IF CompilerVersion >= 22}inline;{$IFEND}
procedure SetAsArrayItem(const name: string; const value: TOmniValue); overload; {$IF CompilerVersion >= 22}inline;{$IFEND}
{$IF CompilerVersion >= 19}//D2007 has problems understanding this overload
procedure SetAsArrayItem(const param, value: TOmniValue); overload; {$IF CompilerVersion >= 22}inline;{$IFEND}
//SetAsArrayItemOV is used in D2007 instead
{$IFEND}
procedure SetAsArrayItemOV(const param, value: TOmniValue); overload; {$IF CompilerVersion >= 22}inline;{$IFEND}
procedure SetAsBoolean(const value: boolean); inline;
procedure SetAsCardinal(const value: cardinal); inline;
procedure SetAsDouble(value: Double); inline;
procedure SetAsDateTime(value: TDateTime); inline;
procedure SetAsException(value: Exception);
procedure SetAsExtended(value: Extended);
procedure SetAsInt64(const value: int64); inline;
procedure SetAsInteger(const value: integer); inline;
procedure SetAsInterface(const value: IInterface); //don't inline, something is broken in codegen (XE)
procedure SetAsObject(const value: TObject); inline;
procedure SetAsOwnedObject(const value: TObject); inline;
procedure SetAsPointer(const value: pointer); inline;
procedure SetAsRecord(const intf: IOmniAutoDestroyObject); inline;
procedure SetAsString(const value: string);
procedure SetAsVariant(const value: Variant);
procedure SetOwnsObject(const value: boolean);
{$REGION 'Documentation'}
/// <summary>Most of the code in this method never executes. It is just here so that
/// stupid compilation hints such as "Private symbol 'GetAsArrayItem' declared but
/// never used" are not shown.</summary>
{$ENDREGION}
class procedure _RemoveWarnings; inline; static;
procedure ClearIntf; inline;
{$IFDEF MSWINDOWS}
function CastToAnsiString: AnsiString; inline;
function CastToWideString: WideString;
procedure SetAsAnsiString(const value: AnsiString);
procedure SetAsWideString(const value: WideString);
{$ENDIF}
{$IFDEF OTL_ERTTI}
private
function GetAsTValue: TValue;
function GetArrayFromTValue(const value: TValue): TOmniValueContainer;
function GetTValueFromArray(const a: TOmniValueContainer): TValue;
procedure SetAsTValue(const value: TValue);
{$ENDIF}
public
constructor Create(const values: array of const);
constructor CreateNamed(const values: array of const; const cppDupConWorkaround: boolean = false);
procedure _AddRef; inline;
procedure _Release; inline;
procedure _ReleaseAndClear; inline;
function CastToBooleanDef(defValue: boolean): boolean; inline;
function CastToCardinalDef(defValue: cardinal): cardinal; inline;
function CastToDoubleDef(defValue: Double): Double; inline;
function CastToDateTimeDef(defValue: TDateTime): TDateTime; inline;
function CastToExceptionDef(defValue: Exception): Exception; inline;
function CastToExtendedDef(defValue: Extended): Extended; inline;
function CastToInt64Def(defValue: int64): int64; inline;
function CastToIntegerDef(defValue: integer): integer; inline;
function CastToInterfaceDef(const defValue: IInterface): IInterface; inline;
function CastToObjectDef(defValue: TObject): TObject; inline;
function CastToPointerDef(defValue: pointer): pointer; inline;
function CastToStringDef(const defValue: string): string; inline;
function CastToVariantDef(defValue: Variant): Variant; inline;
procedure Clear; inline;
function HasArrayItem(idx: integer): boolean; overload; inline;
function HasArrayItem(const name: string): boolean; overload; inline;
function HasArrayItem(const param: TOmniValue): boolean; overload; inline;
function IsArray: boolean; inline;
function IsBoolean: boolean; inline;
function IsEmpty: boolean; inline;
function IsException: boolean; inline;
function IsFloating: boolean; inline;
function IsDateTime: boolean; inline;
function IsInteger: boolean; inline;
function IsInterface: boolean; inline;
function IsInterfacedType: boolean; inline;
function IsObject: boolean; inline;
function IsOwnedObject: boolean; inline;
function IsPointer: boolean; inline;
function IsRecord: boolean; inline;
function IsString: boolean; inline;
function IsVariant: boolean; inline;
class function Null: TOmniValue; static;
function RawData: PInt64; inline;
procedure RawZero; inline;
function TryCastToBoolean(var value: boolean): boolean; inline;
function TryCastToCardinal(var value: cardinal): boolean; inline;
function TryCastToDouble(var value: Double): boolean;
function TryCastToDateTime(var value: TDateTime): boolean;
function TryCastToException(var value: Exception): boolean;
function TryCastToExtended(var value: Extended): boolean;
function TryCastToInt64(var value: int64): boolean; inline;
function TryCastToInteger(var value: integer): boolean; inline;
function TryCastToInterface(var value: IInterface): boolean; inline;
function TryCastToObject(var value: TObject): boolean; inline;
function TryCastToPointer(var value: pointer): boolean;
function TryCastToString(var value: string): boolean;
function TryCastToVariant(var value: Variant): boolean;
class operator Equal(const a: TOmniValue; i: integer): boolean; inline;
class operator Equal(const a: TOmniValue; const s: string): boolean; inline;
class operator Implicit(const a: boolean): TOmniValue; inline;
class operator Implicit(const a: Double): TOmniValue; inline;
class operator Implicit(const a: Extended): TOmniValue; inline;
class operator Implicit(const a: integer): TOmniValue; inline;
class operator Implicit(const a: int64): TOmniValue; inline;
class operator Implicit(const a: pointer): TOmniValue; inline;
class operator Implicit(const a: string): TOmniValue; inline;
class operator Implicit(const a: IInterface): TOmniValue; //don't inline, something is broken in codegen (XE)
class operator Implicit(const a: TObject): TOmniValue; inline;
class operator Implicit(const a: Exception): TOmniValue; inline;
class operator Implicit(const a: TOmniValue): int64; inline;
class operator Implicit(const a: TOmniValue): TObject; inline;
class operator Implicit(const a: TOmniValue): Double; inline;
class operator Implicit(const a: TOmniValue): Exception; inline;
class operator Implicit(const a: TOmniValue): Extended; inline;
class operator Implicit(const a: TOmniValue): string; inline;
class operator Implicit(const a: TOmniValue): integer; inline;
class operator Implicit(const a: TOmniValue): pointer; inline;
class operator Implicit(const a: TOmniValue): boolean; inline;
class operator Implicit(const a: TOmniValue): IInterface; inline;
class operator Implicit(const a: Variant): TOmniValue; inline;
{$IFDEF OTL_TOmniValueImplicitDateTime}
class operator Implicit(const a: TDateTime): TOmniValue; inline;
class operator Implicit(const a: TOmniValue): TDateTime; inline;
{$ENDIF OTL_TOmniValueImplicitDateTime}
property AsArray: TOmniValueContainer read GetAsArray;
property AsArrayItem[idx: integer]: TOmniValue read GetAsArrayItem write SetAsArrayItem; default;
property AsArrayItem[const name: string]: TOmniValue read GetAsArrayItem write SetAsArrayItem; default;
{$IF CompilerVersion >= 19}//D2007 has problems understanding this overload
property AsArrayItem[const param: TOmniValue]: TOmniValue read GetAsArrayItem write SetAsArrayItem; default;
{$IFEND}
property AsArrayItemOV[const param: TOmniValue]: TOmniValue read GetAsArrayItemOV write SetAsArrayItemOV;
property AsBoolean: boolean read CastToBoolean write SetAsBoolean;
property AsCardinal: cardinal read CastToCardinal write SetAsCardinal;
property AsDouble: Double read CastToDouble write SetAsDouble;
property AsDateTime: TDateTime read CastToDateTime write SetAsDateTime;
property AsException: Exception read CastToException write SetAsException;
property AsExtended: Extended read CastToExtended write SetAsExtended;
property AsInt64: int64 read CastToInt64 write SetAsInt64;
property AsInteger: integer read CastToInteger write SetAsInteger;
property AsInterface: IInterface read CastToInterface write SetAsInterface;
property AsObject: TObject read CastToObject write SetAsObject;
property AsOwnedObject: TObject read CastToObject write SetAsOwnedObject;
property AsPointer: pointer read CastToPointer write SetAsPointer;
property AsString: string read CastToString write SetAsString;
property AsVariant: Variant read CastToVariant write SetAsVariant;
property DataType: TOmniValueDataType read ovType;
property OwnsObject: boolean read IsOwnedObject write SetOwnsObject;
{$IFDEF MSWINDOWS}
function CastToAnsiStringDef(const defValue: AnsiString): AnsiString; inline;
function CastToWideStringDef(defValue: WideString): WideString; inline;
function IsAnsiString: boolean; inline;
function IsWideString: boolean; inline;
function TryCastToAnsiString(var value: AnsiString): boolean;
function TryCastToWideString(var value: WideString): boolean;
{$IFDEF Unicode}
class operator Implicit(const a: TOmniValue): AnsiString; inline;
class operator Implicit(const a: AnsiString): TOmniValue; inline;
{$ENDIF Unicode}
class operator Implicit(const a: TOmniValue): WideString; inline;
class operator Implicit(const a: WideString): TOmniValue; inline;
property AsAnsiString: AnsiString read CastToAnsiString write SetAsAnsiString;
property AsWideString: WideString read CastToWideString write SetAsWideString;
{$ENDIF}
{$IFDEF OTL_Generics}
class function CastFrom<T>(const value: T): TOmniValue; static;
function CastTo<T>: T;
class function FromRecord<T: record>(const value: T): TOmniValue; static;
function ToRecord<T>: T;
{$IFDEF OTL_HasArrayOfT}
class function FromArray<T>(const values: TArray<T>): TOmniValue; static;
function ToArray<T>: TArray<T>;
{$ENDIF OTL_HasArrayOfT}
{$IF CompilerVersion > 20}
function CastToObject<T: class>: T; overload;
function ToObject<T: class>: T;
{$IFEND}
{$ENDIF OTL_Generics}
{$IFDEF OTL_ERTTI}
class operator Implicit(const a: TValue): TOmniValue; inline;
class operator Implicit(const a: TOmniValue): TValue; inline;
property AsTValue: TValue read GetAsTValue write SetAsTValue;
{$ENDIF OTL_ERTTI}
end; { TOmniValue }
/// <summary>TOmniValue wrapper - for when you need to treat TOmniValue as an object.</summary>
TOmniValueObj = class
strict private
FValue: TOmniValue;
public
constructor Create(const value: TOmniValue);
property Value: TOmniValue read FValue;
end; { TOmniValueObj }
///<summary>Slightly different from the IEnumerable:
/// - Returns TOmniValue.
/// - Must ensure correct operation of multiple simultaneous enumerators.
/// - TryTake must be implemented to support mutable collections (as TOmniBlockingCollection).
/// For non-mutable collections TryTake can simply return false if the collection
/// is empty.
/// - TryTake must be threadsafe - when used in Parallel.For, data manager will call
/// it simultaneously from multiple threads at the same time.
///</summary>
IOmniValueEnumerator = interface ['{F60EBBD8-2F87-4ACD-A014-452F296F4699}']
function GetCurrent: TOmniValue;
function MoveNext: boolean;
function TryTake(var value: TOmniValue; timeout_ms: cardinal): boolean;
property Current: TOmniValue read GetCurrent;
end; { IOmniValueEnumerator }
IOmniValueEnumerable = interface ['{50C1C176-C61F-41F5-AA0B-6FD215E5159F}']
function GetEnumerator: IOmniValueEnumerator;
end; { IOmniValueEnumerable }
///<summary>Abstract enumerator class, used as a base for internal classes passed to the
/// OtlDataManager.</summary>
TOmniValueEnumerator = class abstract
function GetCurrent: TOmniValue; virtual; abstract;
function MoveNext: boolean; virtual; abstract;
property Current: TOmniValue read GetCurrent;
end; { TOmniValueEnumerator }
IOmniWaitableValue = interface ['{46EB21E0-B5E8-47DA-8E34-E4DE04C4D8D9}']
{$IFDEF MSWINDOWS}
function GetHandle: THandle;
{$ENDIF}
function GetEvent: TEvent;
function GetValue: TOmniValue;
//
procedure Reset;
procedure Signal; overload;
procedure Signal(const data: TOmniValue); overload;
function WaitFor(maxWait_ms: cardinal = INFINITE): boolean;
{$IFDEF MSWINDOWS}
property Handle: THandle read GetHandle;
{$ENDIF}
property Event: TEvent read GetEvent;
property Value: TOmniValue read GetValue;
end; { IOmniWaitableValue }
TOmniWaitableValue = class( TInterfacedObject, IOmniWaitableValue)
strict private
FEvent: TEvent;
FValue: TOmniValue;
protected
{$IFDEF MSWINDOWS}
function GetHandle: THandle;
{$ENDIF}
function GetEvent: TEvent;
function GetValue: TOmniValue;
public
constructor Create;
destructor Destroy; override;
procedure Reset; inline;
procedure Signal; overload; inline;
procedure Signal(const data: TOmniValue); overload; inline;
function WaitFor(maxWait_ms: cardinal = INFINITE): boolean; inline;
{$IFDEF MSWINDOWS}
property Handle: THandle read GetHandle;
{$ENDIF}
property Event: TEvent read GetEvent;
property Value: TOmniValue read GetValue;
end; { TOmniWaitableValue }
TOmniValueContainer = class
strict private
ovcCanModify: boolean;
ovcCount : integer;
ovcNames : array of string;
ovcValues : array of TOmniValue;
strict protected
function AddParam(const paramName: string): integer;
procedure Clear;
function GetItem(paramIdx: integer): TOmniValue; overload;
function GetItem(const paramName: string): TOmniValue; overload;
function GetItem(const param: TOmniValue): TOmniValue; overload;
procedure SetItem(idx: integer; const value: TOmniValue); overload; {$IF CompilerVersion >= 22}inline;{$IFEND}
procedure SetItem(const name: string; const value: TOmniValue); overload;
procedure SetItem(const param, value: TOmniValue); overload;
procedure Grow(requiredIdx: integer = -1);
public
constructor Create;
procedure Add(const paramValue: TOmniValue; const paramName: string = '');
procedure Assign(const parameters: array of TOmniValue);
procedure AssignNamed(const parameters: array of TOmniValue);
function ByName(const paramName: string): TOmniValue; overload;
function ByName(const paramName: string; const defValue: TOmniValue): TOmniValue; overload;
function Count: integer;
function Exists(const paramName: string): boolean;
function IndexOf(const paramName: string): integer;
procedure Insert(paramIdx: integer; const value: TOmniValue);
function IsLocked: boolean; inline;
procedure Lock; inline;
property Item[paramIdx: integer]: TOmniValue read GetItem write SetItem; default;
property Item[const paramName: string]: TOmniValue read GetItem write SetItem; default;
property Item[const param: TOmniValue]: TOmniValue read GetItem write SetItem; default;
end; { TOmniValueContainer }
//:Thread-safe counter
IOmniCounter = interface ['{3A73CCF3-EDC5-484F-8459-532B8C715E3C}']
function GetValue: integer;
procedure SetValue(const value: integer);
//
function Increment: integer;
function Decrement: integer;
function Take(count: integer): integer; overload;
function Take(count: integer; var taken: integer): boolean; overload;
property Value: integer read GetValue write SetValue;
end; { IOmniCounter }
TOmniCounter = record
strict private
{$IFNDEF MSWINDOWS}[Volatile]{$ENDIF}
ocCounter: IOmniCounter;
function GetValue: integer;
procedure SetValue(const value: integer);
public
procedure Initialize;
function Increment: integer;
function Decrement: integer;
function Take(count: integer): integer; overload;
function Take(count: integer; var taken: integer): boolean; overload;
property Value: integer read GetValue write SetValue;
end; { TOmniCounter }
{$IFDEF OTL_GoodGenerics}
TOmniInterfaceDictionaryPair = TPair<int64, IInterface>;
{$ELSE}
TOmniInterfaceDictionaryPair = class
strict private
idpKey : int64;
idpValue: IInterface;
protected
procedure SetKeyValue(const key: int64; const value: IInterface);
public
property Key: int64 read idpKey;
property Value: IInterface read idpValue;
end; { TOmniInterfaceDictionaryPair }
IOmniInterfaceDictionaryEnumerator = interface
function GetCurrent: TOmniInterfaceDictionaryPair;
function MoveNext: boolean;
property Current: TOmniInterfaceDictionaryPair read GetCurrent;
end; { IOmniInterfaceDictionaryEnumerator }
{$ENDIF OTL_GoodGenerics}
IOmniInterfaceDictionary = interface ['{619FCCF3-E810-4DCF-B902-1EF1A5A72DB5}']
{$IFDEF OTL_GoodGenerics}
function GetEnumerator: TDictionary<int64, IInterface>.TPairEnumerator;
{$ELSE}
function GetEnumerator: IOmniInterfaceDictionaryEnumerator;
{$ENDIF OTL_GoodGenerics}
//
procedure Add(const key: int64; const value: IInterface);
procedure Clear;
function Count: integer;
procedure Remove(const key: int64);
function ValueOf(const key: int64): IInterface;
end; { IOmniInterfaceDictionary }
IOmniAffinity = interface ['{8A6DDC70-F705-4577-869B-6810E776132B}']
function GetAsString: string;
function GetCount: integer;
function GetCountPhysical: integer;
procedure SetAsString(const value: string);
procedure SetCount(const value: integer);
{$IFDEF MSWINDOWS}
function GetMask: DWORD;
procedure SetMask(const value: DWORD);
{$ENDIF}
//
property AsString: string read GetAsString write SetAsString;
property Count: integer read GetCount write SetCount;
property CountPhysical: integer read GetCountPhysical;
{$IFDEF MSWINDOWS}
property Mask: DWORD read GetMask write SetMask;
{$ENDIF}
end; { IOmniAffinity }
{$IFDEF MSWINDOWS}
TOmniProcessMemoryCounters = TProcessMemoryCounters;
{$ENDIF}
{$IFDEF MSWINDOWS}
TOmniProcessTimes = record
CreationTime: TDateTime;
UserTime : int64;
KernelTime : int64;
end; { TOmniProcessTimes }
{$ENDIF}
TOmniProcessPriorityClass = (pcIdle, pcBelowNormal, pcNormal, pcAboveNormal, pcHigh,
pcRealtime);
IOmniProcessEnvironment = interface ['{98D6BDA3-840B-4E19-B01D-633E6A239FE9}']
function GetAffinity: IOmniAffinity;
function GetPriorityClass: TOmniProcessPriorityClass;
{$IFDEF MSWINDOWS}
function GetMemory: TOmniProcessMemoryCounters;
function GetTimes: TOmniProcessTimes;
{$ENDIF}
//
property Affinity: IOmniAffinity read GetAffinity;
property PriorityClass: TOmniProcessPriorityClass read GetPriorityClass;
{$IFDEF MSWINDOWS}
property Memory: TOmniProcessMemoryCounters read GetMemory;
property Times: TOmniProcessTimes read GetTimes;
{$ENDIF}
end; { IOmniProcessEnvironment }
IOmniSystemEnvironment = interface ['{9BE1EFE3-4ABB-4C2F-B2A4-B014D0949FEC}']
function GetAffinity: IOmniAffinity;
//
property Affinity: IOmniAffinity read GetAffinity;
end; { IOmniSystemEnvironment }
{$IFNDEF OTL_HasThreadID}
TThreadID = LongWord;
{$ENDIF ~OTL_HasThreadID}
IOmniThreadEnvironment = interface ['{5C11FEC7-9FBE-423F-B30E-543C8240E3A3}']
function GetAffinity: IOmniAffinity;
function GetID: TThreadId;
//
property Affinity: IOmniAffinity read GetAffinity;
property ID: TThreadId read GetID;
end; { IOmniThreadEnvironment }
IOmniEnvironment = interface ['{4F9594E2-8B88-483C-9616-85B50493406D}']
function GetProcess: IOmniProcessEnvironment;
function GetSystem: IOmniSystemEnvironment;
function GetThread: IOmniThreadEnvironment;
//
property Process: IOmniProcessEnvironment read GetProcess;
property System: IOmniSystemEnvironment read GetSystem;
property Thread: IOmniThreadEnvironment read GetThread;
end; { IOmniEnvironment }
TOmniExecutableKind = (oekNull, oekProcedure, oekMethod {$IFDEF OTL_Anonymous},
oekDelegate{$ENDIF});
TOmniExecutable = record
{$IFDEF OTL_Anonymous}
strict private
oeDelegate: TProc;
procedure SetAnonDelegate(const value: TProc); inline;
function GetDelegate: TProc; inline;
{$ENDIF OTL_Anonymous}
strict private
oeMethod : TMethod;
oeProcedure: TProcedure;
oeKind : TOmniExecutableKind;
procedure CheckKind(kind: TOmniExecutableKind); inline;
function GetMethod: TMethod; inline;
function GetProc: TProcedure; inline;
procedure SetMethod(const value: TMethod); inline;
procedure SetProc(const value: TProcedure); inline;
public
class operator Explicit(const a: TOmniExecutable): TMethod; inline;
class operator Explicit(const a: TOmniExecutable): TProcedure; inline;
class operator Explicit(const a: TMethod): TOmniExecutable; inline;
class operator Explicit(const a: TProcedure): TOmniExecutable; inline;
class operator Implicit(const a: TMethod): TOmniExecutable; inline;
class operator Implicit(const a: TProcedure): TOmniExecutable; inline;
class operator Implicit(const a: TOmniExecutable): TMethod; inline;
class operator Implicit(const a: TOmniExecutable): TProcedure; inline;
procedure Clear; inline;
function IsNull: boolean; inline;
property Kind: TOmniExecutableKind read oeKind;
property Method: TMethod read GetMethod write SetMethod;
property Proc: TProcedure read GetProc write SetProc;
public
{$IFDEF OTL_Anonymous}
class procedure AnonCopy(var Dest; const Source); static;
class operator Explicit(const a: TOmniExecutable): TProc; inline;
class operator Explicit(const a: TProc): TOmniExecutable; inline;
class operator Implicit(const a: TOmniExecutable): TProc; inline;
class operator Implicit(const a: TProc): TOmniExecutable; inline;
procedure SetDelegate(const source);
property Delegate: TProc read GetDelegate write SetAnonDelegate;
{$ENDIF OTL_Anonymous}
end; { TOmniExecutable }
TOmniMessageIDType = (mitInteger, mitString, mitPointer);
///<summary>Describes 'smart' IOmniTaskControl message (either message ID, method name,
/// or method pointer.</summary>
///<since>2010-03-16</since>
TOmniMessageID = record
strict private
omidInteger : integer;
omidMessageType: TOmniMessageIDType;
omidPointer : pointer;
omidString : string;
public
class operator Implicit(const a: integer): TOmniMessageID; inline;
class operator Implicit(const a: pointer): TOmniMessageID; inline;
class operator Implicit(const a: string): TOmniMessageID; inline;
class operator Implicit(const a: TOmniMessageID): integer; inline;
class operator Implicit(const a: TOmniMessageID): string; inline;
class operator Implicit(const a: TOmniMessageID): pointer; inline;
function AsString: string;
property MessageType: TOmniMessageIDType read omidMessageType;
end; { TOmniMessageID }
{$IFDEF OTL_Generics}
TOmniRecordWrapper<T> = class
strict private
FValue: T;
public
constructor Create(const value: T);
function GetRecord: T;
procedure SetRecord(const value: T);
property Value: T read GetRecord write SetRecord;
end; { TOmniRecordWrapper<T> }
{$ENDIF OTL_Generics}
IOmniAutoDestroyObject = interface ['{37DE60D3-C53D-4D13-B87C-C70BDC76A530}']
function GetValue: TObject;
function Detach: TObject;
//
property Value: TObject read GetValue;
end; { IOmniAutoDestroyObject }
TOmniAlignedInt32 = record
strict private
FData: int64;
FAddr: PInteger;
function GetValue: integer; inline;
procedure SetValue(value: integer); inline;
public
procedure Initialize; inline;
function Add(value: integer): integer; inline;
function Addr: PInteger; inline;
function CAS(oldValue, newValue: integer): boolean;
function Decrement: integer; overload; inline;
function Decrement(value: integer): integer; overload; inline;
function Increment: integer; overload; inline;
function Increment(value: integer): integer; overload; inline;
function Subtract(value: integer): integer; inline;
class operator Add(const ai: TOmniAlignedInt32; i: integer): cardinal; inline;
class operator Equal(const ai: TOmniAlignedInt32; i: integer): boolean; inline;
class operator GreaterThan(const ai: TOmniAlignedInt32; i: integer): boolean; inline;
class operator GreaterThanOrEqual(const ai: TOmniAlignedInt32; i: integer): boolean; inline;
class operator Implicit(const ai: TOmniAlignedInt32): integer; inline;
class operator Implicit(const ai: TOmniAlignedInt32): cardinal; inline;
class operator Implicit(const ai: TOmniAlignedInt32): PInteger; inline;
class operator LessThan(const ai: TOmniAlignedInt32; i: integer): boolean; inline;
class operator LessThanOrEqual(const ai: TOmniAlignedInt32; i: integer): boolean; inline;
class operator NotEqual(const ai: TOmniAlignedInt32; i: integer): boolean; inline;
class operator Subtract(ai: TOmniAlignedInt32; i: integer): cardinal; inline;
property Value: integer read GetValue write SetValue;
end; { TOmniAlignedInt32 }
TOmniAlignedInt64 = record
strict private
FData: packed record
DataLo, DataHi: int64;
end;
FAddr: PInt64;
function GetValue: int64; inline;
procedure SetValue(value: int64); inline;
public
procedure Initialize; inline;
function Add(value: int64): int64; inline;
function Addr: PInt64; inline;
function CAS(oldValue, newValue: int64): boolean;
function Decrement: int64; overload; inline;
function Decrement(value: int64): int64; overload; inline;
function Increment: int64; overload; inline;
function Increment(value: int64): int64; overload; inline;
function Subtract(value: int64): int64; inline;
property Value: int64 read GetValue write SetValue;
end; { TOmniAlignedInt64 }
{$IFNDEF MSWINDOWS}
TObjectList = class(TObjectList<TObject>)
end;
{$ENDIF}
function CreateCounter(initialValue: integer = 0): IOmniCounter;
function CreateInterfaceDictionary: IOmniInterfaceDictionary;
function CreateWaitableValue: IOmniWaitableValue;
function CreateAutoDestroyObject(obj: TObject): IOmniAutoDestroyObject;
function Environment: IOmniEnvironment;
procedure SetThreadName(const name: string);
function VarToObj(const v: Variant): TObject; inline;
function NextOid: int64;
var
{$IFDEF OTL_USE_ALIGN}
[Volatile] OtlUID: int64 = 0;
{$ELSE}
OtlUID: TOmniAlignedInt64;
{$ENDIF}
TOmniValue_DataSize: array [TTypeKind] of integer;
implementation
{$IFDEF MSWINDOWS}
uses
{$IFDEF OTL_StrPasInAnsiStrings}System.AnsiStrings,{$ENDIF}
GpStringHash;
{$ENDIF}
type
{$IFDEF MSWINDOWS}
IOmniAnsiStringData = interface ['{DBF5674C-AEFF-4CBD-AEC5-95F7A2FC80FF}']
function GetValue: AnsiString;
procedure SetValue(const value: AnsiString);
property Value: AnsiString read GetValue write SetValue;
end; { IOmniStringData }
TOmniAnsiStringData = class(TInterfacedObject, IOmniAnsiStringData)
strict private
osdValue: AnsiString;
public
constructor Create(const value: AnsiString);
function GetValue: AnsiString;
procedure SetValue(const value: AnsiString);
property Value: AnsiString read GetValue write SetValue;
end; { TOmniAnsiStringData }
{$ENDIF}
IOmniStringData = interface ['{21E52E56-390C-4066-B9FC-83862FFBCBF3}']
function GetValue: string;
procedure SetValue(const value: string);
property Value: string read GetValue write SetValue;
end; { IOmniStringData }
TOmniStringData = class(TInterfacedObject, IOmniStringData)
strict private
osdValue: string;
public
constructor Create(const value: string);
function GetValue: string;
procedure SetValue(const value: string);
property Value: string read GetValue write SetValue;
end; { TOmniStringData }
{$IFDEF MSWINDOWS}
IOmniWideStringData = interface ['{B303DB23-4A06-4D25-814A-8A9EDC90D066}']
function GetValue: WideString;
procedure SetValue(const value: WideString);
property Value: WideString read GetValue write SetValue;
end; { IOmniWideStringData }
TOmniWideStringData = class(TInterfacedObject, IOmniWideStringData)
strict private
osdValue: WideString;
public
constructor Create(const value: WideString);
function GetValue: WideString;
procedure SetValue(const value: WideString);
property Value: WideString read GetValue write SetValue;
end; { TOmniWideStringData }
{$ENDIF}
IOmniVariantData = interface ['{65311D7D-67F1-452E-A0BD-C90596671FC8}']
function GetValue: Variant;
procedure SetValue(const value: Variant);
property Value: Variant read GetValue write SetValue;
end; { IOmniVariantData }
TOmniVariantData = class(TInterfacedObject, IOmniVariantData)
strict private
ovdValue: Variant;
public
constructor Create(const value: Variant);
function GetValue: Variant;
procedure SetValue(const value: Variant);
property Value: Variant read GetValue write SetValue;
end; { TOmniVariantData }
IOmniExtendedData = interface ['{B6CD371F-A461-436A-8767-9BCA194B1D0E}']
function GetValue: Extended;
procedure SetValue(const value: Extended);
property Value: Extended read GetValue write SetValue;
end; { IOmniExtendedData }
TOmniExtendedData = class(TInterfacedObject, IOmniExtendedData)
strict private
oedValue: Extended;
public
constructor Create(const value: Extended);
function GetValue: Extended;
procedure SetValue(const value: Extended);
property Value: Extended read GetValue write SetValue;
end; { TOmniExtendedData }
TOmniCounterImpl = class(TInterfacedObject, IOmniCounter)
strict private