Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev-v2012-renames' into dev-v2012
Browse files Browse the repository at this point in the history
* origin/dev-v2012-renames:
  Renames Collection to Storage/
  • Loading branch information
kenorb committed Jul 3, 2022
2 parents 4d07ee6 + 12ce161 commit f9afe77
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 68 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/test-storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: Test Storage

# yamllint disable-line rule:truthy
on:
pull_request:
paths:
- 'Storage/**'
- '.github/workflows/test-storage.yml'
push:
paths:
- 'Storage/**'
- '.github/workflows/test-storage.yml'

jobs:

Compile:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Compile
uses: fx31337/mql-compile-action@master
with:
init-platform: true
path: 'Storage/tests'
verbose: true
- name: Print compiled files
run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname'
shell: powershell
- name: Upload artifacts (MQL4)
uses: actions/upload-artifact@v2
with:
name: files-ex4
path: '**/*.ex4'
- name: Upload artifacts (MQL5)
uses: actions/upload-artifact@v2
with:
name: files-ex5
path: '**/*.ex5'

Storage-Tests-MQL4:
defaults:
run:
shell: bash
working-directory: Storage/tests
needs: Compile
runs-on: ubuntu-latest
strategy:
matrix:
test:
- Collection.test
steps:
- uses: actions/download-artifact@v2
with:
name: files-ex4
- name: Run ${{ matrix.test }}
uses: fx31337/mql-tester-action@master
with:
Script: ${{ matrix.test }}
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ jobs:
matrix:
test:
# - 3DTest
- CollectionTest
- ConfigTest
- ConvertTest
- DateTimeTest
Expand Down
4 changes: 2 additions & 2 deletions Log.mqh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2021, EA31337 Ltd |
//| Copyright 2016-2022, EA31337 Ltd |
//| https://github.com/EA31337 |
//+------------------------------------------------------------------+

Expand All @@ -22,10 +22,10 @@

// Includes.
#include "Array.mqh"
#include "Collection.mqh"
#include "DateTime.mqh"
#include "DictStruct.mqh"
#include "Object.mqh"
#include "Storage/Collection.mqh"

// Prevents processing this includes file for the second time.
#ifndef LOG_MQH
Expand Down
4 changes: 2 additions & 2 deletions Profiler.mqh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2021, EA31337 Ltd |
//| Copyright 2016-2022, EA31337 Ltd |
//| https://github.com/EA31337 |
//+------------------------------------------------------------------+

Expand All @@ -21,7 +21,7 @@
*/

// Includes.
#include "Collection.mqh"
#include "Storage/Collection.mqh"
#include "Timer.mqh"

