nidas  v1.2-1520
IOException.h
Go to the documentation of this file.
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2 // vim: set shiftwidth=4 softtabstop=4 expandtab:
3 /*
4  ********************************************************************
5  ** NIDAS: NCAR In-situ Data Acquistion Software
6  **
7  ** 2006, Copyright University Corporation for Atmospheric Research
8  **
9  ** This program is free software; you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation; either version 2 of the License, or
12  ** (at your option) any later version.
13  **
14  ** This program is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** The LICENSE.txt file accompanying this software contains
20  ** a copy of the GNU General Public License. If it is not found,
21  ** write to the Free Software Foundation, Inc.,
22  ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  **
24  ********************************************************************
25 */
26 
27 #ifndef NIDAS_UTIL_IOEXCEPTION_H
28 #define NIDAS_UTIL_IOEXCEPTION_H
29 
30 #include <string>
31 #include "Exception.h"
32 
33 #include <cerrno> // not used here, but by many users of IOException
34 
35 namespace nidas { namespace util {
36 
37 class IOException : public Exception {
38 protected:
39 
43  IOException(const std::string& etype,const std::string& device,const std::string& task,int err) :
44  Exception(etype,device + ": " + task,err)
45  {
46  }
47 
51  IOException(const std::string& etype,const std::string& device,const std::string& task,const std::string& msg) :
52  Exception(etype,device + ": " + task + ": " + msg)
53  {
54  }
55 
56 public:
57 
62  IOException(const std::string& device, const std::string& task, const std::string& msg):
63  Exception("IOException", device + ": " + task + ": " + msg)
64  {}
65 
70  IOException(const std::string& task, const std::string& msg):
71  Exception("IOException", task + ": " + msg)
72  {}
73 
78  IOException(const std::string& device, const std::string& task, int err):
79  Exception("IOException", device + ": " + task,err)
80  {
81  }
82 
87 
89  {
91  return *this;
92  }
93 
97  virtual Exception* clone() const {
98  return new IOException(*this);
99  }
100 };
101 
102 }} // namespace nidas namespace util
103 
104 #endif
static string device
Definition: sing.cc:60
IOException(const IOException &e)
Copy constructor.
Definition: IOException.h:86
IOException(const std::string &etype, const std::string &device, const std::string &task, const std::string &msg)
Constructor used by sub-classes of IOException (e.g.
Definition: IOException.h:51
IOException(const std::string &device, const std::string &task, int err)
Create an IOException, passing a device name, task (e.g. &quot;read&quot; or &quot;ioctl&quot;), and an errno value...
Definition: IOException.h:78
#define err(format, arg...)
Definition: ck_lams.cc:55
virtual Exception * clone() const
clone myself (a &quot;virtual&quot; constructor).
Definition: IOException.h:97
IOException(const std::string &task, const std::string &msg)
Create an IOException, passing a device name, task (e.g. &quot;read&quot; or &quot;ioctl&quot;), and a message...
Definition: IOException.h:70
IOException & operator=(const IOException &e)
Definition: IOException.h:88
IOException(const std::string &etype, const std::string &device, const std::string &task, int err)
Constructor used by sub-classes of IOException (e.g.
Definition: IOException.h:43
IOException(const std::string &device, const std::string &task, const std::string &msg)
Create an IOException, passing a device name, task (e.g. &quot;read&quot; or &quot;ioctl&quot;), and a message...
Definition: IOException.h:62
Definition: Exception.h:35
Exception & operator=(const Exception &e)
Definition: Exception.h:74
Definition: IOException.h:37