ewmscp  ..
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
outputHandler::base Class Referenceabstract

#include <outputHandler.h>

Inheritance diagram for outputHandler::base:
[legend]
Collaboration diagram for outputHandler::base:
[legend]

Classes

class  factoryClass
 factory class to create outputHandler::base* objects More...
 
class  factoryTemplate
 template for factoryClass-derived factories More...
 
class  writer
 

Public Types

enum  renameRetvalType { renameRetvalType::ok, renameRetvalType::fileChanged, renameRetvalType::fileVanished, renameRetvalType::cantHappen }
 

Public Member Functions

 ~base () override=default
 
virtual std::unique_ptr< writernewWriter (const std::string &path, bool mightAppend, size_t sourceSize, size_t readBlockSize, copyRequest::stateType &state, bool noWrite, std::unique_ptr< ioHandle::attrDataType > attrData, std::unique_ptr< acl::list > aclData)=0
 
virtual std::unique_ptr< writernewTmpWriter (std::string &path, size_t sourceSize, bool noWrite, std::unique_ptr< ioHandle::attrDataType > attrData, std::unique_ptr< acl::list > aclData)
 
virtual void ensureParentDirs (const std::string &path, const std::string &srcPath, inputHandler::base *InputHandler)=0
 
virtual void remove (const std::string &path, copyRequest::stateType &state)=0
 
virtual bool renameSimple (const std::string &fromPath, const std::string &toPath)=0
 
virtual void createSymlink (const std::vector< char > &, const std::string &, uid_t, gid_t)
 
virtual renameRetvalType rename (const std::string &fromPath, const std::unique_ptr< const genericStat > &readInitialStat, const std::string &toPath, copyRequest::stateType &state)=0
 
virtual void doAttributePreservations (const std::string &, const genericStat &)
 
virtual size_t getMaxNameLength (const std::string &dirPath)
 
template<class C >
void shortenNameToMax (const std::string &path, C &pathBuf, const std::string &suffix)
 
- Public Member Functions inherited from pathHandler
virtual ~pathHandler ()=default
 
virtual bool pathExists (const std::string &path)=0
 
virtual std::unique_ptr< const genericStatgetStat (const std::string &path, bool followLink=true)=0
 
virtual std::string getXattr (const std::string &, const std::string &)
 

Static Public Member Functions

static basenewHandler (const std::string &name)
 
template<class T >
static void addAllowedNamesToOption (T &option)
 

Protected Member Functions

 base ()=default
 

Static Protected Member Functions

static std::map< std::string, factoryClass * > & getFactoryMap ()
 

Detailed Description

Definition at line 17 of file outputHandler.h.

Member Enumeration Documentation

◆ renameRetvalType

Enumerator
ok 
fileChanged 
fileVanished 
cantHappen 

Definition at line 106 of file outputHandler.h.

106  {
107  ok,
108  fileChanged,
109  fileVanished,
110  cantHappen
111  };

Constructor & Destructor Documentation

◆ base()

outputHandler::base::base ( )
protecteddefault

◆ ~base()

outputHandler::base::~base ( )
overridedefault

Member Function Documentation

◆ addAllowedNamesToOption()

template<class T >
static void outputHandler::base::addAllowedNamesToOption ( T &  option)
inlinestatic

Definition at line 87 of file outputHandler.h.

87  {
88  for (const auto& item : getFactoryMap()) {
89  option.fAddToRange(item.first);
90  }
91  };

References getFactoryMap().

Here is the call graph for this function:

◆ createSymlink()

virtual void outputHandler::base::createSymlink ( const std::vector< char > &  ,
const std::string &  ,
uid_t  ,
gid_t   
)
inlinevirtual

Reimplemented in outputHandler::daosFs, outputHandler::posixFile, and outputHandler::libssh.

Definition at line 100 of file outputHandler.h.

102  {
103  throw unimplementedActionError("symlink creation not implemented");
104  }

◆ doAttributePreservations()

virtual void outputHandler::base::doAttributePreservations ( const std::string &  ,
const genericStat  
)
inlinevirtual

Reimplemented in outputHandler::daosFs, outputHandler::posixFile, and outputHandler::dcap.

Definition at line 117 of file outputHandler.h.

118  {
119  throw unimplementedActionError("setMtime not implemented");
120  }

◆ ensureParentDirs()

virtual void outputHandler::base::ensureParentDirs ( const std::string &  path,
const std::string &  srcPath,
inputHandler::base InputHandler 
)
pure virtual

◆ getFactoryMap()

static std::map<std::string, factoryClass*>& outputHandler::base::getFactoryMap ( )
inlinestaticprotected

Definition at line 22 of file outputHandler.h.

22  {
23  static std::remove_reference<decltype(getFactoryMap())>::type map;
24  return map;
25  }

Referenced by addAllowedNamesToOption(), outputHandler::base::factoryClass::factoryClass(), and newHandler().

Here is the caller graph for this function:

◆ getMaxNameLength()

size_t outputHandler::base::getMaxNameLength ( const std::string &  dirPath)
virtual

