Add support for classname (using getImplId()).
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 12 Sep 2013 15:38:47 +0000 (17:38 +0200)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 12 Sep 2013 15:38:47 +0000 (17:38 +0200)
src/Throw.cpp
src/Vfs.cpp
src/Vfs.h
src/VfsDriver.cpp
src/VfsDriver.h

index a3ba6f5..f7f0cd6 100644 (file)
@@ -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;
 }
index c55c27b..7022f37 100644 (file)
@@ -18,6 +18,12 @@ using namespace dmlite;
 
 
 
+std::string VfsFactory::getImplId() const throw ()
+{
+  return "VfsFactory";
+}
+
+
 VfsFactory::VfsFactory() throw (DmException)
 {
   struct utsname hname;
index 02ca183..82bb060 100644 (file)
--- a/src/Vfs.h
+++ b/src/Vfs.h
 #include <dmlite/cpp/io.h>
 #include <dmlite/cpp/poolmanager.h>
 
-#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);
 
 };
 
index 8cae412..5fed071 100644 (file)
@@ -108,6 +108,13 @@ VfsPoolHandler::~VfsPoolHandler()
 
 
 
+std::string VfsPoolHandler::getImplId() const throw ()
+{
+  return "VfsPoolDriver";
+}
+
+
+
 std::string VfsPoolHandler::getPoolType(void) throw (DmException)
 {
   return "vfs";
index d521d0c..049d8f2 100644 (file)
@@ -61,6 +61,8 @@ namespace dmlite {
   private:
     VfsPoolDriver* driver_;
     std::string    poolName_;
+
+    std::string getImplId() const throw();
   };
 
 };