// TimeEquipSubState.h: interface for the CTimeEquipSubState class.
//
//////////////////////////////////////////////////////////////////////

#pragma once

#include <string>

#include "DllDefines.h"
#include "dbini.h"

class MCCTRDLLCLASS CTimeEquipSubState
{
public:
    //  default constructor
    CTimeEquipSubState(std::string csSectionName = "", std::string csKeyName = "",
        std::string csFileName = RUNTIME_INI);

    //  default destructor
    virtual ~CTimeEquipSubState();

    //  Start timer
    void Start();

    //  Stop timer
    void Stop();

    //  Reset timer to 0
    void Reset();

    //  Get timer time
    LONGLONG GetTime();

    //  set timer time
    void SetTime(LONGLONG);

    //  Add timer time
    void AddTime(LONGLONG lTimeSpan);

    //  check if timer has been started
    bool IsTimerStarted();

    //  record debugging info to file
    void WriteTimeSpanToFile();

    //  copy current time span to previous time span
    void CopyCurTimeSpanToPrev();

    //  check time span has changed
    bool IsTimeSpanChanged();

    //  Set Section Name
    bool SetSectionName(const char* ccSectionName);

    //  Set KeyName
    bool SetKeyName(const char* ccKeyName);

    //  Get Start Time
    LONGLONG GetStartTime();

    enum
    {
        RESET_TIMER,
        START_TIMER,
        STOP_TIMER,
    };

private:
    //  flag to detemine whether the timer has started
    bool m_bTimerStarted;

    //  attribute to store start time
    LONGLONG m_lStartTime;

    //  attribute to store timer time span
    //  time span = startTime - stop time
    LONGLONG m_lTimeSpan;

    //  previous time span
    LONGLONG m_lPrevTimeSpan;

    //  Section name of the debug info file
    char m_csSectionName[100];

    //  Key name of the debug info file
    char m_csKeyName[100];

    //  File name of the debug info file
    char m_csFileName[100];
};
