Commit UEA [20/06/2018]
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ObjectsCustom.mqh |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2015, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Base Class CObjectCustom |
|
||||
//+------------------------------------------------------------------+
|
||||
class CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing human beings. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CHuman : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing weather. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CWeather : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing Expert Advisors. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CExpert : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing cars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CCar : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing numbers. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CNumber : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing price bars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CBar : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing quotations. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CQuotes : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing the MetaQuotes company. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CMetaQuotes : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing ships. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CShip : public CObjectCustom
|
||||
{
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ObjectsCustom.mqh |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2015, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Base class CObjectCustom |
|
||||
//+------------------------------------------------------------------+
|
||||
class CObjectCustom
|
||||
{
|
||||
public:
|
||||
|
||||
void CObjectCustom()
|
||||
{
|
||||
printf("Object #"+(string)(count++)+" - "+typename(this));
|
||||
}
|
||||
private:
|
||||
static int count;
|
||||
};
|
||||
static int CObjectCustom::count=0;
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing human beings. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CHuman : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing weather. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CWeather : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing Expert Advisors. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CExpert : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing cars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CCar : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing numbers. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CNumber : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing price bars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CBar : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing quotations. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CQuotes : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing the MetaQuotes company. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CMetaQuotes : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing ships. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CShip : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,19 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Test.mq5 |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2014, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
|
||||
#include "ObjectsCustom.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
CObjectCustom array[3];
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,77 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ObjectsCustom.mqh |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2015, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Base class CObjectCustom |
|
||||
//+------------------------------------------------------------------+
|
||||
class CObjectCustom
|
||||
{
|
||||
public:
|
||||
|
||||
void CObjectCustom()
|
||||
{
|
||||
printf("Object #"+(string)(count++)+" - "+typename(this));
|
||||
}
|
||||
private:
|
||||
static int count;
|
||||
};
|
||||
static int CObjectCustom::count=0;
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing human beings. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CHuman : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing weather. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CWeather : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing Expert Advisors. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CExpert : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing cars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CCar : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing numbers. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CNumber : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing price bars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CBar : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing quotations. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CQuotes : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing the MetaQuotes company. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CMetaQuotes : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing ships. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CShip : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,21 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Test.mq5 |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2014, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
|
||||
#include "ObjectsCustom.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
CObjectCustom array[3];
|
||||
CWeather weather;
|
||||
array[0]=weather;
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,77 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ObjectsCustom.mqh |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2015, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Base class CObjectCustom |
|
||||
//+------------------------------------------------------------------+
|
||||
class CObjectCustom
|
||||
{
|
||||
public:
|
||||
|
||||
void CObjectCustom()
|
||||
{
|
||||
printf("Object #"+(string)(count++)+" - "+typename(this));
|
||||
}
|
||||
private:
|
||||
static int count;
|
||||
};
|
||||
static int CObjectCustom::count=0;
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing human beings. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CHuman : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing weather. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CWeather : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing Expert Advisors. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CExpert : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing cars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CCar : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing numbers. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CNumber : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing price bars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CBar : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing quotations. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CQuotes : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing the MetaQuotes company. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CMetaQuotes : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing ships. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CShip : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,21 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Test.mq5 |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2014, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
|
||||
#include "ObjectsCustom.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
CObjectCustom *array[3];
|
||||
CWeather *weather=new CWeather();
|
||||
array[0]=weather;
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,77 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ObjectsCustom.mqh |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2015, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Base class CObjectCustom |
|
||||
//+------------------------------------------------------------------+
|
||||
class CObjectCustom
|
||||
{
|
||||
public:
|
||||
|
||||
void CObjectCustom()
|
||||
{
|
||||
printf("Object #"+(string)(count++)+" - "+typename(this));
|
||||
}
|
||||
private:
|
||||
static int count;
|
||||
};
|
||||
static int CObjectCustom::count=0;
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing human beings. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CHuman : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing weather. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CWeather : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing Expert Advisors. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CExpert : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing cars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CCar : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing numbers. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CNumber : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing price bars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CBar : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing quotations. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CQuotes : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing the MetaQuotes company. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CMetaQuotes : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing ships. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CShip : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,27 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Test.mq5 |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2014, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
|
||||
#include "ObjectsCustom.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
CObjectCustom *arrayObj[8];
|
||||
arrayObj[0] = new CHuman();
|
||||
arrayObj[1] = new CWeather();
|
||||
arrayObj[2] = new CExpert();
|
||||
arrayObj[3] = new CCar();
|
||||
arrayObj[4] = new CNumber();
|
||||
arrayObj[5] = new CBar();
|
||||
arrayObj[6] = new CMetaQuotes();
|
||||
arrayObj[7] = new CShip();
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,77 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ObjectsCustom.mqh |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2015, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Base class CObjectCustom |
|
||||
//+------------------------------------------------------------------+
|
||||
class CObjectCustom
|
||||
{
|
||||
public:
|
||||
|
||||
void CObjectCustom()
|
||||
{
|
||||
printf("Object #"+(string)(count++)+" - "+typename(this));
|
||||
}
|
||||
private:
|
||||
static int count;
|
||||
};
|
||||
static int CObjectCustom::count=0;
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing human beings. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CHuman : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing weather. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CWeather : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing Expert Advisors. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CExpert : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing cars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CCar : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing numbers. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CNumber : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing price bars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CBar : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing quotations. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CQuotes : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing the MetaQuotes company. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CMetaQuotes : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing ships. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CShip : public CObjectCustom
|
||||
{
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,22 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Test.mq5 |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2014, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
|
||||
#include "ObjectsCustom.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
CObjectCustom *arrayObj[8];
|
||||
arrayObj[0]=new CHuman();
|
||||
CObjectCustom*obj=arrayObj[0];
|
||||
CHuman *human=obj;
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,97 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ObjectsCustom.mqh |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2015, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
|
||||
#include "Types.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Base Class CObjectCustom |
|
||||
//+------------------------------------------------------------------+
|
||||
class CObjectCustom
|
||||
{
|
||||
private:
|
||||
int m_type;
|
||||
protected:
|
||||
CObjectCustom(int type){m_type=type;}
|
||||
public:
|
||||
CObjectCustom(){m_type=TYPE_OBJECT;}
|
||||
int Type(){return m_type;}
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing human beings. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CHuman : public CObjectCustom
|
||||
{
|
||||
public:
|
||||
CHuman() : CObjectCustom(TYPE_HUMAN){;}
|
||||
void Run(void){printf("Human run...");}
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing weather. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CWeather : public CObjectCustom
|
||||
{
|
||||
public:
|
||||
CWeather() : CObjectCustom(TYPE_WEATHER){;}
|
||||
double Temp(void){return 32.0;}
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing Expert Advisors. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CExpert : public CObjectCustom
|
||||
{
|
||||
public:
|
||||
CExpert() : CObjectCustom(TYPE_EXPERT){;}
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing cars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CCar : public CObjectCustom
|
||||
{
|
||||
public:
|
||||
CCar() : CObjectCustom(TYPE_CAR){;}
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing numbers. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CNumber : public CObjectCustom
|
||||
{
|
||||
public:
|
||||
CNumber() : CObjectCustom(TYPE_NUMBER){;}
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing price bars. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CBar : public CObjectCustom
|
||||
{
|
||||
public:
|
||||
CBar() : CObjectCustom(TYPE_BAR){;}
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing quotations. |
|
||||
//+------------------------------------------------------------------+
|
||||
//class CQuotes : public CObjectCustom
|
||||
// {
|
||||
//public:
|
||||
// CQuotes() : CObjectCustom(TYPE_QUOTES){;}
|
||||
// };
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing the MetaQuotes company. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CMetaQuotes : public CObjectCustom
|
||||
{
|
||||
public:
|
||||
CMetaQuotes() : CObjectCustom(TYPE_MQ){;}
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class describing ships. |
|
||||
//+------------------------------------------------------------------+
|
||||
class CShip : public CObjectCustom
|
||||
{
|
||||
public:
|
||||
CShip() : CObjectCustom(TYPE_SHIP){;}
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,43 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Test.mq5 |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2014, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
|
||||
#include "ObjectsCustom.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
CObjectCustom *arrayObj[3];
|
||||
arrayObj[0] = new CHuman();
|
||||
arrayObj[1] = new CWeather();
|
||||
arrayObj[2] = new CBar();
|
||||
for(int i=0; i<ArraySize(arrayObj); i++)
|
||||
{
|
||||
CObjectCustom *obj=arrayObj[i];
|
||||
switch(obj.Type())
|
||||
{
|
||||
case TYPE_HUMAN:
|
||||
{
|
||||
CHuman *human=obj;
|
||||
human.Run();
|
||||
break;
|
||||
}
|
||||
case TYPE_WEATHER:
|
||||
{
|
||||
CWeather *weather=obj;
|
||||
printf(DoubleToString(weather.Temp(),1));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printf("unknown type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,17 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Types.mqh |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2015, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
|
||||
#define TYPE_OBJECT 0 // General type CObjectCustom
|
||||
#define TYPE_HUMAN 1 // Class CHuman
|
||||
#define TYPE_WEATHER 2 // Class CWeather
|
||||
#define TYPE_EXPERT 3 // Class CExpert
|
||||
#define TYPE_CAR 4 // Class CCar
|
||||
#define TYPE_NUMBER 5 // Class CNumber
|
||||
#define TYPE_BAR 6 // Class CBar
|
||||
#define TYPE_MQ 7 // Class CMetaQuotes
|
||||
#define TYPE_SHIP 8 // Class CShip
|
||||
@@ -0,0 +1,52 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| TestList.mq5 |
|
||||
//| Copyright 2015, Vasiliy Sokolov. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2014, Vasiliy Sokolov."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
#include <Object.mqh>
|
||||
#include <Arrays\List.mqh>
|
||||
|
||||
class CCar : public CObject{};
|
||||
class CExpert : public CObject{};
|
||||
class CWealth : public CObject{};
|
||||
class CShip : public CObject{};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
CList list;
|
||||
list.Add(new CCar());
|
||||
list.Add(new CExpert());
|
||||
list.Add(new CWealth());
|
||||
list.Add(new CShip());
|
||||
printf(">>> enumerate from begin to end >>>");
|
||||
EnumerateAll(list);
|
||||
printf("<<< enumerate from end to begin <<<");
|
||||
ReverseEnumerateAll(list);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Enumerates the list from beginning to end displaying a sequence |
|
||||
//| number of each element in the terminal. |
|
||||
//+------------------------------------------------------------------+
|
||||
void EnumerateAll(CList &list)
|
||||
{
|
||||
CObject *node=list.GetFirstNode();
|
||||
for(int i=0; node!=NULL; i++,node=node.Next())
|
||||
printf("Element at "+(string)i);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Enumerates the list from end to beginning displaying a sequence |
|
||||
//| number of each element in the terminal |
|
||||
//+------------------------------------------------------------------+
|
||||
void ReverseEnumerateAll(CList &list)
|
||||
{
|
||||
CObject *node=list.GetLastNode();
|
||||
for(int i=list.Total()-1; node!=NULL; i--,node=node.Prev())
|
||||
printf("Element at "+(string)i);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,24 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| uLong.mq5 |
|
||||
//| Copyright 2018, MetaQuotes Software Corp. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2018, MetaQuotes Software Corp."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
struct DoubleValue{ double value;} dValue;
|
||||
struct ULongValue { ulong value; } lValue;
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
dValue.value=3.14159;
|
||||
lValue=(ULongValue)dValue;
|
||||
printf((string)lValue.value);
|
||||
dValue.value=3.14160;
|
||||
lValue=(ULongValue)dValue;
|
||||
printf((string)lValue.value);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,40 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Hashing.mq5 |
|
||||
//| Copyright 2018, MetaQuotes Software Corp. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2018, MetaQuotes Software Corp."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
printf("Hello world - "+(string)Adler32("Hello world"));
|
||||
printf("Hello world! - "+(string)Adler32("Hello world!"));
|
||||
printf("Peace - "+(string)Adler32("Peace"));
|
||||
printf("MetaTrader - "+(string)Adler32("MetaTrader"));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//+------------------------------------------------------------------+
|
||||
//| Accepts a string and returns hashing 32-bit value, |
|
||||
//| which characterizes this string. |
|
||||
//+------------------------------------------------------------------+
|
||||
uint Adler32(string line)
|
||||
{
|
||||
ulong s1 = 1;
|
||||
ulong s2 = 0;
|
||||
uint buflength=StringLen(line);
|
||||
uchar char_array[];
|
||||
ArrayResize(char_array,buflength,0);
|
||||
StringToCharArray(line,char_array,0,-1,CP_ACP);
|
||||
for(uint n=0; n<buflength; n++)
|
||||
{
|
||||
s1 = (s1 + char_array[n]) % 65521;
|
||||
s2 = (s2 + s1) % 65521;
|
||||
}
|
||||
return ((s2 << 16) + s1);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,95 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| An associative array or a dictionary storing elements as |
|
||||
//| <key - value>, where a key may be represented by any base type, |
|
||||
//| and a value may be represented be a CObject type object. |
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
#include <Object.mqh>
|
||||
#include <Arrays\List.mqh>
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
class CDictionary
|
||||
{
|
||||
private:
|
||||
CList *m_array[]; // List array.
|
||||
template<typename T>
|
||||
bool AddObject(T key,CObject *value);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Adds a CObject type element with a T key to the dictionary |
|
||||
//| INPUT PARAMETRS: |
|
||||
//| T key - any base type, for instance int, double or string. |
|
||||
//| value - a class that derives from CObject. |
|
||||
//| RETURNS: |
|
||||
//| true, if the element has been added, otherwise - false. |
|
||||
//+------------------------------------------------------------------+
|
||||
template<typename T>
|
||||
bool CDictionary::AddObject(T key,CObject *value)
|
||||
{
|
||||
if(ContainsKey(key))
|
||||
return false;
|
||||
if(m_total==m_array_size)
|
||||
{
|
||||
printf("Resize"+m_total);
|
||||
Resize();
|
||||
}
|
||||
if(CheckPointer(m_array[m_index])==POINTER_INVALID)
|
||||
{
|
||||
m_array[m_index]=new CList();
|
||||
m_array[m_index].FreeMode(m_free_mode);
|
||||
}
|
||||
KeyValuePair *kv=new KeyValuePair(key,m_hash,value);
|
||||
if(m_array[m_index].Add(kv)!=-1)
|
||||
m_total++;
|
||||
if(CheckPointer(m_current_kvp)==POINTER_INVALID)
|
||||
{
|
||||
m_first_kvp=kv;
|
||||
m_current_kvp=kv;
|
||||
m_last_kvp=kv;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_current_kvp.next_kvp=kv;
|
||||
kv.prev_kvp=m_current_kvp;
|
||||
m_current_kvp=kv;
|
||||
m_last_kvp=kv;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
//+------------------------------------------------------------------+
|
||||
//| Dictionary.mqh |
|
||||
//| Copyright 2018, MetaQuotes Software Corp. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2018, MetaQuotes Software Corp."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
class CDictionary
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
CDictionary();
|
||||
~CDictionary();
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
CDictionary::CDictionary()
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
CDictionary::~CDictionary()
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
*/
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,22 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Test.mq5 |
|
||||
//| Copyright 2018, MetaQuotes Software Corp. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2018, MetaQuotes Software Corp."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
|
||||
#include "Dictionary.mqh"
|
||||
CDictionary dictionary;
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
CObject *obj=new CObject();
|
||||
dictionary.AddObject(124, obj);
|
||||
dictionary.AddObject("simple object", obj);
|
||||
dictionary.AddObject(PERIOD_D1, obj);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Test.mq5 |
|
||||
//| Copyright 2018, MetaQuotes Software Corp. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2018, MetaQuotes Software Corp."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
#include "Dictionary.mqh"
|
||||
CDictionary dict;
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
if(dict.ContainsKey("Car"))
|
||||
printf("Car always exists.");
|
||||
else
|
||||
dict.AddObject("Car",new CCar());
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Test.mq5 |
|
||||
//| Copyright 2018, MetaQuotes Software Corp. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2018, MetaQuotes Software Corp."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
|
||||
#include "Dictionary.mqh"
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
class CStringValue : public CObject
|
||||
{
|
||||
public:
|
||||
string Value;
|
||||
CStringValue();
|
||||
CStringValue(string value){Value=value;}
|
||||
};
|
||||
CDictionary dict;
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
dict.AddObject("CNumber", new CStringValue("CNumber"));
|
||||
dict.AddObject("CShip", new CStringValue("CShip"));
|
||||
dict.AddObject("CWeather", new CStringValue("CWeather"));
|
||||
dict.AddObject("CHuman", new CStringValue("CHuman"));
|
||||
dict.AddObject("CExpert", new CStringValue("CExpert"));
|
||||
dict.AddObject("CCar", new CStringValue("CCar"));
|
||||
CStringValue *currString=dict.GetFirstNode();
|
||||
for(int i=1; currString!=NULL; i++)
|
||||
{
|
||||
printf((string)i+":\t"+currString.Value);
|
||||
currString=dict.GetNextNode();
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Test.mq5 |
|
||||
//| Copyright 2018, MetaQuotes Software Corp. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2018, MetaQuotes Software Corp."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
|
||||
#include "Dictionary.mqh"
|
||||
|
||||
CDictionary dict;
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Reference in New Issue
Block a user