53 lines
2.1 KiB
MQL5
53 lines
2.1 KiB
MQL5
//+------------------------------------------------------------------+
| |||
//| RegService.mqh |
| |||
//| Copyright 2026, Niquel Mendoza |
| |||
//| https://www.mql5.com |
| |||
//+------------------------------------------------------------------+
| |||
#property copyright "Copyright 2026, Niquel Mendoza"
| |||
#property link "https://www.mql5.com"
| |||
#property strict
| |||
| |||
#ifndef MQLARTICLES_UTILS_REGSERVISE_MQH
| |||
#define MQLARTICLES_UTILS_REGSERVISE_MQH
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| |
| |||
//+------------------------------------------------------------------+
| |||
#include <TSN/GCol/GenericHashes.mqh>
| |||
#include <TSN/GCol/HashMap.mqh>
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| |
| |||
//+------------------------------------------------------------------+
| |||
namespace TSN
| |||
{
| |||
//+------------------------------------------------------------------+
| |||
//| |
| |||
//+------------------------------------------------------------------+
| |||
template <typename TObject>
| |||
class CRegService
| |||
{
| |||
public:
| |||
CRegService(void) {}
| |||
~CRegService(void) {}
| |||
//---
| |||
static CHashMapFastP(ulong, TObject*, _fibbo) s_values;
| |||
static TObject* s_current_value;
| |||
| |||
//---
| |||
static bool SelectCurrentInstance(const ulong id)
| |||
{
| |||
const int idx = s_values.Find(id);
| |||
if(idx < 0)
| |||
return false;
| |||
s_current_value = s_values.m_table[idx].value;
| |||
return true;
| |||
}
| |||
};
| |||
//---
| |||
template <typename TObject> CHashMapFastP(ulong, TObject*, _fibbo) CRegService::s_values;
| |||
template <typename TObject> TObject* CRegService::s_current_value = NULL;
| |||
}
| |||
//+------------------------------------------------------------------+
| |||
#endif // MQLARTICLES_UTILS_REGSERVISE_MQH
| |||
//+------------------------------------------------------------------+
|