#ifndef monitorFollow_INCLUDED
	#define monitorFollow_INCLUDED

#include <bncs_script_helper.h>
#include <map>
#include "direct.h"
#include "tieline.h"

#ifdef WIN32
	#ifdef DOEXPORT_SCRIPT
		#define EXPORT_SCRIPT __declspec(dllexport) 
	#else
		#define EXPORT_SCRIPT __declspec(dllimport) 
	#endif
#else 
	#define EXPORT_SCRIPT
#endif
 
class monitorFollow : public bncs_script_helper
{
public:
	monitorFollow( bncs_client_callback * parent, const char* path );
	
	void init() ;
	
	virtual ~monitorFollow();

	void buttonCallback( buttonNotify *b );
	int revertiveCallback( revertiveNotify * r );
	void databaseCallback( revertiveNotify * r );
	bncs_string parentCallback( parentNotify *p );
	void timerCallback( int );
private:
	bool m_bEnableOnLoad;
	void setFollow();
	bncs_string m_sTally;
	bool m_bWaitingForPARKrevertive;
	void setTally(bncs_string s);
	void tally();

	//Option for new mon follow

	//This is a member function pointer so has to be written like this
	//void (monitorFollow::*follow)(int);
	//This is how to set it follow = &monitorFollow::followPackage;
	//This is how to call it (this->*follow)(2);


	

	void (monitorFollow::*follow)();
	//This is how to set it follow = &monitorFollow::followPackage;
	//This is how to call it (this->*follow)();

	void followDirect();
	void followPackageTieline();
	void followPackage();
	

	void setDestFollow(int iDestIndex);

	void (monitorFollow::*destFollow)();

	void destFollowRouted();
	void destFollowPackage();


	int m_intDestFollowDevice;
	int m_intDestFollowIndex;
	bool m_bDestFollow;




	int m_source;

	int m_intPackageRouterDevice;
	int m_intPackageRouterIndexDest;
	int m_intSourcePackageID;
	bncs_string m_sSourcePackageName;

	bool m_bPackagerInstance;


	bool m_bMonFollowReady;

	bool m_monFollowing;

	bncs_string m_instance;

	bool m_bPackageParked;

	//Assuming making an ass out of you and me
	//that there will only ever be 1 instance of a tieline per router per monitor, any thing else would seem stupid. If this is not the case Multimap should be used and some tweaks to revertive are necessary

	//These are all for the Tallying
	map<int,tieline> m_mTielines; // Stores device of router, index of tieline dest, index of source package related too, index of SDI under source package just incase

	direct m_direct; //There can only be one direct route. because of how the config is currently set
	tieline m_tieline;	//This is to store the tieline if we are supposed to do tieline monfollow


};


#endif // monitorFollow_INCLUDED