157 lines
4.9 KiB
MQL5
157 lines
4.9 KiB
MQL5
|
#ifndef LIB_MQLPLUS_BASE_OBJECT_NODE_MQH_INCLUDED
|
||
|
#define LIB_MQLPLUS_BASE_OBJECT_NODE_MQH_INCLUDED
|
||
|
#property version "1.0";
|
||
|
/**********************************************************************************
|
||
|
* Copyright (C) 2010-2022 Dominik Egert <info@freie-netze.de>
|
||
|
*
|
||
|
* This file is the objects 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.0
|
||
|
* State: production
|
||
|
*
|
||
|
* File information
|
||
|
* ================
|
||
|
*
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
#ifdef DBG_MSG_TRACE_FILE_LOADER
|
||
|
DBG_MSG_TRACE_FILE_LOADER;
|
||
|
|
||
|
#endif
|
||
|
|
||
|
|
||
|
|
||
|
/*********************************************************************************************************************************************************/
|
||
|
/* */
|
||
|
/* MQLplus data structures */
|
||
|
/* */
|
||
|
/*********************************************************************************************************************************************************/
|
||
|
|
||
|
|
||
|
///////////////////////////////////////
|
||
|
//
|
||
|
// Object Node
|
||
|
//
|
||
|
|
||
|
// Base object
|
||
|
|
||
|
template <typename USER_DATA, typename NODE_TYPE>
|
||
|
class _object_node
|
||
|
{
|
||
|
public:
|
||
|
// Local storage
|
||
|
|
||
|
NODE_TYPE* _left;
|
||
|
NODE_TYPE* _right;
|
||
|
USER_DATA this_obj;
|
||
|
|
||
|
public:
|
||
|
// Constructors / Destructor
|
||
|
|
||
|
// Default constructor
|
||
|
_object_node() :
|
||
|
_left (NULL),
|
||
|
_right (NULL)
|
||
|
{ };
|
||
|
|
||
|
// Copy constructor
|
||
|
_object_node(const NODE_TYPE& p_in)
|
||
|
{
|
||
|
_left = p_in._left;
|
||
|
_right = p_in._right;
|
||
|
};
|
||
|
|
||
|
// Destructor
|
||
|
~_object_node()
|
||
|
{ };
|
||
|
|
||
|
|
||
|
protected:
|
||
|
// Element selector functions
|
||
|
|
||
|
// First element
|
||
|
NODE_TYPE* top()
|
||
|
{ return(left()); }
|
||
|
|
||
|
NODE_TYPE* left()
|
||
|
{
|
||
|
NODE_TYPE* ptr_obj = ::GetPointer(this);
|
||
|
while( (ptr_obj._left != NULL)
|
||
|
&& (!_StopFlag) )
|
||
|
{ ptr_obj = ptr_obj._left; }
|
||
|
|
||
|
// Return
|
||
|
return(ptr_obj);
|
||
|
}
|
||
|
|
||
|
// Last element
|
||
|
NODE_TYPE* bottom()
|
||
|
{ return(right()); }
|
||
|
|
||
|
NODE_TYPE* right()
|
||
|
{
|
||
|
NODE_TYPE* ptr_obj = ::GetPointer(this);
|
||
|
while( (ptr_obj._right != NULL)
|
||
|
&& (!_StopFlag) )
|
||
|
{ ptr_obj = ptr_obj._right; }
|
||
|
|
||
|
// Return
|
||
|
return(ptr_obj);
|
||
|
}
|
||
|
|
||
|
|
||
|
public:
|
||
|
// Element operations
|
||
|
|
||
|
// Get size
|
||
|
const int size()
|
||
|
{
|
||
|
int count = NULL;
|
||
|
NODE_TYPE* ptr_obj = left();
|
||
|
while( (ptr_obj != NULL)
|
||
|
&& (!_StopFlag) )
|
||
|
{
|
||
|
ptr_obj = ptr_obj._right;
|
||
|
count++;
|
||
|
}
|
||
|
|
||
|
// Return
|
||
|
return(count);
|
||
|
};
|
||
|
|
||
|
|
||
|
// Assignment operator
|
||
|
|
||
|
// Assignment operator
|
||
|
void operator=(const NODE_TYPE& p_in)
|
||
|
{
|
||
|
_left = p_in._left;
|
||
|
_right = p_in._right;
|
||
|
};
|
||
|
|
||
|
void operator=(NODE_TYPE* p_in)
|
||
|
{
|
||
|
_left = p_in._left;
|
||
|
_right = p_in._right;
|
||
|
};
|
||
|
|
||
|
// Value assignment
|
||
|
USER_DATA operator=(USER_DATA& p_in)
|
||
|
{
|
||
|
this_obj = p_in;
|
||
|
return(this_obj);
|
||
|
};
|
||
|
};
|
||
|
|
||
|
|
||
|
//
|
||
|
// END MQL data structures */
|
||
|
//*********************************************************************************************************************************************************/
|
||
|
#endif // LIB_MQLPLUS_BASE_OBJECT_NODE_MQH_INCLUDED
|