FixedPolygonTool.h

#pragma once
#include <vector>
#include <gdiplus.h>
#include <gdiplusinit.h>
#include <map>


enum class ToolState {
	Active,
	Completed,
	FinalPolygon
};

enum class ToolsType
{
	Polygon,
	Line,
	Fixed
};

class FixedPolygonTool
{

	ToolState getToolState(int frameNumber, ToolsType toolType = ToolsType::Polygon);
};

struct PolygonParams
{
	ToolState toolState;
	std::vector<std::pair<Gdiplus::Point, Gdiplus::Point>> PolygonToolStartEndPoint;
};
std::map<int, PolygonParams> m_polygonParams_map;

FixedPolygonTool.cpp

#include "FixedPolygonTool.h"

ToolState FixedPolygonTool::getToolState(int frameNumber, ToolsType toolType)
{
	return m_polygonParams_map[frameNumber].toolState;
}

InvokeFunctions.cpp




#include <iostream>
#include "InvokeFunction.h"




void InvokeFunction::EnterSVelPointEdit()
{
	std::cout << "EnterSVelPointEdit method invoked" << std::endl;
}

void InvokeFunction::EnterEVelPointEdit()
{
	std::cout << "EnterEVelPointEdit method invoked" << std::endl;
}
void InvokeFunction::EncoderInc()
{
	std::cout << "EncoderInc method called" << std::endl;
}


MethodHolder.h

#pragma once
#include <iostream>
#include <map>
#include <string>
#include <functional>
#include "InvokeFunction.h"
#include "FixedPolygonTool.h"



class MethodHolder
{

public:
    typedef void(*FunctionPointer)();
	
   //using MethodPointer = std::function<void(int,ToolsType)>;

    static MethodHolder* GetInstance() {
        if (!instance) {
            instance = new MethodHolder();
        }     
        return instance;
    }
    //void InvokeMethod(const std::string& methodName);
    void InvokeMethod(const std::string& methodName,int frameNumber, ToolsType toolType);
    void RegisterMethod(const std::string& methodName, FunctionPointer methodPtr);

private:
    MethodHolder() {}
    static MethodHolder* instance;
    MethodHolder(const MethodHolder&) = delete;
    MethodHolder& operator=(const MethodHolder&) = delete; 

    std::map<std::string, FunctionPointer> MethodMap;
};

MethodHolder.cpp

#include "MethodHolder.h"

MethodHolder* MethodHolder::instance = nullptr;

void MethodHolder::InvokeMethod(const std::string& methodName)
{
auto it = MethodMap.find(methodName);
if (it != MethodMap.end()) {
it->second();
}
else {
std::cout << "Method not found: " << methodName << std::endl;
}
}

void MethodHolder::RegisterMethod(const std::string& methodName, MethodPointer methodPtr)
{
MethodMap[methodName] = methodPtr;
}

FSMBase.cpp

#include
#include
#include
#include<rapidjson/document.h>
#include<rapidjson/filereadstream.h>
#include
#include "FSMBase.h"
#include "FSMBuilder.h"
#include "MethodHolder.h"
#include "InvokeFunction.h"

using namespace std;
using namespace rapidjson;


    FSMBase::FSMBase()
    {
            std::cout << "default constructor called" << std::endl;
    }


    void FSMBase::Add(FSMBase* b1)
    {
            subitem.push_back(b1);
    
    }

    FSMBase::~FSMBase()
    {
            std::cout << " destructor called" << std::endl;
    }
int main()
{


    Document doc;
    ifstream file("FSMImplementationJSON.json");
    if (!file.is_open()) {
            cerr << "Could not open file: FSMImplementationJSON.json" << endl;
            return 1;
    }

    string json((istreambuf_iterator<char>(file)),
            istreambuf_iterator<char>());

    doc.Parse(json.c_str());

    if (doc.HasParseError()) {
            cerr << "Error parsing JSON: "
                    << doc.GetParseError() << endl;
            return 1;
    }
     
    PrimitiveTool* prTool1 = new PrimitiveTool();
    FSMBuilder::createStatesFromJson(prTool1, doc);
    std::cout <<" " << std::endl;

    prTool1->SetInitialState("StartToolState");

    Event* event1 = new Event("CompleteEvent", "ChangeState", "WaitForAccept");     
    prTool1->InEvent(event1);

    Event* event2 = new Event("CompleteEvent", "ChangeState", "AcceptedState");
    prTool1->InEvent(event2);


    InvokeFunction invokePtr;
    MethodHolder::GetInstance()->RegisterMethod("EnterSVelPointEdit", [&invokePtr]() {invokePtr.EnterSVelPointEdit(); });
    Event* event3 = new Event("ClickStartPoint", "InvokeMethod", "EnterSVelPointEdit");
    prTool1->InEvent(event3);


    Event* event4 = new Event("getToolState", "InvokeMethod", "getToolState");
    prTool1->InEvent(event4);

    delete event1;
    delete event2;
    delete event3;
    delete prTool1;  
    return 0;
}


in the MethodHolder class i want to register method  having differrent parameters in differrent classes eg :ToolState getToolState(int frameNumber, ToolsType toolType = ToolsType::Polygon) of
and void EnterSVelPointEdit() of seperate classes FixedPolygonTool class and InvokeFunction class.After registering the methods to method map and need to invoke method in the classes while triggering event 
provide the necessary codes