MQLplus/lib_structures/lib_scale_array.mqh
super.admin 466f9ca5c5 convert
2025-05-30 16:09:52 +02:00

199 lines
5.7 KiB
MQL5

#ifndef LIB_MQLPLUS_SCALE_ARRAY_TEMPLATES_MQH_INCLUDED
#define LIB_MQLPLUS_SCALE_ARRAY_TEMPLATES_MQH_INCLUDED
#property version "1.2";
/**********************************************************************************
* Copyright (C) 2010-2022 Dominik Egert <info@freie-netze.de>
*
* This file is the scale array include file.
*
* MQLplus, including this file may not be copied and/or distributed
* without explecit permit by the author.
* Author Dominik Egert / Freie Netze UG.
**********************************************************************************
*
* Version: 1.2
* State: production
*
* File information
* ================
*
*
*
*
*/
#ifdef DBG_MSG_TRACE_FILE_LOADER
DBG_MSG_TRACE_FILE_LOADER;
#endif
///////////////////////////////
//
// Include mt5api Array
//
#include "base/lib_base_scale_array.mqh"
/*********************************************************************************************************************************************************/
/* */
/* MQLplus data structures */
/* */
/*********************************************************************************************************************************************************/
///////////////////////////////////////
//
// Dynamic scale array simple type
//
template <typename T>
class scale_array : public _generic_scale_array<scale_array, T>
{
public:
// Default constructor
scale_array(const bool dnd = false)
{ value = NULL; };
// Element function
const T append(T p_in)
{ return(_base_scale_array<scale_array, T>::append(p_in)); }
const T prepend(T p_in)
{ return(_base_scale_array<scale_array, T>::prepend(p_in)); }
const T remove()
{
_base_scale_array<scale_array, T>::remove_dim();
T tmp = value;
value = (T)NULL;
return(tmp);
};
// Assignment operator
const T operator=(const T p_in)
{
value = p_in;
return(value);
};
};
///////////////////////////////////////
//
// Dynamic scale array struct type
//
template <typename T>
class struct_scale_array : public _generic_scale_array<struct_scale_array, T>
{
public:
// Default constructor
struct_scale_array(const bool dnd = false)
{ };
// Assignment operator
const T operator=(const T& p_in)
{
value = p_in;
return(value);
};
};
///////////////////////////////////////
//
// Dynamic scale array pointer type
//
template <typename T>
class ptr_scale_array : public _generic_scale_array<ptr_scale_array, T*>
{
// Local storage
bool do_not_destroy;
public:
// Default constructor
ptr_scale_array() :
do_not_destroy (false)
{ value = NULL; };
// Custom constructor
ptr_scale_array(const bool _do_not_destroy) :
do_not_destroy (_do_not_destroy)
{ value = NULL; };
// Destructor
~ptr_scale_array()
{ if((!do_not_destroy) && (value != NULL)) { delete(value); } };
// Buffer functions
const bool dnd(const bool _do_not_destroy = true)
{
do_not_destroy |= _do_not_destroy;
return(do_not_destroy);
};
// Element function
T* append(T* p_in)
{ return(_base_scale_array<ptr_scale_array, T*>::append(p_in)); }
T* prepend(T* p_in)
{ return(_base_scale_array<ptr_scale_array, T*>::prepend(p_in)); }
T* remove()
{
_base_scale_array<ptr_scale_array, T*>::remove_dim();
T* tmp = value;
if(!do_not_destroy)
{ delete(value); }
value = (T*)NULL;
return(tmp);
};
// Assignment operator
T* operator=(const T& p_in)
{
value = new T(p_in);
return(value);
};
T* operator=(T* p_in)
{
value = p_in;
return(value);
};
};
//
// END MQL data structures */
//*********************************************************************************************************************************************************/
#endif // LIB_MQLPLUS_SCALE_ARRAY_TEMPLATES_MQH_INCLUDED