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 <utils/ipc/shm.h>
28 #include <blackboard/internal/memory_manager.h>
29 
30 namespace fawkes {
31 
32 class SharedMemory;
33 
35 {
36  private:
37  /** This struct determines the header in the shared memory segment
38  */
39  typedef struct {
40  unsigned int version; /**< version of the BB */
41  void *shm_addr; /**< base addr of shared memory */
42  chunk_list_t *free_list_head; /**< offset of the free chunks list head */
43  chunk_list_t *alloc_list_head; /**< offset of the allocated chunks list head */
44  } BlackBoardSharedMemoryHeaderData;
45 
46  public:
48  BlackBoardSharedMemoryHeader(size_t data_size, unsigned int version);
51  void set_shared_memory(SharedMemory *shmem);
52  virtual bool matches(void *memptr);
53  virtual size_t size();
54  virtual void initialize(void *memptr);
55  virtual void set(void *memptr);
56  virtual void reset();
57  virtual size_t data_size();
58  virtual SharedMemoryHeader * clone() const;
59  virtual bool operator==(const fawkes::SharedMemoryHeader &s) const;
64 
65  unsigned int version() const;
66 
67  private:
68  size_t _data_size;
69  unsigned int _version;
70  BlackBoardSharedMemoryHeaderData *data;
71  SharedMemory *shmem;
72 };
73 
74 } // end namespace fawkes
75 
76 #endif
virtual size_t size()
Get the size of the header data.
Definition: header.cpp:145
unsigned int version() const
Get BlackBoard version.
Definition: header.cpp:244
chunk_list_t * alloc_list_head()
Get the head of the allocated chunks list.
Definition: header.cpp:212
void set_shared_memory(SharedMemory *shmem)
Set SharedMemory instance.
Definition: header.cpp:87
Fawkes library namespace.
virtual ~BlackBoardSharedMemoryHeader()
Destructor.
Definition: header.cpp:94
virtual bool operator==(const fawkes::SharedMemoryHeader &s) const
Check for equality of headers.
Definition: header.cpp:129
chunk_list_t * free_list_head()
Get the head of the free chunks list.
Definition: header.cpp:201
void set_alloc_list_head(chunk_list_t *alh)
Set the head of the allocated chunks list.
Definition: header.cpp:234
virtual void reset()
Reset information previously set with set().
Definition: header.cpp:180
virtual SharedMemoryHeader * clone() const
Clone this shared memory header.
Definition: header.cpp:101
Chunk lists as stored in BlackBoard shared memory segment.
void set_free_list_head(chunk_list_t *flh)
Set the head of the free chunks list.
Definition: header.cpp:223
virtual size_t data_size()
Data segment size.
Definition: header.cpp:190
virtual bool matches(void *memptr)
Check if the given shared memory segment is a Fawkes BB segment.
Definition: header.cpp:112
Shared memory segment.
Definition: shm.h:49
BlackBoard Shared Memory Header.
Definition: header.h:34
virtual void initialize(void *memptr)
Initialize shared memory segment This copies basic management header data into the shared memory segm...
Definition: header.cpp:157
BlackBoardSharedMemoryHeader(unsigned int version)
Constructor.
Definition: header.cpp:62
Interface for shared memory header.
Definition: shm.h:33