//+------------------------------------------------------------------+ //| Actions.mqh | //| Copyright 2026, MasterOfPuppets | //| https://forge.mql5.io/masterofpuppets/mql5 | //+------------------------------------------------------------------+ #ifndef MASTER_OF_PUPPETS_LIB_ACTIONS_MQH #define MASTER_OF_PUPPETS_LIB_ACTIONS_MQH #include #property copyright "Copyright 2026, MasterOfPuppets" #property link "https://forge.mql5.io/masterofpuppets/mql5" //+------------------------------------------------------------------+ //| Actions class | //+------------------------------------------------------------------+ template class Actions { private: CHashMap m_actions; int m_actionKeys[]; string m_actionNames[]; public: void AddAction(const ActionKey actionKey, const TActionEnum action) { m_actions.Add(actionKey, action); ArrayResize(m_actionKeys, m_actionKeys.Size() + 1); m_actionKeys[m_actionKeys.Size() - 1] = actionKey; ArrayResize(m_actionNames, m_actionNames.Size() + 1); m_actionNames[m_actionNames.Size() - 1] = EnumToString(action); } void Clear() { m_actions.Clear(); ArrayFree(m_actionKeys); ArrayFree(m_actionNames); } int GetAction(const long actionKey) { int action; m_actions.TryGetValue(actionKey, action); return action; } void GetActionKeys(int &actionKeys[]) { ArrayCopy(actionKeys, m_actionKeys); } void GetActionNames(string &actionNames[]) { ArrayCopy(actionNames, m_actionNames); } string Usage() { string usage; for(uint i = 0; i < m_actionKeys.Size(); i++) { usage += StringFormat("[%c] %s\n", m_actionKeys[i], m_actionNames[i]); } return usage; } }; #endif //+------------------------------------------------------------------+