Go to the documentation of this file.00001
00002
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 };
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 };
00082
00083 }
00084 }
00085
00086 #endif // UTILMM_TYPES_FACTORY_ERROR_HEADER
00087