From: František Dvořák Date: Thu, 12 Sep 2013 15:38:47 +0000 (+0200) Subject: Add support for classname (using getImplId()). X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=a6097819dbff9c868c26e4968d5f467c5e404b04;p=dmlite-plugins-vfs.git Add support for classname (using getImplId()). --- diff --git a/src/Throw.cpp b/src/Throw.cpp index a3ba6f5..f7f0cd6 100644 --- a/src/Throw.cpp +++ b/src/Throw.cpp @@ -7,30 +7,30 @@ #include "Vfs.h" -void dmlite::vfsThrowHelper(const std::string& func, int code, const std::string& msg) throw (DmException) { - throw DmException(code, "VfsCatalog::" + func + "(): " + msg); +void dmlite::vfsThrowHelper(const std::string &classname, const std::string& func, int code, const std::string& msg) throw (DmException) { + throw DmException(code, classname + "::" + func + "(): " + msg); } -int dmlite::vfsWrapCallHelper(const std::string &func, int r, const std::string& msg) throw (DmException) { +int dmlite::vfsWrapCallHelper(const std::string &classname, const std::string &func, int r, const std::string& msg) throw (DmException) { if (r < 0) { if (msg.length() != 0) - vfsThrowHelper(func, errno, msg + ": " + strerror(errno)); + vfsThrowHelper(classname, func, errno, msg + ": " + strerror(errno)); else - vfsThrowHelper(func, errno, strerror(errno)); + vfsThrowHelper(classname, func, errno, strerror(errno)); } return r; } -void *dmlite::vfsWrapCallHelper(const std::string &func, void *p, const std::string& msg) throw (DmException) { +void *dmlite::vfsWrapCallHelper(const std::string &classname, const std::string &func, void *p, const std::string& msg) throw (DmException) { if (!p) { if (msg.length() != 0) - vfsThrowHelper(func, errno, msg + ": " + strerror(errno)); + vfsThrowHelper(classname, func, errno, msg + ": " + strerror(errno)); else - vfsThrowHelper(func, errno, strerror(errno)); + vfsThrowHelper(classname, func, errno, strerror(errno)); } return p; } diff --git a/src/Vfs.cpp b/src/Vfs.cpp index c55c27b..7022f37 100644 --- a/src/Vfs.cpp +++ b/src/Vfs.cpp @@ -18,6 +18,12 @@ using namespace dmlite; +std::string VfsFactory::getImplId() const throw () +{ + return "VfsFactory"; +} + + VfsFactory::VfsFactory() throw (DmException) { struct utsname hname; diff --git a/src/Vfs.h b/src/Vfs.h index 02ca183..82bb060 100644 --- a/src/Vfs.h +++ b/src/Vfs.h @@ -10,13 +10,13 @@ #include #include -#define vfsThrowErrno(MSG) dmlite::vfsThrowHelper(__func__, DMLITE_SYSERR(errno), (MSG)) -#define vfsThrow(CODE, MSG) dmlite::vfsThrowHelper(__func__, (CODE), (MSG)) +#define vfsThrowErrno(MSG) dmlite::vfsThrowHelper(getImplId(), __func__, DMLITE_SYSERR(errno), (MSG)) +#define vfsThrow(CODE, MSG) dmlite::vfsThrowHelper(getImplId(), __func__, (CODE), (MSG)) #ifdef __GNUC__ - #define wrapCall(RETVAL, MSG...) dmlite::vfsWrapCallHelper(__func__, (RETVAL) , ##MSG) + #define wrapCall(RETVAL, MSG...) dmlite::vfsWrapCallHelper(getImplId(), __func__, (RETVAL) , ##MSG) #else - #define wrapCall(RETVAL, ...) dmlite::vfsWrapCallHelper(__func__, (RETVAL) , ##__VA_ARGS__) + #define wrapCall(RETVAL, ...) dmlite::vfsWrapCallHelper(getImplId(), __func__, (RETVAL) , ##__VA_ARGS__) #endif namespace dmlite { @@ -46,11 +46,14 @@ namespace dmlite { std::string tokenPasswd_; bool tokenUseIp_; unsigned tokenLife_; + + private: + std::string getImplId(void) const throw (); }; - void vfsThrowHelper(const std::string& func, int code, const std::string& msg = "") throw (DmException); - int vfsWrapCallHelper(const std::string &func, int r, const std::string& msg = "") throw (DmException); - void *vfsWrapCallHelper(const std::string &func, void *p, const std::string& msg = "") throw (DmException); + void vfsThrowHelper(const std::string &classname, const std::string& func, int code, const std::string& msg = "") throw (DmException); + int vfsWrapCallHelper(const std::string &classname, const std::string &func, int r, const std::string& msg = "") throw (DmException); + void *vfsWrapCallHelper(const std::string &classname, const std::string &func, void *p, const std::string& msg = "") throw (DmException); }; diff --git a/src/VfsDriver.cpp b/src/VfsDriver.cpp index 8cae412..5fed071 100644 --- a/src/VfsDriver.cpp +++ b/src/VfsDriver.cpp @@ -108,6 +108,13 @@ VfsPoolHandler::~VfsPoolHandler() +std::string VfsPoolHandler::getImplId() const throw () +{ + return "VfsPoolDriver"; +} + + + std::string VfsPoolHandler::getPoolType(void) throw (DmException) { return "vfs"; diff --git a/src/VfsDriver.h b/src/VfsDriver.h index d521d0c..049d8f2 100644 --- a/src/VfsDriver.h +++ b/src/VfsDriver.h @@ -61,6 +61,8 @@ namespace dmlite { private: VfsPoolDriver* driver_; std::string poolName_; + + std::string getImplId() const throw(); }; };