/********************************************************************
* CONFIDENTIAL - All source code is the propriety and confidential  *
* information of David Sorber.                                      *
*                                                                   *
* Copyright 2024 David Sorber                                       *
* Unpublished -- all rights reserved under the copyright laws       *
* of the United States.                                             *
********************************************************************/

#ifndef __COPYTOOL_COPYMANAGEROPTIONS_H_
#define __COPYTOOL_COPYMANAGEROPTIONS_H_

#include <cstdint>
#include <map>
#include <string>

namespace DBS
{

class CopyManagerOptions
{
public:

    // Log option defaults
    static const bool DEFAULT_DISABLE_LOG{false};
    static const bool DEFAULT_LOG_TO_STDERR{true};
    static const int DEFAULT_LOG_LEVEL{3};
    static inline const std::string DEFAULT_LOG_FILE_PATH{"./copyfile.log"};


    static const uint32_t DEFAULT_FC_THRESHOLD{1000};
    static const uint32_t DEFAULT_NUM_COPY_THREADS{4};
    static const bool DEFAULT_COPY_TOPLEVEL{false};

    CopyManagerOptions(
        const std::string& srcPath,
        const std::string& destPath,
        bool disableLog,
        bool logToStderr,
        const std::string& logFilePath,
        int logLevel,
        uint32_t flowCtrlThreshold,
        uint32_t numProcThreads,
        bool copyTopLevel);

    ~CopyManagerOptions();

    //--- Getters -------------------------------------------------------------
    inline const std::string& getSrcPath() const
    {
        return r_srcPath;
    }

    inline const std::string& getDestPath() const
    {
        return m_destPath;
    }

    inline bool getDisableLog() const
    {
        return m_disableLog;
    }

    inline bool getLogToStderr() const
    {
        return m_logToStderr;
    }

    inline int getLogLevel() const
    {
        return m_logLevel;
    }

    inline const std::string& getLogFilePath() const
    {
        return r_logFilePath;
    }

    inline uint32_t getFlowControlThreshold() const
    {
        return m_flowControlThreshold;
    }

    inline uint32_t getNumCopyThreads() const
    {
        return m_numCopyThreads;
    }

    inline bool getCopyTopLevel() const
    {
        return m_copyTopLevel;
    }

    //--- Setters -------------------------------------------------------------
    inline void setDestPath(const std::string& destPath)
    {
        m_destPath = destPath;
    }

    inline void setFlowControlThreshold(uint32_t threshold)
    {
        m_flowControlThreshold = threshold;
    }

private:

    // Fundamental options/settings
    const std::string& r_srcPath;       // source path; "copy from"
    std::string m_destPath;             // destination path; "copy to"

    // Logging related options
    bool m_disableLog;                  // Enable/disable the log
    bool m_logToStderr;                 // Write log messages to stderr instead of file
    const std::string& r_logFilePath;          // Path to log file
    int m_logLevel;                     // Log messages >= selected level will be output

    // Other options
    uint32_t m_flowControlThreshold;    // Max level of entry queue for flow control purposes
    uint32_t m_numCopyThreads;          // Number of copy threads to spawn
    bool m_copyTopLevel;                // Copy top level source dir to dest dir

};

} // namespace DBS


#endif //__COPYTOOL_COPYMANAGEROPTIONS_H_