// Defines macros.
Expand Down
44 changes: 0 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ It can be also used to convert your MQL4 code into MQL5 with minimum code change
- [`Account` class](#account-class)
- [Example 1 - Managing account (dynamic calls)](#example-1---managing-account-dynamic-calls)
- [Example 2 - Managing account (static calls)](#example-2---managing-account-static-calls)
- [`Collection` class](#collection-class)
- [`Dict` class](#dict-class)
- [Example 1 - Storing string-int data structures](#example-1---storing-string-int-data-structures)
- [`Mail` class](#mail-class)
Expand Down Expand Up @@ -181,49 +180,6 @@ The class for managing the current trading account.
// Some trade code.
}

### `Collection` class

This class is for storing various type of objects. Here is the example usage:

// Define custom classes of Object type.
class Stack : Object {
public:
virtual string GetName() = NULL;
};
class Foo : Stack {
public:
string GetName() { return "Foo"; };
double Weight() { return 0; };
};
class Bar : Stack {
public:
string GetName() { return "Bar"; };
double Weight() { return 1; };
};
class Baz : Stack {
public:
string GetName() { return "Baz"; };
double Weight() { return 2; };
};

int OnInit() {
// Define and add items.
Collection *stack = new Collection();
stack.Add(new Foo);
stack.Add(new Bar);
stack.Add(new Baz);
// Print the lowest and the highest items.
Print("Lowest: ", ((Stack *)stack.GetLowest()).GetName());
Print("Highest: ", ((Stack *)stack.GetHighest()).GetName());
// Print all the items.
for (uint i = 0; i < stack.GetSize(); i++) {
Print(i, ": ", ((Stack *)stack.GetByIndex(i)).GetName());
}
// Clean up.
Object::Delete(stack);
return (INIT_SUCCEEDED);
}

### `Dict` class

Use this class to store the values in form of a collective attribute–value pairs,
Expand Down
11 changes: 5 additions & 6 deletions Collection.mqh → Storage/Collection.mqh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2021, EA31337 Ltd |
//| Copyright 2016-2022, EA31337 Ltd |
//| https://github.com/EA31337 |
//+------------------------------------------------------------------+

Expand All @@ -25,12 +25,12 @@
#define COLLECTION_MQH

// Includes.
#include "Object.mqh"
#include "../Object.mqh"

/**
* Class to deal with collection of objects.
*/
template<typename X>
template <typename X>
class Collection {
protected:
// Variables.
Expand All @@ -45,8 +45,7 @@ class Collection {
Collection() {}
Collection(string _name) : name(_name) {}
Collection(void *_obj) { Add(_obj); }
~Collection() {
}
~Collection() {}

/* Setters */

Expand Down Expand Up @@ -99,7 +98,7 @@ class Collection {
/**
* Returns pointer to the current object.
*/
X* GetCurrentItem() { return data[index].Ptr() != NULL ? data[index].Ptr() : NULL; }
X *GetCurrentItem() { return data[index].Ptr() != NULL ? data[index].Ptr() : NULL; }

/**
* Returns ID of the current object.
Expand Down
44 changes: 44 additions & 0 deletions Storage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Storage classes

## `Collection` class

This class is for storing various type of objects. Here is the example usage:

// Define custom classes of Object type.
class Stack : Object {
public:
virtual string GetName() = NULL;
};
class Foo : Stack {
public:
string GetName() { return "Foo"; };
double Weight() { return 0; };
};
class Bar : Stack {
public:
string GetName() { return "Bar"; };
double Weight() { return 1; };
};
class Baz : Stack {
public:
string GetName() { return "Baz"; };
double Weight() { return 2; };
};

int OnInit() {
// Define and add items.
Collection *stack = new Collection();
stack.Add(new Foo);
stack.Add(new Bar);
stack.Add(new Baz);
// Print the lowest and the highest items.
Print("Lowest: ", ((Stack *)stack.GetLowest()).GetName());
Print("Highest: ", ((Stack *)stack.GetHighest()).GetName());
// Print all the items.
for (uint i = 0; i < stack.GetSize(); i++) {
Print(i, ": ", ((Stack *)stack.GetByIndex(i)).GetName());
}
// Clean up.
Object::Delete(stack);
return (INIT_SUCCEEDED);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2021, EA31337 Ltd |
//| Copyright 2016-2022, EA31337 Ltd |
//| https://github.com/EA31337 |
//+------------------------------------------------------------------+

Expand All @@ -25,4 +25,4 @@
*/

// Includes.
#include "CollectionTest.mq5"
#include "Collection.test.mq5"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2021, EA31337 Ltd |
//| Copyright 2016-2022, EA31337 Ltd |
//| https://github.com/EA31337 |
//+------------------------------------------------------------------+

Expand All @@ -26,7 +26,7 @@

// Includes.
#include "../Collection.mqh"
#include "../Test.mqh"
#include "../../Test.mqh"

// Define classes.
class Stack : public Object {
Expand Down
4 changes: 2 additions & 2 deletions tests/CompileTest.mq5
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2021, EA31337 Ltd |
//| Copyright 2016-2022, EA31337 Ltd |
//| https://github.com/EA31337 |
//+------------------------------------------------------------------+

Expand Down Expand Up @@ -43,7 +43,6 @@
#include "../Buffer.mqh"
#include "../BufferStruct.mqh"
#include "../Chart.mqh"
#include "../Collection.mqh"
#include "../Config.mqh"
#include "../Convert.mqh"
#include "../Database.mqh"
Expand All @@ -66,6 +65,7 @@
#include "../Inet.mqh"
#include "../Log.mqh"
#include "../MD5.mqh"
#include "../Storage/Collection.mqh"
#include "../Storage/IValueStorage.h"
#include "../Task/TaskCondition.h"
//#include "../MQL4.mqh" // @removeme
Expand Down
7 changes: 0 additions & 7 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ services:
BT_DAYS: 1-4
BT_MONTHS: 1
OPT_VERBOSE: 1
CollectionTest:
command: run_backtest -s CollectionTest.mq4
image: ea31337/ea-tester:latest
volumes:
- ../:/opt/src
environment:
OPT_VERBOSE: 1
ConditionTest:
command: run_backtest -e ConditionTest.mq4
image: ea31337/ea-tester:EURUSD-2019-DS
Expand Down

0 comments on commit f9afe77

Please sign in to comment.