YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ShmemOutputStream.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef YARP_SHMEM_SHMEMOUTPUTSTREAM_H
8#define YARP_SHMEM_SHMEMOUTPUTSTREAM_H
9
10
11#include "ShmemTypes.h"
12
14#include <yarp/os/Semaphore.h>
15#include <yarp/os/Thread.h>
16#include <yarp/os/Time.h>
17
18#include <ace/config.h>
19#include <ace/Mutex.h>
20#include <ace/Process_Mutex.h>
21#include <ace/SOCK_Stream.h>
22#include <ace/SOCK_Acceptor.h>
23#include <ace/SOCK_Connector.h>
24#include <ace/Log_Msg.h>
25#if defined(ACE_LACKS_SYSV_SHMEM)
26#include <ace/Shared_Memory_MM.h>
27#else
28#include <ace/Shared_Memory_SV.h>
29#endif
30// In one the ACE headers there is a definition of "main" for WIN32
31# ifdef main
32# undef main
33# endif
34
35
37{
38public:
41
42 bool isOk() const;
43 bool open(int port, int size = SHMEM_DEFAULT_SIZE);
44 bool write(const yarp::os::Bytes& b);
45 void close();
46
47protected:
48 bool Resize(int newsize);
49
50 bool m_bOpen;
51
53 int m_Port;
54
55#if defined(_ACE_USE_SV_SEM)
56 ACE_Mutex* m_pAccessMutex;
57 ACE_Mutex* m_pWaitDataMutex;
58#else
59 ACE_Process_Mutex* m_pAccessMutex;
60 ACE_Process_Mutex* m_pWaitDataMutex;
61#endif
62
63 ACE_Shared_Memory* m_pMap;
64 char* m_pData;
66};
67
68#endif // YARP_SHMEM_SHMEMOUTPUTSTREAM_H
#define SHMEM_DEFAULT_SIZE
Definition ShmemTypes.h:10
bool write(const yarp::os::Bytes &b)
bool open(int port, int size=4096)
ACE_Process_Mutex * m_pWaitDataMutex
ACE_Process_Mutex * m_pAccessMutex
ShmemHeader_t * m_pHeader
ACE_Shared_Memory * m_pMap
A simple abstraction for a block of bytes.
Definition Bytes.h:24