// %pacpus:license{
// This file is part of the PACPUS framework distributed under the
// CECILL-C License, Version 1.0.
// %pacpus:license}
/// @file
/// @author  Firstname Surname <firstname.surname@utc.fr>
/// @date    Month, Year
/// @version $Id: PosixShMem.h 76 2013-01-10 17:05:10Z kurdejma $
/// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
/// @brief Brief description.
///
/// Detailed description.

#ifndef DEF_PACPUS_POSIXSHMEM_H
#define DEF_PACPUS_POSIXSHMEM_H

#include <QSharedMemory>
#include <QSystemSemaphore>

#include "ShMemBase.h"
#include "PacpusToolsConfig.h"

/// @todo Documentation
class PACPUSTOOLS_API PosixShMem
        : public ShMemBase
{
public:
    /// @todo Documentation
    PosixShMem(const char * name, int size);
    /// @todo Documentation
    virtual ~PosixShMem();

    /// @todo Documentation
    virtual void *read();
    /// @todo Documentation
    virtual void write(void *data, int size, unsigned long offset = 0);
    /// @todo Documentation
    virtual bool wait(unsigned long timeout = 0);
    /// @todo Documentation
    virtual void lockMemory();
    /// @todo Documentation
    virtual void unlockMemory();

private:
    QSystemSemaphore * event_;
    QSharedMemory * memory_;
};

#endif // DEF_PACPUS_POSIXSHMEM_H
