Base.h

#pragma once
#include<iostream>
#include<string>
#include<vector>



class FSMBase {
public:
	std::string StateName;
	std::string EventName;
	std::vector<FSMBase*> subitem;
	FSMBase* parent;

	FSMBase();
	virtual void Add(FSMBase* b1);
	
	~FSMBase();
};


FSMBase.cpp
#include<iostream>
#include<string>
#include<vector>
#include<rapidjson/document.h>
#include<rapidjson/filereadstream.h>
#include<fstream> 
#include "FSMBase.h"
#include "FSMBuilder.h"
#include "MethodHolder.h"
#include "InvokeFunction.h"
#include "FixedPolygonTool.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);
		//b1->getdata();
	
	}

	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);


	MethodHolder* holder = MethodHolder::GetInstance();

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

	FixedPolygonTool polygonPtr;
	int frameNumber = 1;
	ToolsType toolType = ToolsType::Polygon;
	holder->RegisterMethod("getToolState", [&](int frameNumber, ToolsType toolType) -> ToolState {return polygonPtr.getToolState(frameNumber, toolType); });
	ToolState state=holder->InvokeToolState("getToolState", 1, toolType);

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

MethodHolder.h

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

class MethodHolder
{

public:

    typedef void(*VoidFunctionPtr)();
    typedef ToolState(*ToolstatefunctionPtr)(int,ToolsType);


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

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

    std::map<std::string, VoidFunctionPtr>VoidMethodMap;
    std::map<std::string, ToolstatefunctionPtr>ToolstateMethodMap;
};

MethodHolder.cpp

#include "MethodHolder.h"


MethodHolder* MethodHolder::instance = nullptr;

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

ToolState MethodHolder::InvokeToolState(const std::string& methodName, int frameNumber, ToolsType toolType)
{
    auto it = ToolstateMethodMap.find(methodName);
    if (it != ToolstateMethodMap.end()) {
        return it->second(frameNumber, toolType);
    }
    else {
        std::cout << "Method not found: " << methodName << std::endl;
    }
}

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

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

InvokeFunction.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;
}

FixedPolygonTool.h

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



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;
}


I am getting the below error.Provide solution for that

Severity	Code	Description	Project	File	Line	Suppression State	Details
Error	C2665	'MethodHolder::RegisterMethod': no overloaded function could convert all the argument types	FsmImplementation	C:\Users\1038586\Downloads\FsmImplementation11142024\FsmImplementation\FsmImplementation\FSMBase.cpp	81		
Error (active)	E0304	no instance of overloaded function "MethodHolder::RegisterMethod" matches the argument list	FsmImplementation	C:\Users\1038586\Downloads\FsmImplementation11142024\FsmImplementation\FsmImplementation\FSMBase.cpp	74		
Error (active)	E0304	no instance of overloaded function "MethodHolder::RegisterMethod" matches the argument list	FsmImplementation	C:\Users\1038586\Downloads\FsmImplementation11142024\FsmImplementation\FsmImplementation\FSMBase.cpp	81		
Error	C2665	'MethodHolder::RegisterMethod': no overloaded function could convert all the argument types	FsmImplementation	C:\Users\1038586\Downloads\FsmImplementation11142024\FsmImplementation\FsmImplementation\FSMBase.cpp	74		
Warning	C4715	'MethodHolder::InvokeToolState': not all control paths return a value	FsmImplementation	C:\Users\1038586\Downloads\FsmImplementation11142024\FsmImplementation\FsmImplementation\MethodHolder.cpp	26