/* LICENSE:
  =========================================================================
    CMPack'04 Source Code Release for OPEN-R SDK 1.1.5-r2 for ERS7
    Copyright (C) 2004 Multirobot Lab [Project Head: Manuela Veloso]
    School of Computer Science, Carnegie Mellon University
    All rights reserved.
  ========================================================================= */

#ifndef INCLUDED_AperiosSharedMem_h
#define INCLUDED_AperiosSharedMem_h

#include <OPENR/RCRegion.h>

/*------------------------------------------------------------------
CLASS
  SharedMemRegion

DESCRIPTION
  A region of shared memory in Aperios.
------------------------------------------------------------------*/
class SharedMemRegion {
public:
  typedef RCRegion *MsgForm;

  SharedMemRegion();
  virtual ~SharedMemRegion();

  virtual void init(int size);
  // trying virtual to keep brain dead compiler happy
  virtual void init(MsgForm info);

  void release();

  MsgForm getMsgForm();

  void *getBase();

  virtual void *getData();

  bool validData();

  SharedMemRegion &operator=(const SharedMemRegion &x);

  static MsgForm cloneMsgForm(const MsgForm &y);

private:
  RCRegion *region;
};

/*------------------------------------------------------------------
CLASS
  SMMSharedMemRegion

DESCRIPTION
  A shared memory region suitable for passing through SharedMemMgr.
------------------------------------------------------------------*/
class SMMSharedMemRegion : public SharedMemRegion {
public:
  virtual void init(int size);
  // trying virtual to keep brain dead compiler happy
  virtual void init(MsgForm info);
  
  virtual void *getData();

  void setId(int id);

  int getId();

  SMMSharedMemRegion &operator=(const SMMSharedMemRegion &x) {
    SharedMemRegion::operator=(x);
    return *this;
  }

private:
};

#endif
