Project

General

Profile

Download (4.15 KB) Statistics
| Branch: | Revision:
/********************************************************************
* 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_ENABLE_LOG{false};
static const bool DEFAULT_LOG_TO_STDERR{false};
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};

static const bool DEFAULT_PRESERVE_PERMS{false};
static const bool DEFAULT_PRESERVE_OWNER{false};
static const bool DEFAULT_PRESERVE_GROUP{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,
bool preservePerms,
bool preserveOwner,
bool preserveGroup);

~CopyManagerOptions();

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

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

inline bool getEnableLog() const
{
return m_enableLog;
}

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;
}

inline bool getPreservePerms() const
{
return m_preservePerms;
}

inline bool getPreserveOwner() const
{
return m_preserveOwner;
}

inline bool getPreserveGroup() const
{
return m_preserveGroup;
}

//--- 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_enableLog; // 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

bool m_preservePerms; // Preserve directory/file permissions
bool m_preserveOwner; // Preserve directory/file owner
bool m_preserveGroup; // Preserve directory/file group

};

} // namespace DBS


#endif //__COPYTOOL_COPYMANAGEROPTIONS_H_
(4-4/9)