Muesli
 All Classes Namespaces Files Functions Typedefs Enumerations
exception.h
1 /*
2  * exception.h
3  *
4  * Author:
5  *
6  * -------------------------------------------------------------------------------
7  *
8  * The MIT License
9  *
10  * Copyright 2014 Steffen Ernsting <s.ernsting@uni-muenster.de>,
11  * Herbert Kuchen <kuchen@uni-muenster.de.
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a copy
14  * of this software and associated documentation files (the "Software"), to deal
15  * in the Software without restriction, including without limitation the rights
16  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17  * copies of the Software, and to permit persons to whom the Software is
18  * furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included in
21  * all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29  * THE SOFTWARE.
30  *
31  */
32 
33 #pragma once
34 
35 #include <sstream>
36 #include <string>
37 
38 namespace msl {
39 
40 namespace detail {
41 
42 /* Abstract
43  */
44 class Exception
45 {
46 
47 public:
48 
49  virtual ~Exception()
50  {
51  }
52  ;
53 
54  virtual std::string
55  tostring() const = 0;
56 
57 };
58 
59 // ***************** Exception for Skeletons ****************
60 
62 {
63 
64 public:
65 
66  std::string tostring() const
67  {
68  return "UndefinedSourceException";
69  }
70 
71 };
72 
74 {
75 
76 public:
77 
78  std::string tostring() const
79  {
80  return "UndefinedDestinationException";
81  }
82 
83 };
84 
86 {
87 
88 public:
89 
90  std::string tostring() const
91  {
92  return "NonLocalAccessException";
93  }
94 
95 };
96 
98 {
99 
100 public:
101 
102  std::string tostring() const
103  {
104  return "MissingInitializationException";
105  }
106 
107 };
108 
110 {
111 
112 public:
113 
114  std::string tostring() const
115  {
116  return "IllegalGetException";
117  }
118 
119 };
120 
122 {
123 
124 public:
125 
126  std::string tostring() const
127  {
128  return "IllegalPutException";
129  }
130 
131 };
132 
134 {
135 
136 public:
137 
138  std::string tostring() const
139  {
140  return "IllegalPartitionException";
141  }
142 
143 };
144 
146 {
147 
148 public:
149 
150  std::string tostring() const
151  {
152  return "PartitioningImpossibleException";
153  }
154 
155 };
156 
158 {
159 
160 public:
161 
162  std::string tostring() const
163  {
164  return "IllegalPermuteException";
165  }
166 
167 };
168 
170 {
171 
172 public:
173 
174  std::string tostring() const
175  {
176  return "IllegalAllToAllException";
177  }
178 
179 };
180 
182 {
183 public:
184  std::string tostring() const
185  {
186  return "IllegalFunctorException\nMust provide a functor for each computing unit!";
187  }
188 };
189 
191 {
192 public:
194  : feature(f)
195  {
196  }
197 
198  std::string tostring() const
199  {
200  return feature + " not supported by your device(s)!";
201  }
202 
203 private:
204  std::string feature;
205 };
206 
208 {
209 
210 public:
211 
212  std::string tostring() const
213  {
214  return "NoSolutionException";
215  }
216 
217 };
218 
220 {
221 
222 public:
223 
224  std::string tostring() const
225  {
226  return "InternalErrorException";
227  }
228 
229 };
230 
231 // ***************** Exceptions for Collections *************
232 
234 {
235 
236 public:
237 
238  std::string tostring() const
239  {
240  return "EmptyHeapException";
241  }
242 
243 };
244 
246 {
247 
248 public:
249 
250  std::string tostring() const
251  {
252  return "EmptyStackException";
253  }
254 
255 };
256 
258 {
259 
260 public:
261 
262  std::string tostring() const
263  {
264  return "EmptyQueueException";
265  }
266 
267 };
268 
269 // ***************** Various *************
270 
271 inline std::ostream&
272 operator<<(std::ostream& os, const Exception& e)
273 {
274  os << e.tostring() << std::endl;
275 
276  return os;
277 }
278 
279 }
280 
281 }
Definition: exception.h:219
Definition: exception.h:109
Definition: exception.h:233
Definition: exception.h:85
Definition: exception.h:257
Definition: exception.h:121
Definition: exception.h:44
Definition: exception.h:169
Definition: exception.h:157
Definition: exception.h:245
Definition: exception.h:61
Definition: exception.h:181
Definition: exception.h:207
Definition: exception.h:133