Fawkes API Fawkes Development Version
header.h
1
2/***************************************************************************
3 * bb_shmem_header.h - BlackBoard shared memory header
4 *
5 * Created: Thu Oct 19 14:19:06 2006 (Anne's 25th Birthday)
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_SHMEM_HEADER_H_
25#define _BLACKBOARD_SHMEM_HEADER_H_
26
27#include <blackboard/internal/memory_manager.h>
28#include <utils/ipc/shm.h>
29
30namespace fawkes {
31
32class SharedMemory;
33
35{
36private:
37 /** This struct determines the header in the shared memory segment
38 */
39 typedef struct
40 {
41 unsigned int version; /**< version of the BB */
42 void * shm_addr; /**< base addr of shared memory */
43 chunk_list_t *free_list_head; /**< offset of the free chunks list head */
44 chunk_list_t *alloc_list_head; /**< offset of the allocated chunks list head */
45 } BlackBoardSharedMemoryHeaderData;
46
47public:
53 virtual bool matches(void *memptr);
54 virtual size_t size();
55 virtual void initialize(void *memptr);
56 virtual void set(void *memptr);
57 virtual void reset();
58 virtual size_t data_size();
59 virtual SharedMemoryHeader *clone() const;
60 virtual bool operator==(const fawkes::SharedMemoryHeader &s) const;
65
66 unsigned int version() const;
67
68private:
69 size_t _data_size;
70 unsigned int _version;
71 BlackBoardSharedMemoryHeaderData *data;
72 SharedMemory * shmem;
73};
74
75} // end namespace fawkes
76
77#endif
BlackBoard Shared Memory Header.
Definition: header.h:35
virtual void set(void *memptr)
Set data of this header Sets the internal pointer to the shared memory header data to the data retrie...
Definition: header.cpp:160
void set_shared_memory(SharedMemory *shmem)
Set SharedMemory instance.
Definition: header.cpp:83
virtual bool matches(void *memptr)
Check if the given shared memory segment is a Fawkes BB segment.
Definition: header.cpp:104
virtual size_t data_size()
Data segment size.
Definition: header.cpp:175
virtual ~BlackBoardSharedMemoryHeader()
Destructor.
Definition: header.cpp:89
virtual void initialize(void *memptr)
Initialize shared memory segment This copies basic management header data into the shared memory segm...
Definition: header.cpp:145
BlackBoardSharedMemoryHeader(unsigned int version)
Constructor.
Definition: header.cpp:60
unsigned int version() const
Get BlackBoard version.
Definition: header.cpp:224
chunk_list_t * free_list_head()
Get the head of the free chunks list.
Definition: header.cpp:185
void set_free_list_head(chunk_list_t *flh)
Set the head of the free chunks list.
Definition: header.cpp:205
virtual void reset()
Reset information previously set with set().
Definition: header.cpp:166
virtual SharedMemoryHeader * clone() const
Clone this shared memory header.
Definition: header.cpp:94
void set_alloc_list_head(chunk_list_t *alh)
Set the head of the allocated chunks list.
Definition: header.cpp:215
virtual bool operator==(const fawkes::SharedMemoryHeader &s) const
Check for equality of headers.
Definition: header.cpp:120
virtual size_t size()
Get the size of the header data.
Definition: header.cpp:134
chunk_list_t * alloc_list_head()
Get the head of the allocated chunks list.
Definition: header.cpp:195
Interface for shared memory header.
Definition: shm.h:34
Shared memory segment.
Definition: shm.h:53
Fawkes library namespace.
Chunk lists as stored in BlackBoard shared memory segment.