diff --git a/DictSlot.mqh b/DictSlot.mqh index 3752244c9..1b28cea9e 100644 --- a/DictSlot.mqh +++ b/DictSlot.mqh @@ -40,11 +40,11 @@ class DictSlot { DictSlot(unsigned char flags = 0) : _flags(flags) {} -#ifdef __MQL__ - DictSlot(const DictSlot& r) : _flags(r._flags), key(r.key), value(r.value) {} -#else + //#ifdef __MQL__ + // DictSlot(const DictSlot& r) : _flags(r._flags), key(r.key), value(r.value) {} + //#else DictSlot(const DictSlot& r) : _flags(r._flags), key(r.key) { value = r.value; } -#endif + //#endif bool IsValid() { return !bool(_flags & DICT_SLOT_INVALID); } diff --git a/Indicator/tests/classes/Indicators.h b/Indicator/tests/classes/Indicators.h index aac05a9ee..871d059a3 100644 --- a/Indicator/tests/classes/Indicators.h +++ b/Indicator/tests/classes/Indicators.h @@ -40,7 +40,7 @@ class Indicators { DictStruct> _indis; public: - void Add(IndicatorBase* _indi) { + void Add(IndicatorData* _indi) { Ref _ref = _indi; _indis.Push(_ref); } @@ -51,7 +51,7 @@ class Indicators { IndicatorData* operator[](int index) { return Get(index); } - int Size() { return _indis.Size(); } + int Size() { return (int)_indis.Size(); } /** * Executes OnTick() on every added indicator. diff --git a/Refs.struct.h b/Refs.struct.h index 3de03deba..ddda68a3b 100644 --- a/Refs.struct.h +++ b/Refs.struct.h @@ -357,6 +357,14 @@ struct WeakRef { return Ptr(); } + /** + * Makes a weak reference to the given weakly-referenced object. + */ + X* operator=(const WeakRef& right) { + THIS_REF = right.Ptr(); + return Ptr(); + } + /** * Makes a weak reference to the strongly-referenced object. */ @@ -365,6 +373,14 @@ struct WeakRef { return Ptr(); } + /** + * Makes a weak reference to the strongly-referenced object. + */ + X* operator=(const Ref& right) { + THIS_REF = right.Ptr(); + return Ptr(); + } + /** * Equality operator. */ diff --git a/Tick/Tick.struct.h b/Tick/Tick.struct.h index 71f08dcf8..bda8880d5 100644 --- a/Tick/Tick.struct.h +++ b/Tick/Tick.struct.h @@ -47,6 +47,20 @@ struct MqlTick { long time_msc; // Time of a price last update in milliseconds. unsigned int flags; // Tick flags. unsigned long volume; // Volume for the current last price. + // Default constructor. + MqlTick() {} + + // Copy constructor. + MqlTick(){const MqlTick & r} { + time = r.time; + ask = r.ask; + bid = r.bid; + last = r.last; + volume_real = r.volume_real; + time_msc = r.time_msc; + flags = r.flags; + volume = r.volume; + } }; #endif diff --git a/Tick/TickManager.h b/Tick/TickManager.h index 76f2f0e1d..d34239ac3 100644 --- a/Tick/TickManager.h +++ b/Tick/TickManager.h @@ -27,6 +27,7 @@ // Includes. #include "../BufferStruct.mqh" +#include "Tick.struct.h" #include "TickManager.h" //#include "TickManager.struct.h" diff --git a/tests/IndicatorsTest.mq5 b/tests/IndicatorsTest.mq5 index b306ed976..c113d8892 100644 --- a/tests/IndicatorsTest.mq5 +++ b/tests/IndicatorsTest.mq5 @@ -53,8 +53,8 @@ enum ENUM_CUSTOM_INDICATORS { INDI_SPECIAL_MATH_CUSTOM = FINAL_INDICATOR_TYPE_EN // Global variables. Indicators indis; -DictStruct whitelisted_indis; -DictStruct tested; +Dict whitelisted_indis; +Dict tested; double test_values[] = {1.245, 1.248, 1.254, 1.264, 1.268, 1.261, 1.256, 1.250, 1.242, 1.240, 1.235, 1.240, 1.234, 1.245, 1.265, 1.274, 1.285, 1.295, 1.300, 1.312, 1.315, 1.320, 1.325, 1.335, 1.342, 1.348, 1.352, 1.357, 1.359, 1.422, 1.430, 1.435}; diff --git a/tests/RefsTest.mq5 b/tests/RefsTest.mq5 index 8f0b0cf9e..943a22378 100644 --- a/tests/RefsTest.mq5 +++ b/tests/RefsTest.mq5 @@ -137,26 +137,25 @@ int OnInit() { // Dictionary of weak references. DictStruct> refs2; - /* - Ref dyn9_1 = new DynamicClass(1); - Ref dyn9_2 = new DynamicClass(2); - Ref dyn9_3 = new DynamicClass(3); + Ref dyn9_1 = new DynamicClass(1); + Ref dyn9_2 = new DynamicClass(2); + Ref dyn9_3 = new DynamicClass(3); - WeakRef dyn9_1_weak_ref = dyn9_1; - WeakRef dyn9_2_weak_ref = dyn9_2; - WeakRef dyn9_3_weak_ref = dyn9_3; + WeakRef dyn9_1_weak_ref = dyn9_1; + WeakRef dyn9_2_weak_ref = dyn9_2; + WeakRef dyn9_3_weak_ref = dyn9_3; - refs2.Set("1", dyn9_1_weak_ref); - refs2.Set("2", dyn9_2_weak_ref); - refs2.Set("3", dyn9_3_weak_ref); + refs2.Set("1", dyn9_1_weak_ref); + refs2.Set("2", dyn9_2_weak_ref); + refs2.Set("3", dyn9_3_weak_ref); - // Should make refs2["2"] to have no existing object. - dyn9_2 = NULL; + // Should make refs2["2"] to have no existing object. + dyn9_2 = NULL; + + assertTrueOrFail(refs2.GetByKey("1").ObjectExists(), "Object should exists"); + assertTrueOrFail(!refs2.GetByKey("2").ObjectExists(), "Object should not exists as it has no more strong references"); + assertTrueOrFail(refs2.GetByKey("3").ObjectExists(), "Object should exists"); - assertTrueOrFail(refs2.GetByKey("1").ObjectExists(), "Object should exists"); - assertTrueOrFail(!refs2.GetByKey("2").ObjectExists(), "Object should not exists as it has no more strong - references"); assertTrueOrFail(refs2.GetByKey("3").ObjectExists(), "Object should exists"); - */ return INIT_SUCCEEDED; }