Fawkes API  Fawkes Development Version
shm_exceptions.cpp
1 
2 /***************************************************************************
3  * shm_exceptions.cpp - exceptions thrown in shmem utils, do NOT put your own
4  * application specific exceptions here!
5  *
6  * Created: Sat Nov 11 14:15:19 2006 (on train from Hamburg to Aachen)
7  * Copyright 2005-2006 Tim Niemueller [www.niemueller.de]
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #include <utils/ipc/shm_exceptions.h>
26 
27 #include <core/threading/mutex.h>
28 
29 #ifndef _GNU_SOURCE
30 #define _GNU_SOURCE
31 #endif
32 #include <stdio.h>
33 
34 namespace fawkes {
35 
36 
37 /** @class ShmCouldNotAttachException shm_exceptions.h <utils/ipc/shm_exceptions.h>
38  * Could not attach to shared memory segment.
39  */
40 /** Constructor.
41  * @param msg message why we could not attach
42  */
44  : Exception(msg)
45 {
46 }
47 
48 /** @class ShmNoHeaderException shm_exceptions.h <utils/ipc/shm_exceptions.h>
49  * No shared memory header set before attach()
50  */
51 /** Constructor. */
53  : Exception("No SharedMemoryHeader, cannot attach")
54 {
55 }
56 
57 
58 /** @class ShmInconsistentSegmentSizeException shm_exceptions.h <utils/ipc/shm_exceptions.h>
59  * Memory size does not match
60  */
61 /** Constructor
62  * @param desired_mem The exepcted memory size
63  * @param act_mem The actual memory size
64  */
66  unsigned int act_mem)
67  : Exception("Inconsistent shared mem segment found in memory "
68  "(memory size does not match, desired: %u, actual: %u)",
69  desired_mem, act_mem)
70 {
71 }
72 
73 
74 /** @class ShmDoesNotExistException shm_exceptions.h <utils/ipc/shm_exceptions.h>
75  * Shared memory segment does not exist.
76  */
77 /** Constructor */
79  : Exception("The given shared memory segment does not exist.")
80 {
81 }
82 
83 
84 /** @class ShmCouldNotAttachAddrDepException shm_exceptions.h <utils/ipc/shm_exceptions.h>
85  * The shared memory is set adress-dependend but could not be opened at the appropriate
86  * address.
87  */
88 /** Constructor. */
90  : Exception("Could not attach to the shared memory "
91  "segment with the appropriate address")
92 {
93 }
94 
95 
96 /** @class ShmAddrOutOfBoundsException shm_exceptions.h <utils/ipc/shm_exceptions.h>
97  * The address points out of the shared memory.
98  */
99 /** Constructor. */
101  : Exception("The address you tried to transform points "
102  "out of the shared memory segment")
103 {
104 }
105 
106 
107 /** @class ShmPtrOutOfBoundsException shm_exceptions.h <utils/ipc/shm_exceptions.h>
108  * The pointer does not point inside the shared memory.
109  */
110 /** Constructor. */
112  : Exception("The pointer you tried to transform does not "
113  "point inside the shared memory segment")
114 {
115 }
116 
117 } // end namespace fawkes
Fawkes library namespace.
ShmInconsistentSegmentSizeException(unsigned int desired_mem, unsigned int act_mem)
Constructor.
ShmCouldNotAttachException(const char *msg)
Constructor.
Base class for exceptions in Fawkes.
Definition: exception.h:36