factory_error.hh
Go to the documentation of this file.
00001 /* -*- C++ -*-
00002  * $Id: factory_error.hh 954 2005-02-23 12:38:20Z fpy $
00003  */
00004 #ifndef UTILMM_TYPES_FACTORY_ERROR_HEADER
00005 # define UTILMM_TYPES_FACTORY_ERROR_HEADER
00006 
00007 # include <stdexcept>
00008 # include <sstream>
00009 
00010 namespace utilmm {
00018   namespace factory_toolbox {
00019     
00030     template<class AbstractProduct, typename IdentifierType, typename Result>
00031     struct error {
00032       
00044       class exception
00045         :public std::runtime_error {
00046       private:
00047         exception(std::string const &msg)
00048           : std::runtime_error(msg) {}
00049 
00050         friend class error;
00051       }; // class utilmm::factory_toolbox::error<>::exception
00052 
00062       template<typename Ty>
00063       static Ty on_unknown_id(IdentifierType const &id) {
00064         std::ostringstream msg;
00065         msg<<"factory error : type "<<id<<" is unknown.";
00066         throw exception(msg.str());
00067       }
00068 
00078       static Result on_unknown_type(IdentifierType const &id) {
00079         return on_unknown_id<Result>(id);
00080       }
00081     }; // struct utilmm::factory_toolbox::error<>
00082     
00083   } // namespace utilmm::factory_toolbox
00084 } // namespace utilmm
00085 
00086 #endif // UTILMM_TYPES_FACTORY_ERROR_HEADER
00087 


utilmm
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Wed Sep 16 2015 07:05:43