Fawkes API  Fawkes Development Version
exceptions.h
1 /***************************************************************************
2  * exceptions.h - SyncPoint exceptions
3  *
4  * Created: Wed Jan 15 11:09:55 2014
5  * Copyright 2014 Till Hofmann
6  *
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef _SYNCPOINT_EXCEPTIONS_H_
24 #define _SYNCPOINT_EXCEPTIONS_H_
25 
26 #include <core/exception.h>
27 
28 namespace fawkes {
29 
30 /** A component which is watching a SyncPoint, called get_syncpoint() for the
31  * same identifier
32  */
33 class SyncPointAlreadyOpenedException : public Exception
34 {
35 public:
36  /** Constructor.
37  * @param component The calling component
38  * @param identifier The identifier of the SyncPoint
39  */
40  SyncPointAlreadyOpenedException(const char *component, const char *identifier)
41  {
42  append("Component '%s' called get_syncpoint() for identifier '%s', but is already watching",
43  component,
44  identifier);
45  }
46 };
47 
48 /** Emit was called by a component which isn't in the watcher set
49  * (or wrong component argument was passed)
50  */
52 {
53 public:
54  /** Constructor.
55  * @param component The calling component
56  * @param identifier The identifier of the SyncPoint
57  */
58  SyncPointNonWatcherCalledEmitException(const char *component, const char *identifier)
59  {
60  append("Component '%s' called emit for SyncPoint '%s', but is not a watcher",
61  component,
62  identifier);
63  }
64 };
65 
66 /** Emit was called by a component which isn't in the watcher set
67  * (or wrong component argument was passed)
68  */
69 class SyncPointNonWatcherCalledWaitException : public Exception
70 {
71 public:
72  /** Constructor.
73  * @param component The calling component
74  * @param identifier The identifier of the SyncPoint
75  */
76  SyncPointNonWatcherCalledWaitException(const char *component, const char *identifier)
77  {
78  append("Component '%s' called wait for SyncPoint '%s', but is not a watcher",
79  component,
80  identifier);
81  }
82 };
83 
84 /** Release was called on a non-existing SyncPoint
85  *
86  */
87 class SyncPointReleasedDoesNotExistException : public Exception
88 {
89 public:
90  /** Constructor.
91  * @param component The calling component
92  * @param identifier The identifier of the SyncPoint
93  */
94  SyncPointReleasedDoesNotExistException(const char *component, const char *identifier)
95  {
96  append("Component '%s' tried to release non-existing SyncPoint '%s'", component, identifier);
97  }
98 };
99 
100 /** Release was called by a component which isn't a watcher
101  *
102  */
104 {
105 public:
106  /** Constructor.
107  * @param component The calling component
108  * @param identifier The identifier of the SyncPoint
109  */
110  SyncPointReleasedByNonWatcherException(const char *component, const char *identifier)
111  {
112  append("Component '%s' tried to release SyncPoint '%s' but is not a watcher",
113  component,
114  identifier);
115  }
116 };
117 
118 /** Invalid identifier used (i.e. an empty string)
119  *
120  */
121 class SyncPointInvalidIdentifierException : public Exception
122 {
123 public:
124  /** Constructor.
125  * @param identifier The identifier of the SyncPoint
126  */
127  SyncPointInvalidIdentifierException(const char *identifier)
128  {
129  append("Tried to construct a SyncPoint with invalid identifier ('%s'). "
130  "Identifier must be a non-empty absolute path (e.g. '/path/to/syncpoint')"
131  " and may not end with '/'",
132  identifier);
133  }
134 };
135 
136 /** Invalid component name used (i.e. an empty string)
137  *
138  */
139 class SyncPointInvalidComponentException : public Exception
140 {
141 public:
142  /** Constructor.
143  * @param component The calling component
144  * @param identifier The identifier of the SyncPoint
145  */
146  SyncPointInvalidComponentException(const char *component, const char *identifier)
147  {
148  append("Invalid component name '%s' while accessing SyncPoint '%s'", component, identifier);
149  }
150 };
151 
152 /** A component called wait() but is already waiting
153  *
154  */
156 {
157 public:
158  /** Constructor.
159  * @param component The calling component
160  * @param identifier The identifier of the SyncPoint
161  */
162  SyncPointMultipleWaitCallsException(const char *component, const char *identifier)
163  {
164  append("Component '%s' called wait() on SyncPoint '%s', but is already waiting",
165  component,
166  identifier);
167  }
168 };
169 
170 /** Emit was called on a SyncBarrier but the calling component is not registered
171  * as emitter
172  */
173 class SyncPointNonEmitterCalledEmitException : public Exception
174 {
175 public:
176  /** Constructor.
177  * @param component The calling component
178  * @param identifier The identifier of the SyncPoint
179  */
180  SyncPointNonEmitterCalledEmitException(const char *component, const char *identifier)
181  {
182  append("Component '%s' called emit for SyncPoint '%s', "
183  "but is not a registered emitter",
184  component,
185  identifier);
186  }
187 };
188 
189 /** Invalid SyncPoint type.
190  */
191 class SyncPointInvalidTypeException : public Exception
192 {
193 public:
194  /** Constructor. */
196  {
197  append("Invalid SyncPoint Wakeup type.");
198  }
199 };
200 
201 /** The component called release but is still registered as emitter. */
203 {
204 public:
205  /** Constructor.
206  * @param component The calling component
207  * @param identifier The identifier of the SyncPoint
208  */
209  SyncPointCannotReleaseEmitter(const char *component, const char *identifier)
210  {
211  append("Component '%s' called emit for SyncPoint '%s', "
212  "but is still registered as emitter",
213  component,
214  identifier);
215  }
216 };
217 
218 } // namespace fawkes
219 
220 #endif
fawkes::SyncPointCannotReleaseEmitter
The component called release but is still registered as emitter.
Definition: exceptions.h:207
fawkes::SyncPointNonWatcherCalledEmitException
Emit was called by a component which isn't in the watcher set (or wrong component argument was passed...
Definition: exceptions.h:56
fawkes::SyncPointNonEmitterCalledEmitException::SyncPointNonEmitterCalledEmitException
SyncPointNonEmitterCalledEmitException(const char *component, const char *identifier)
Constructor.
Definition: exceptions.h:185
fawkes::SyncPointAlreadyOpenedException::SyncPointAlreadyOpenedException
SyncPointAlreadyOpenedException(const char *component, const char *identifier)
Constructor.
Definition: exceptions.h:51
fawkes::SyncPointNonWatcherCalledWaitException::SyncPointNonWatcherCalledWaitException
SyncPointNonWatcherCalledWaitException(const char *component, const char *identifier)
Constructor.
Definition: exceptions.h:81
fawkes::SyncPointNonWatcherCalledEmitException::SyncPointNonWatcherCalledEmitException
SyncPointNonWatcherCalledEmitException(const char *component, const char *identifier)
Constructor.
Definition: exceptions.h:63
fawkes::SyncPointReleasedByNonWatcherException
Release was called by a component which isn't a watcher.
Definition: exceptions.h:108
fawkes::SyncPointInvalidIdentifierException::SyncPointInvalidIdentifierException
SyncPointInvalidIdentifierException(const char *identifier)
Constructor.
Definition: exceptions.h:132
fawkes::SyncPointReleasedByNonWatcherException::SyncPointReleasedByNonWatcherException
SyncPointReleasedByNonWatcherException(const char *component, const char *identifier)
Constructor.
Definition: exceptions.h:115
fawkes::Exception::append
void append(const char *format,...)
Append messages to the message list.
Definition: exception.cpp:332
fawkes
fawkes::SyncPointMultipleWaitCallsException
A component called wait() but is already waiting.
Definition: exceptions.h:160
fawkes::SyncPointCannotReleaseEmitter::SyncPointCannotReleaseEmitter
SyncPointCannotReleaseEmitter(const char *component, const char *identifier)
Constructor.
Definition: exceptions.h:214
fawkes::SyncPointMultipleWaitCallsException::SyncPointMultipleWaitCallsException
SyncPointMultipleWaitCallsException(const char *component, const char *identifier)
Constructor.
Definition: exceptions.h:167
fawkes::SyncPointInvalidTypeException::SyncPointInvalidTypeException
SyncPointInvalidTypeException()
Constructor.
Definition: exceptions.h:200
fawkes::SyncPointReleasedDoesNotExistException::SyncPointReleasedDoesNotExistException
SyncPointReleasedDoesNotExistException(const char *component, const char *identifier)
Constructor.
Definition: exceptions.h:99
fawkes::SyncPointInvalidComponentException::SyncPointInvalidComponentException
SyncPointInvalidComponentException(const char *component, const char *identifier)
Constructor.
Definition: exceptions.h:151
fawkes::Exception
Definition: exception.h:39