t2n_exception.hxx

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Gerd v. Egidy                                   *
00003  *   gve@intra2net.com                                                     *
00004  *                                                                         *
00005  *   This library is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License version   *
00007  *   2.1 as published by the Free Software Foundation.                     *
00008  *                                                                         *
00009  *   This library is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU Lesser General Public License for more details.                   *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Lesser General Public      *
00015  *   License along with this program; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00018  ***************************************************************************/
00019 #ifndef __LIBT2N_T2N_EXCEPTION
00020 #define __LIBT2N_T2N_EXCEPTION
00021 
00022 #include <stdexcept>
00023 #include <string>
00024 
00025 #include <boost/serialization/serialization.hpp>
00026 
00027 namespace boost {
00028 namespace serialization {
00029 
00030 // make std::exception serializable
00031 template<class Archive>
00032 void serialize(Archive & ar, std::exception & g, const unsigned int version)
00033 {
00034 }
00035 
00036 } // namespace serialization
00037 } // namespace boost
00038 
00039 namespace libt2n
00040 {
00045 class t2n_exception : public std::exception
00046 {
00047     private:
00048         std::string message;
00049 
00050         friend class boost::serialization::access;
00051         template<class Archive>
00052         void serialize(Archive & ar, const unsigned int version);
00053 
00054     public:
00055         t2n_exception(const std::string& _message)
00056             { message=_message; }
00057 
00058         t2n_exception()
00059             { }
00060 
00061         virtual const char* what() const throw()
00062             { return message.c_str(); }
00063 
00064         virtual t2n_exception* clone() const
00065             { return new t2n_exception(*this); }
00066 
00067         virtual ~t2n_exception() throw()
00068             {}
00069 
00070         virtual void do_throw()
00071             { throw *this; }
00072 };
00073 
00075 class t2n_communication_error : public t2n_exception
00076 {
00077     private:
00078         friend class boost::serialization::access;
00079         template<class Archive>
00080         void serialize(Archive & ar, const unsigned int version);
00081 
00082     public:
00083         t2n_communication_error(const std::string& _message)
00084             : t2n_exception(_message)
00085             { }
00086 
00087         t2n_communication_error()
00088             { }
00089 
00090         t2n_exception* clone() const
00091             { return new t2n_communication_error(*this); }
00092 
00093         void do_throw()
00094             { throw *this; }
00095 };
00096 
00098 class t2n_connect_error : public t2n_communication_error
00099 {
00100     private:
00101         friend class boost::serialization::access;
00102         template<class Archive>
00103         void serialize(Archive & ar, const unsigned int version);
00104 
00105     public:
00106         t2n_connect_error(const std::string& _message)
00107             : t2n_communication_error(_message)
00108             { }
00109 
00110         t2n_connect_error()
00111             { }
00112 
00113         t2n_exception* clone() const
00114             { return new t2n_connect_error(*this); }
00115 
00116         void do_throw()
00117             { throw *this; }
00118 };
00119 
00121 class t2n_server_error : public t2n_communication_error
00122 {
00123     private:
00124         friend class boost::serialization::access;
00125         template<class Archive>
00126         void serialize(Archive & ar, const unsigned int version);
00127 
00128     public:
00129         t2n_server_error(const std::string& _message)
00130             : t2n_communication_error(_message)
00131             { }
00132 
00133         t2n_server_error()
00134             { }
00135 
00136         t2n_exception* clone() const
00137             { return new t2n_server_error(*this); }
00138 
00139         void do_throw()
00140             { throw *this; }
00141 };
00142 
00144 class t2n_transfer_error : public t2n_communication_error
00145 {
00146     private:
00147         friend class boost::serialization::access;
00148         template<class Archive>
00149         void serialize(Archive & ar, const unsigned int version);
00150 
00151     public:
00152         t2n_transfer_error(const std::string& _message)
00153             : t2n_communication_error(_message)
00154             { }
00155 
00156         t2n_transfer_error()
00157             { }
00158 
00159         t2n_exception* clone() const
00160             { return new t2n_transfer_error(*this); }
00161 
00162         void do_throw()
00163             { throw *this; }
00164 };
00165 
00167 class t2n_version_mismatch : public t2n_communication_error
00168 {
00169     private:
00170         friend class boost::serialization::access;
00171         template<class Archive>
00172         void serialize(Archive & ar, const unsigned int version);
00173 
00174     public:
00175         t2n_version_mismatch(const std::string& _message)
00176             : t2n_communication_error(_message)
00177             { }
00178 
00179         t2n_version_mismatch()
00180             { }
00181 
00182         t2n_exception* clone() const
00183             { return new t2n_version_mismatch(*this); }
00184 
00185         void do_throw()
00186             { throw *this; }
00187 };
00188 
00190 class t2n_command_error : public t2n_exception
00191 {
00192     private:
00193         friend class boost::serialization::access;
00194         template<class Archive>
00195         void serialize(Archive & ar, const unsigned int version);
00196 
00197     public:
00198         t2n_command_error(const std::string& _message)
00199             : t2n_exception(_message)
00200             { }
00201 
00202         t2n_command_error()
00203             { }
00204 
00205         t2n_exception* clone() const
00206             { return new t2n_command_error(*this); }
00207 
00208         void do_throw()
00209             { throw *this; }
00210 };
00211 
00213 class t2n_serialization_error : public t2n_exception
00214 {
00215     private:
00216         friend class boost::serialization::access;
00217         template<class Archive>
00218         void serialize(Archive & ar, const unsigned int version);
00219 
00220     public:
00221         t2n_serialization_error(const std::string& _message)
00222             : t2n_exception(_message)
00223             { }
00224 
00225         t2n_serialization_error()
00226             { }
00227 
00228         t2n_exception* clone() const
00229             { return new t2n_serialization_error(*this); }
00230 
00231         void do_throw()
00232             { throw *this; }
00233 };
00234 
00240 class t2n_runtime_error : public t2n_exception
00241 {
00242     private:
00243         friend class boost::serialization::access;
00244         template<class Archive>
00245         void serialize(Archive & ar, const unsigned int version);
00246 
00247     public:
00248         t2n_runtime_error(const std::string& _message)
00249             : t2n_exception(_message)
00250             { }
00251 
00252         t2n_runtime_error()
00253             { }
00254 
00255         t2n_exception* clone() const
00256             { return new t2n_runtime_error(*this); }
00257 
00258         void do_throw()
00259             { throw *this; }
00260 };
00261 
00262 }  // namespace libt2n
00263 
00264 #include "t2n_exception.tcc"
00265 
00266 #endif

Generated on Fri Sep 26 15:36:59 2008 for libt2n by  doxygen 1.5.6