Fawkes API  Fawkes Development Version
exceptions.h
1 
2 /***************************************************************************
3  * exceptions.h - BlackBoard exceptions
4  *
5  * Generated: Wed Oct 04 18:37:50 2006
6  * Copyright 2006 Tim Niemueller [www.niemueller.de]
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. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __BLACKBOARD_EXCEPTIONS_H_
25 #define __BLACKBOARD_EXCEPTIONS_H_
26 
27 #include <core/exception.h>
28 
29 namespace fawkes {
30 
31 /** A NULL pointer was supplied where not allowed.
32  * Throw this exception if a pointer to NULL has been supplied where this is
33  * not allowed.
34  */
36  public:
37  /** Constructor */
38  BlackBoardMemMgrInvalidPointerException() : Exception("Invalid pointer to free") {}
39 };
40 
41 
42 /** Thrown when BlackBoard memory has been corupted
43  * This exception is thrown by the memory manager if the memory has been
44  * corrupted, for example if there are bytes that belong to neither a free chunk nor
45  * a allocated chunk.
46  */
48  public:
49  /** Constructor
50  * @param msg message, appended to exception, base message "Memory corruption detected"
51  */
53  : Exception("Memory corruption detected")
54  {
55  append(msg);
56  }
57 };
58 
59 /** Thrown if BlackBoard is not master and master operation has been requested.
60  * This exception is thrown by the memory manager if the memory is not owned but
61  * master mode is required. The interface manager throws it if you try to create
62  * a new interface but are not master.
63  * corrupted, for example if there are bytes that belong to neither a free chunk nor
64  * a allocated chunk.
65  */
67  public:
68  /** Constructor
69  * @param msg message, appended to exception, base message "Memory corruption detected"
70  */
71  BBNotMasterException(const char *msg)
72  : Exception("Not BlackBoard Master!")
73  {
74  append(msg);
75  }
76 };
77 
78 
79 /** Thrown if shared memory could not be opened. Can happen only if opening the
80  * segment as non-master.
81  */
83  public:
84  /** Constructor */
85  BBMemMgrCannotOpenException() : Exception("Cannot open shared memory segment") {}
86 };
87 
88 
89 /** Thrown if no definition of interface or interface generator found.
90  */
92  public:
93  /** Constructor
94  * @param type type of interface that could not be found
95  * @param add_msg additional message, add a space as first character
96  */
97  BlackBoardInterfaceNotFoundException(const char *type, const char *add_msg = "")
98  : Exception("Interface of type '%s' not found.%s", type, add_msg)
99  {
100  }
101 };
102 
103 
104 /** Thrown if versions do not match.
105  * If the hashes of two interfaces of the very same type do not match they
106  * are incompatible.
107  */
109  public:
110  /** Constructor. */
112  : Exception("Interface versions do not match, need to update and recompile interfaces?")
113  {
114  }
115 };
116 
117 
118 /** Thrown if a writer is already active on an interface that writing has
119  * been requested for.
120  */
122  public:
123  /** Constructor
124  * @param type type of interface that could not be found
125  * @param id identifier of the interface
126  */
127  BlackBoardWriterActiveException(const char *id, const char *type) : Exception()
128  {
129  append("There is already a writer on interface '%s' of type '%s'", id, type);
130  }
131 };
132 
133 
134 /** Thrown if BlackBoard is opened as non-master with no master alive.
135  */
137  public:
138  /** Constructor*/
139  BlackBoardNoMasterAliveException() : Exception("No master BlackBoard alive") {}
140 };
141 
142 
143 /** Thrown if no writer interface is alive.
144  */
146 {
147  public:
148  /** Constructor.
149  * @param type interface type string
150  * @param id interface ID
151  */
152  BlackBoardNoWritingInstanceException(const char *type, const char *id) : Exception()
153  {
154  append("No writing instance for interface %s::%s", type, id);
155  }
156 };
157 
158 } // end namespace fawkes
159 
160 #endif
Thrown when BlackBoard memory has been corupted This exception is thrown by the memory manager if the...
Definition: exceptions.h:47
Fawkes library namespace.
BlackBoardWriterActiveException(const char *id, const char *type)
Constructor.
Definition: exceptions.h:127
Thrown if no writer interface is alive.
Definition: exceptions.h:145
A NULL pointer was supplied where not allowed.
Definition: exceptions.h:35
BBNotMasterException(const char *msg)
Constructor.
Definition: exceptions.h:71
BlackBoardInterfaceNotFoundException(const char *type, const char *add_msg="")
Constructor.
Definition: exceptions.h:97
Base class for exceptions in Fawkes.
Definition: exception.h:36
Thrown if shared memory could not be opened.
Definition: exceptions.h:82
Thrown if BlackBoard is not master and master operation has been requested.
Definition: exceptions.h:66
BBMemMgrCannotOpenException()
Constructor.
Definition: exceptions.h:85
Thrown if BlackBoard is opened as non-master with no master alive.
Definition: exceptions.h:136
Thrown if versions do not match.
Definition: exceptions.h:108
Thrown if no definition of interface or interface generator found.
Definition: exceptions.h:91
BBInconsistentMemoryException(const char *msg)
Constructor.
Definition: exceptions.h:52
BlackBoardNoWritingInstanceException(const char *type, const char *id)
Constructor.
Definition: exceptions.h:152
Thrown if a writer is already active on an interface that writing has been requested for...
Definition: exceptions.h:121
void append(const char *format,...)
Append messages to the message list.
Definition: exception.cpp:341