#ifndef __router_h
#define __router_h


#include "ConfigObject.h"
#include "defs.h"

class SERVICE_EXPORTED_CLASS CX25Router : public CConfigObject
{
	DECLARE_DYNAMIC(CX25Router)
// Attributes
protected:
// alias map, where the line's alias is the map key
//	CMap<CString, const CString&, CAlias, const CAlias&> m_AliasMap;
	CAliasMap m_AliasMap;
// array of route's
	CRoutingTable m_RoutingTable;
// path to router Registry data	
	CString m_RouterPath;
// router Registry data
//	CRegDataKey m_RouterKey;

	int m_nNumRasPorts;
#ifdef NT5
private:
	CString m_strInstance;
#endif

public :
	CX25Router(HKEY const hKeyRoot, CString const strRegPath, CConfigObject const * const pParent);
	virtual ~CX25Router();
	virtual BOOL GetParameters(void);
	virtual BOOL SetParameters(void);
	virtual BOOL RemoveParameters(BOOL fRemoveKey = FALSE);

	virtual BOOL AddWizardPages(CConfigWizSheet * const pSheet){return TRUE;}
	virtual BOOL NextWizardPage(int const nState){return TRUE;}

	virtual BOOL AddChild(void){ASSERT(FALSE);return FALSE;}
	virtual BOOL DoProperties(void);



	CRoute *GetRoute(int i) { return &m_RoutingTable[i]; };
	INT_PTR CountRoutes() const { return m_RoutingTable.GetSize(); };

		// given an realname return the alias
	CString FindByRealName(const CString&, const CString&) const;
	
	// given an alias return the realname
	void FindByAlias(const CString&, CString&, CString&) const;
	BOOL FindByAlias(const CString&) const;

	BOOL IsAliasMapEmpty() { return m_AliasMap.IsEmpty(); };

	DWORD GetTotalRASPorts() const;

// Operations
/*
	void SetPath(const CString& Path)
		{ m_RouterPath = Path + _T('\\') + GetServiceName(); };
*/

	BOOL CheckConfig();

	
	BOOL ValidateRouteAddress(const CString&);

	BOOL AddRoute(const CString&, const CString&);
	void RemoveRoute(int);
	BOOL MoveUp(int);
	BOOL MoveDown(int);

	int FindHiddenRoutes();

	void AddAlias(const CString&, const CString&, const CString&, int = -1);
	void ChangeAlias(const CString&, const CString&);
	BOOL SetAliasNumPorts(const CString&, DWORD);

	void RemoveRoutingAlias(const CString&, const CString&, BOOL = TRUE);

	BOOL AddRoute(int, int *);
	BOOL ChangeRoute(int, int *);
	BOOL RemoveRoute(int, int *);
private:
	void CopyMap(const CAliasMap& src,CAliasMap& dst);


};


#endif