header.h

00001 
00002 /***************************************************************************
00003  *  bb_shmem_header.h - BlackBoard shared memory header
00004  *
00005  *  Created: Thu Oct 19 14:19:06 2006 (Anne's 25th Birthday)
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_SHMEM_HEADER_H_
00025 #define __BLACKBOARD_SHMEM_HEADER_H_
00026 
00027 #include <utils/ipc/shm.h>
00028 #include <blackboard/internal/memory_manager.h>
00029 
00030 namespace fawkes {
00031 
00032 class SharedMemory;
00033 
00034 class BlackBoardSharedMemoryHeader : public SharedMemoryHeader
00035 {
00036  private:
00037   /** This struct determines the header in the shared memory segment
00038    */
00039   typedef struct {
00040     unsigned int  version;              /**< version of the BB */
00041     void         *shm_addr;             /**< base addr of shared memory */
00042     chunk_list_t *free_list_head;       /**< offset of the free chunks list head */
00043     chunk_list_t *alloc_list_head;      /**< offset of the allocated chunks list head */
00044   } BlackBoardSharedMemoryHeaderData;
00045 
00046  public:
00047   BlackBoardSharedMemoryHeader(unsigned int version);
00048   BlackBoardSharedMemoryHeader(size_t data_size, unsigned int version);
00049   BlackBoardSharedMemoryHeader(const BlackBoardSharedMemoryHeader *h);
00050   virtual ~BlackBoardSharedMemoryHeader();
00051   void           set_shared_memory(SharedMemory *shmem);
00052   virtual bool   matches(void *memptr);
00053   virtual size_t size();
00054   virtual void   initialize(void *memptr);
00055   virtual void   set(void *memptr);
00056   virtual void   reset();
00057   virtual size_t data_size();
00058   virtual SharedMemoryHeader * clone() const;
00059   virtual bool   operator==(const fawkes::SharedMemoryHeader &s) const;
00060   chunk_list_t * free_list_head();
00061   chunk_list_t * alloc_list_head();
00062   void set_free_list_head(chunk_list_t *flh);
00063   void set_alloc_list_head(chunk_list_t *alh);
00064 
00065   unsigned int version() const;
00066 
00067  private:
00068   size_t       _data_size;
00069   unsigned int _version;
00070   BlackBoardSharedMemoryHeaderData *data;
00071   SharedMemory                     *shmem;
00072 };
00073 
00074 } // end namespace fawkes
00075 
00076 #endif

Generated on Tue Feb 22 13:31:25 2011 for Fawkes API by  doxygen 1.4.7