PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/interprocess/exceptions.hpp

http://hadesmem.googlecode.com/
C++ Header | 150 lines | 66 code | 22 blank | 62 comment | 5 complexity | a51cb0d02634f49c75d542ce361f024a MD5 | raw file
  1//////////////////////////////////////////////////////////////////////////////
  2//
  3// (C) Copyright Ion Gaztanaga 2005-2009. Distributed under the Boost
  4// Software License, Version 1.0. (See accompanying file
  5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6//
  7// See http://www.boost.org/libs/interprocess for documentation.
  8//
  9//////////////////////////////////////////////////////////////////////////////
 10
 11#ifndef BOOST_INTERPROCESS_EXCEPTIONS_HPP
 12#define BOOST_INTERPROCESS_EXCEPTIONS_HPP
 13
 14#if (defined _MSC_VER) && (_MSC_VER >= 1200)
 15#  pragma once
 16#endif
 17
 18#include <boost/interprocess/detail/config_begin.hpp>
 19#include <boost/interprocess/detail/workaround.hpp>
 20#include <boost/interprocess/errors.hpp>
 21#include <stdexcept>
 22#include <new>
 23
 24//!\file
 25//!Describes exceptions thrown by interprocess classes
 26
 27namespace boost {
 28
 29namespace interprocess {
 30
 31//!This class is the base class of all exceptions
 32//!thrown by boost::interprocess
 33class interprocess_exception : public std::exception
 34{
 35   public:
 36   interprocess_exception(const char *err/*error_code_t ec = other_error*/)
 37      :  m_err(other_error)
 38   {
 39//      try   {  m_str = "boost::interprocess_exception::library_error"; }
 40      try   {  m_str = err; }
 41      catch (...) {}
 42   }
 43/*
 44   interprocess_exception(native_error_t sys_err_code)
 45      :  m_err(sys_err_code)
 46   {
 47      try   {  fill_system_message(m_err.get_native_error(), m_str); }
 48      catch (...) {}
 49   }*/
 50
 51   interprocess_exception(const error_info &err_info, const char *str = 0)
 52      :  m_err(err_info)
 53   {
 54      try{
 55         if(m_err.get_native_error() != 0){
 56            fill_system_message(m_err.get_native_error(), m_str);
 57         }
 58         else if(str){
 59            m_str = str;
 60         }
 61         else{
 62            m_str = "boost::interprocess_exception::library_error";
 63         }
 64      }
 65      catch(...){}
 66   }
 67
 68   virtual ~interprocess_exception() throw(){}
 69
 70   virtual const char * what() const throw()
 71   {  return m_str.c_str();  }
 72
 73   native_error_t get_native_error()const { return m_err.get_native_error(); }
 74
 75   // Note: a value of other_error implies a library (rather than system) error
 76   error_code_t   get_error_code()  const { return m_err.get_error_code(); }
 77
 78   /// @cond
 79   private:
 80   error_info        m_err;
 81   std::string       m_str;
 82   /// @endcond
 83};
 84
 85//!This is the exception thrown by shared interprocess_mutex family when a deadlock situation
 86//!is detected or when using a interprocess_condition the interprocess_mutex is not locked
 87class lock_exception : public interprocess_exception
 88{
 89   public:
 90   lock_exception()
 91      :  interprocess_exception(lock_error)
 92   {}
 93
 94   virtual const char* what() const throw()
 95   {  return "boost::interprocess::lock_exception";  }
 96};
 97
 98//!This is the exception thrown by named interprocess_semaphore when a deadlock situation
 99//!is detected or when an error is detected in the post/wait operation
100/*
101class sem_exception : public interprocess_exception
102{
103   public:
104   sem_exception()
105      :  interprocess_exception(lock_error)
106   {}
107
108   virtual const char* what() const throw()
109   {  return "boost::interprocess::sem_exception";  }
110};
111*/
112//!This is the exception thrown by synchronization objects when there is
113//!an error in a wait() function
114/*
115class wait_exception : public interprocess_exception
116{
117   public:
118   virtual const char* what() const throw()
119   {  return "boost::interprocess::wait_exception";  }
120};
121*/
122
123//!This exception is thrown when a named object is created
124//!in "open_only" mode and the resource was not already created
125/*
126class not_previously_created : public interprocess_exception
127{
128 public:
129    virtual const char* what() const throw()
130      {  return "boost::interprocess::not_previously_created";  }
131};
132*/
133
134//!This exception is thrown when a memory request can't be
135//!fulfilled.
136class bad_alloc : public interprocess_exception
137{
138 public:
139   bad_alloc() : interprocess_exception("::boost::interprocess::bad_alloc"){}
140   virtual const char* what() const throw()
141      {  return "boost::interprocess::bad_alloc";  }
142};
143
144}  // namespace interprocess {
145
146}  // namespace boost
147
148#include <boost/interprocess/detail/config_end.hpp>
149
150#endif // BOOST_INTERPROCESS_EXCEPTIONS_HPP