Util--  1.1
factory_error.hh
Go to the documentation of this file.
1 /* -*- C++ -*-
2  * $Id: factory_error.hh 954 2005-02-23 12:38:20Z fpy $
3  */
4 #ifndef UTILMM_TYPES_FACTORY_ERROR_HEADER
5 # define UTILMM_TYPES_FACTORY_ERROR_HEADER
6 
7 # include <stdexcept>
8 # include <sstream>
9 
10 namespace utilmm {
18  namespace factory_toolbox {
19 
30  template<class AbstractProduct, typename IdentifierType, typename Result>
31  struct error {
32 
44  class exception
45  :public std::runtime_error {
46  private:
47  exception(std::string const &msg)
48  : std::runtime_error(msg) {}
49 
50  friend class error;
51  }; // class utilmm::factory_toolbox::error<>::exception
52 
62  template<typename Ty>
63  static Ty on_unknown_id(IdentifierType const &id) {
64  std::ostringstream msg;
65  msg<<"factory error : type "<<id<<" is unknown.";
66  throw exception(msg.str());
67  }
68 
78  static Result on_unknown_type(IdentifierType const &id) {
79  return on_unknown_id<Result>(id);
80  }
81  }; // struct utilmm::factory_toolbox::error<>
82 
83  } // namespace utilmm::factory_toolbox
84 } // namespace utilmm
85 
86 #endif // UTILMM_TYPES_FACTORY_ERROR_HEADER
87 
default utilmm::factory error policy
Definition: factory_error.hh:31
static Ty on_unknown_id(IdentifierType const &id)
unknown id error
Definition: factory_error.hh:63
static Result on_unknown_type(IdentifierType const &id)
unknown creation method error
Definition: factory_error.hh:78
factory error exception
Definition: factory_error.hh:44
Definition: auto_flag.hh:6

Generated on Mon Oct 22 2018 18:39:28 for Util-- by doxygen 1.8.13
SourceForge.net Project Page