libt2n: (gerd) more documentation-polishing
[libt2n] / src / t2n_exception.hxx
index c81ba02..0440f05 100644 (file)
@@ -23,7 +23,6 @@
 #include <string>
 
 #include <boost/serialization/serialization.hpp>
-#include <boost/serialization/export.hpp>
 
 namespace boost {
 namespace serialization {
@@ -39,7 +38,10 @@ void serialize(Archive & ar, std::exception & g, const unsigned int version)
 
 namespace libt2n
 {
-/// a generic exception that can be handeled with libt2n
+/** @brief a generic exception that can be handeled with libt2n
+    @note don't derive the exceptions your application generates directly from this one
+          but use libt2n::t2n_runtime_error for this
+*/
 class t2n_exception : public std::exception
 {
     private:
@@ -47,11 +49,7 @@ class t2n_exception : public std::exception
 
         friend class boost::serialization::access;
         template<class Archive>
-        void serialize(Archive & ar, const unsigned int version)
-        {
-            ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(exception);
-            ar & BOOST_SERIALIZATION_NVP(message);
-        }
+        void serialize(Archive & ar, const unsigned int version);
 
     public:
         t2n_exception(const std::string& _message)
@@ -79,10 +77,7 @@ class t2n_communication_error : public t2n_exception
     private:
         friend class boost::serialization::access;
         template<class Archive>
-        void serialize(Archive & ar, const unsigned int version)
-        {
-            ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_exception);
-        }
+        void serialize(Archive & ar, const unsigned int version);
 
     public:
         t2n_communication_error(const std::string& _message)
@@ -105,10 +100,7 @@ class t2n_connect_error : public t2n_communication_error
     private:
         friend class boost::serialization::access;
         template<class Archive>
-        void serialize(Archive & ar, const unsigned int version)
-        {
-            ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_communication_error);
-        }
+        void serialize(Archive & ar, const unsigned int version);
 
     public:
         t2n_connect_error(const std::string& _message)
@@ -131,10 +123,7 @@ class t2n_server_error : public t2n_communication_error
     private:
         friend class boost::serialization::access;
         template<class Archive>
-        void serialize(Archive & ar, const unsigned int version)
-        {
-            ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_communication_error);
-        }
+        void serialize(Archive & ar, const unsigned int version);
 
     public:
         t2n_server_error(const std::string& _message)
@@ -157,10 +146,7 @@ class t2n_transfer_error : public t2n_communication_error
     private:
         friend class boost::serialization::access;
         template<class Archive>
-        void serialize(Archive & ar, const unsigned int version)
-        {
-            ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_communication_error);
-        }
+        void serialize(Archive & ar, const unsigned int version);
 
     public:
         t2n_transfer_error(const std::string& _message)
@@ -183,10 +169,7 @@ class t2n_version_mismatch : public t2n_communication_error
     private:
         friend class boost::serialization::access;
         template<class Archive>
-        void serialize(Archive & ar, const unsigned int version)
-        {
-            ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_communication_error);
-        }
+        void serialize(Archive & ar, const unsigned int version);
 
     public:
         t2n_version_mismatch(const std::string& _message)
@@ -209,10 +192,7 @@ class t2n_command_error : public t2n_exception
     private:
         friend class boost::serialization::access;
         template<class Archive>
-        void serialize(Archive & ar, const unsigned int version)
-        {
-            ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_exception);
-        }
+        void serialize(Archive & ar, const unsigned int version);
 
     public:
         t2n_command_error(const std::string& _message)
@@ -235,10 +215,7 @@ class t2n_serialization_error : public t2n_exception
     private:
         friend class boost::serialization::access;
         template<class Archive>
-        void serialize(Archive & ar, const unsigned int version)
-        {
-            ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_exception);
-        }
+        void serialize(Archive & ar, const unsigned int version);
 
     public:
         t2n_serialization_error(const std::string& _message)
@@ -257,16 +234,15 @@ class t2n_serialization_error : public t2n_exception
 
 /** @brief a runtime error within the remote function.
  derive your own custom exceptions from this one
+
+ @note you must override the virtual clone method if you do so (used by libt2n::command_server::handle())
 */
 class t2n_runtime_error : public t2n_exception
 {
     private:
         friend class boost::serialization::access;
         template<class Archive>
-        void serialize(Archive & ar, const unsigned int version)
-        {
-            ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_exception);
-        }
+        void serialize(Archive & ar, const unsigned int version);
 
     public:
         t2n_runtime_error(const std::string& _message)
@@ -285,4 +261,6 @@ class t2n_runtime_error : public t2n_exception
 
 }  // namespace libt2n
 
+#include "t2n_exception.tcc"
+
 #endif