exceptions.h

00001 
00002 /***************************************************************************
00003  *  exceptions.h - BlackBoard exceptions
00004  *
00005  *  Generated: Wed Oct 04 18:37:50 2006
00006  *  Copyright  2006  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #ifndef __BLACKBOARD_EXCEPTIONS_H_
00025 #define __BLACKBOARD_EXCEPTIONS_H_
00026 
00027 #include <core/exception.h>
00028 
00029 namespace fawkes {
00030 
00031 /** A NULL pointer was supplied where not allowed.
00032  * Throw this exception if a pointer to NULL has been supplied where this is
00033  * not allowed.
00034  */
00035 class BlackBoardMemMgrInvalidPointerException : public Exception {
00036  public:
00037   /** Constructor */
00038   BlackBoardMemMgrInvalidPointerException() : Exception("Invalid pointer to free") {}
00039 };
00040 
00041 
00042 /** Thrown when BlackBoard memory has been corupted
00043  * This exception is thrown by the memory manager if the memory has been
00044  * corrupted, for example if there are bytes that belong to neither a free chunk nor
00045  * a allocated chunk.
00046  */
00047 class BBInconsistentMemoryException : public Exception {
00048  public:
00049   /** Constructor
00050    * @param msg message, appended to exception, base message "Memory corruption detected"
00051    */
00052   BBInconsistentMemoryException(const char *msg)
00053     : Exception("Memory corruption detected")
00054   {
00055     append(msg);
00056   }
00057 };
00058 
00059 /** Thrown if BlackBoard is not master and master operation has been requested.
00060  * This exception is thrown by the memory manager if the memory is not owned but
00061  * master mode is required. The interface manager throws it if you try to create
00062  * a new interface but are not master.
00063  * corrupted, for example if there are bytes that belong to neither a free chunk nor
00064  * a allocated chunk.
00065  */
00066 class BBNotMasterException : public Exception {
00067  public:
00068   /** Constructor
00069    * @param msg message, appended to exception, base message "Memory corruption detected"
00070    */
00071   BBNotMasterException(const char *msg)
00072     : Exception("Not BlackBoard Master!")
00073   {
00074     append(msg);
00075   }
00076 };
00077 
00078 
00079 /** Thrown if shared memory could not be opened. Can happen only if opening the
00080  * segment as non-master.
00081  */
00082 class BBMemMgrCannotOpenException : public Exception {
00083  public:
00084   /** Constructor */
00085   BBMemMgrCannotOpenException() : Exception("Cannot open shared memory segment") {}
00086 };
00087 
00088 
00089 /** Thrown if no definition of interface or interface generator found.
00090  */
00091 class BlackBoardInterfaceNotFoundException : public Exception {
00092  public:
00093   /** Constructor
00094    * @param type type of interface that could not be found
00095    * @param add_msg additional message, add a space as first character
00096    */
00097   BlackBoardInterfaceNotFoundException(const char *type, const char *add_msg = "")
00098     : Exception("Interface of type '%s' not found.%s", type, add_msg)
00099   {
00100   }
00101 };
00102 
00103 
00104 /** Thrown if versions do not match.
00105  * If the hashes of two interfaces of the very same type do not match they
00106  * are incompatible.
00107  */
00108 class BlackBoardInterfaceVersionMismatchException : public Exception {
00109  public:
00110   /** Constructor. */
00111   BlackBoardInterfaceVersionMismatchException()
00112     : Exception("Interface versions do not match, need to update and recompile interfaces?")
00113   {
00114   }
00115 };
00116 
00117 
00118 /** Thrown if a writer is already active on an interface that writing has
00119  * been requested for.
00120  */
00121 class BlackBoardWriterActiveException : public Exception {
00122  public:
00123   /** Constructor
00124    * @param type type of interface that could not be found
00125    * @param id identifier of the interface
00126    */
00127   BlackBoardWriterActiveException(const char *id, const char *type) : Exception()
00128   {
00129     append("There is already a writer on interface '%s' of type '%s'", id, type);
00130   }
00131 };
00132 
00133 
00134 /** Thrown if BlackBoard is opened as non-master with no master alive.
00135  */
00136 class BlackBoardNoMasterAliveException : public Exception {
00137  public:
00138   /** Constructor*/
00139   BlackBoardNoMasterAliveException() : Exception("No master BlackBoard alive") {}
00140 };
00141 
00142 
00143 /** Thrown if no writer interface is alive.
00144  */
00145 class BlackBoardNoWritingInstanceException : public Exception {
00146  public:
00147   /** Constructor*/
00148   BlackBoardNoWritingInstanceException() : Exception("No writing instance for interface") {}
00149 };
00150 
00151 } // end namespace fawkes
00152 
00153 #endif