//---------------------------------------------------------------------------

#ifndef CDSLinkFH
#define CDSLinkFH
//---------------------------------------------------------------------------

#include <Classes.hpp>
#include <ADODB.hpp>
#include <DB.hpp>
#include "ITSLibF.h"
#include "ITSDbF.h"
#include "CDSLayerF.h"
#include "CDSObjectF.h"
//---------------------------------------------------------------------------

/*
*  LINK class
*/
class TItsLink
{
public:
    TItsLink();
    virtual ~TItsLink();
    void Clear();

private:
    bool    FModified;
    bool    FCompleted;

public:
    String  LINK_ID;
    String	F_NODE_ID;
    String	T_NODE_ID;
    String	ROAD_USE;
    String	LANES;
    String	ROAD_RANK;
    String	ROAD_TYPE;
    String	ROAD_NO;
    String	ROAD_NAME;
    String	MULTI_LINK;
    String	LINK_CONNECT;
    String	MAX_SPD;
    String	REST_VEH;
    String	REST_W;
    String	REST_H;
    String	LINK_LENG;
    String	RMRK;
    String	DEL_YN;
    String	DFLT_SPED;
    String	DFLT_SPED_USE_YN;
    String	SECT_GRAD_CD;
    String	AREA_CD;
    String  PARA_ID;

    String	REGN_YN;

    String  IFSC_ID;
    String  ROAD_ID;

    TCDSTraffic             *TRAF;
    TItsMap<int, TItsVrtx*>  Vrtxs;

    bool   IsVertex;
    String X_CRDN_ARR;
    String Y_CRDN_ARR;
    int    SPED;
    int    TRAF_GRAD;

protected:

public:
    __property bool   Modified  = {read = FModified};
    __property bool   Completed = {read = FCompleted, write = FCompleted};

    void InitTraffic();
};
//---------------------------------------------------------------------------

class TClctSystStts
{
public:
    TClctSystStts()  {};
    ~TClctSystStts() {};

private:

public:
    String CLCT_SYST_CD;
    String CLCT_SYST_NM;
    String PRCN_DT;

    int    CLCT_NUM;
    int    FLTR_NUM;
    int    FUSN_NUM;

    bool   IsCollected;
};
//---------------------------------------------------------------------------

/*
* Link Manager
*/
class TItsLinkManager
{
public:
    TItsLinkManager();
    virtual ~TItsLinkManager();

public:
    int                         FRegionPointCnt;
    String                      FRegionVertex;

    TItsMap<String, TItsLink*>       FLists;
    TItsMap<String, TClctSystStts*>  FClctSystStts;

public:
    bool LoadFromDb(TADOConnection *ADbConn=NULL);
    bool LoadVrtxFromDb(TADOConnection *ADbConn=NULL);
    bool LoadVrtxFromFile(TADOConnection *ADbConn=NULL);

    bool LoadRegionVertexFromDb(TADOConnection *ADbConn=NULL);

    void InitTraffic();
    bool LoadTraffic(TADOConnection *ADbConn=NULL);
    bool LoadClctSystStts(TADOConnection *ADbConn=NULL);
};
//---------------------------------------------------------------------------
extern TItsLinkManager *ItsLinkManager;
//---------------------------------------------------------------------------

#endif