Reimplemented in outputHandler::daosFs, outputHandler::posixFile, and outputHandler::libssh.

Definition at line 34 of file outputHandler.cpp.

34  {
35 #ifdef NAME_MAX
36  return NAME_MAX
37 #else
38  return 255; // best guess for most cases
39 #endif
40  }

Referenced by shortenNameToMax().

Here is the caller graph for this function:

◆ newHandler()

static base* outputHandler::base::newHandler ( const std::string &  name)
inlinestatic

Definition at line 80 of file outputHandler.h.

80  {
81  auto it = getFactoryMap().find(name);
82  if (it != getFactoryMap().end()) {
83  return it->second->create();
84  }
85  throw std::runtime_error("no outputHandler factory called " + name);
86  }

References getFactoryMap().

Referenced by copyRequest::perThreadData::perThreadData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ newTmpWriter()

std::unique_ptr< base::writer > outputHandler::base::newTmpWriter ( std::string &  path,
size_t  sourceSize,
bool  noWrite,
std::unique_ptr< ioHandle::attrDataType attrData,
std::unique_ptr< acl::list aclData 
)
virtual

Reimplemented in outputHandler::Gpfs, outputHandler::daosFs, and outputHandler::posixFile.

Definition at line 9 of file outputHandler.cpp.

13  {
14  {
15  std::string suffix(".");
16  suffix += std::to_string(copyRequest::clock_type::now().time_since_epoch().count());
17  suffix += std::to_string(getpid());
18  suffix += ".tmp";
19  shortenNameToMax(path,path,suffix);
20  path += suffix;
21  }
23  return newWriter(path, false, sourceSize, 0, dummy, noWrite,
24  std::move(attrData),
25  std::move(aclData));
26  }

References newWriter(), and shortenNameToMax().

Here is the call graph for this function:

◆ newWriter()

virtual std::unique_ptr<writer> outputHandler::base::newWriter ( const std::string &  path,
bool  mightAppend,
size_t  sourceSize,
size_t  readBlockSize,
copyRequest::stateType state,
bool  noWrite,
std::unique_ptr< ioHandle::attrDataType attrData,
std::unique_ptr< acl::list aclData 
)
pure virtual

Implemented in outputHandler::Gpfs, outputHandler::dcap, outputHandler::daosFs, outputHandler::posixFile, outputHandler::libssh, and outputHandler::davix.

Referenced by newTmpWriter().

Here is the caller graph for this function:

◆ remove()

virtual void outputHandler::base::remove ( const std::string &  path,
copyRequest::stateType state 
)
pure virtual

Implemented in outputHandler::daosFs, outputHandler::posixFile, outputHandler::libssh, outputHandler::dcap, and outputHandler::davix.

Referenced by copyRequest::base::removeFileOrDirectory().

Here is the caller graph for this function:

◆ rename()

virtual renameRetvalType outputHandler::base::rename ( const std::string &  fromPath,
const std::unique_ptr< const genericStat > &  readInitialStat,
const std::string &  toPath,
copyRequest::stateType state 
)
pure virtual

◆ renameSimple()

virtual bool outputHandler::base::renameSimple ( const std::string &  fromPath,
const std::string &  toPath 
)
pure virtual

◆ shortenNameToMax()

template<class C >
void outputHandler::base::shortenNameToMax ( const std::string &  path,
C &  pathBuf,
const std::string &  suffix 
)
inline

Definition at line 122 of file outputHandler.h.

124  {
125  auto lastSlash = path.find_last_of('/');
126  std::string dirPath;
127  size_t fileNameLength;
128  if (lastSlash != std::string::npos) {
129  fileNameLength = path.size() - lastSlash - 1;
130  dirPath = path.substr(0,lastSlash);
131  } else {
132  fileNameLength = path.size();
133  dirPath="./";
134  }
135  if (fileNameLength + suffix.size() > getMaxNameLength(dirPath)) {
136  pathBuf.resize(path.size() - suffix.size());
137  }
138  }

References getMaxNameLength().

Referenced by newTmpWriter(), and outputHandler::posixFile::writerPosixFile::writerPosixFile().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files:
outputHandler::base::newWriter
virtual std::unique_ptr< writer > newWriter(const std::string &path, bool mightAppend, size_t sourceSize, size_t readBlockSize, copyRequest::stateType &state, bool noWrite, std::unique_ptr< ioHandle::attrDataType > attrData, std::unique_ptr< acl::list > aclData)=0
unimplementedActionError
class for exceptions that result from unimplemented functions Exceptions of this kind are to be throw...
Definition: copyRequestTypes.h:32
copyRequest::stateType
Definition: copyRequestTypes.h:66
outputHandler::base::getFactoryMap
static std::map< std::string, factoryClass * > & getFactoryMap()
Definition: outputHandler.h:22
outputHandler::base::getMaxNameLength
virtual size_t getMaxNameLength(const std::string &dirPath)
Definition: outputHandler.cpp:34
outputHandler::base::shortenNameToMax
void shortenNameToMax(const std::string &path, C &pathBuf, const std::string &suffix)
Definition: outputHandler.h:122