code format
This commit is contained in:
@@ -5,22 +5,22 @@
|
||||
* \~russian Разделяемая память
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Shared Memory
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Shared Memory
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PISHAREDMEMORY_H
|
||||
@@ -33,26 +33,25 @@
|
||||
//! \~\brief
|
||||
//! \~english Shared memory.
|
||||
//! \~russian Разделяемая память.
|
||||
class PIP_EXPORT PISharedMemory: public PIIODevice
|
||||
{
|
||||
class PIP_EXPORT PISharedMemory: public PIIODevice {
|
||||
PIIODEVICE(PISharedMemory, "shm");
|
||||
|
||||
public:
|
||||
|
||||
//! \~english Constructs empty %PISharedMemory
|
||||
//! \~russian Создает пустой %PISharedMemory
|
||||
explicit PISharedMemory();
|
||||
|
||||
|
||||
//! \~english Constructs a shared memory object with name "shm_name", size "size" and open mode "mode"
|
||||
//! \~russian Создает объект разделяемой памяти с именем "shm_name", размером "size" и режимом открытия "mode"
|
||||
explicit PISharedMemory(const PIString & shm_name, int size, DeviceMode mode = ReadWrite);
|
||||
|
||||
|
||||
virtual ~PISharedMemory();
|
||||
|
||||
|
||||
|
||||
//! \~english Read all shared memory content and return it as byte array
|
||||
//! \~russian Читает всю разделяемую память и возвращает её как байтовый массив
|
||||
PIByteArray readAll();
|
||||
|
||||
|
||||
//! \~english Returns shared memory size
|
||||
//! \~russian Возвращает размер разделяемой памяти
|
||||
llong size() const;
|
||||
@@ -60,11 +59,11 @@ public:
|
||||
//! \~english Set shared memory size
|
||||
//! \~russian Устанавливает размер разделяемой памяти
|
||||
void setSize(llong s);
|
||||
|
||||
|
||||
//! \~english Returns if shared memory object is empty (by size)
|
||||
//! \~russian Возвращает пустой ли объект разделяемой памяти (по размеру)
|
||||
bool isEmpty() const {return (size() <= 0);}
|
||||
|
||||
bool isEmpty() const { return (size() <= 0); }
|
||||
|
||||
//! \~english Read from shared memory to "read_to" no more than "max_size" and return readed bytes count
|
||||
//! \~russian Читает из разделяемой памяти в "read_to" не более "max_size" и возвращает количество прочитанных байт
|
||||
int read(void * read_to, int max_size);
|
||||
@@ -72,7 +71,7 @@ public:
|
||||
//! \~english Read from shared memory started from "offset" to "read_to" no more than "max_size" and return readed bytes count
|
||||
//! \~russian Читает из разделяемой памяти с начала "offset" в "read_to" не более "max_size" и возвращает количество прочитанных байт
|
||||
int read(void * read_to, int max_size, int offset);
|
||||
|
||||
|
||||
//! \~english Write to shared memory "data" with size "max_size" and return written bytes count
|
||||
//! \~russian Пишет в разделяемую память "data" размером "max_size" и возвращает количество записанных байт
|
||||
int write(const void * data, int max_size);
|
||||
@@ -83,12 +82,12 @@ public:
|
||||
|
||||
//! \~english Write "data" to shared memory
|
||||
//! \~russian Пишет в разделяемую память "data"
|
||||
int write(const PIByteArray & data) {return write(data.data(), data.size_s());}
|
||||
int write(const PIByteArray & data) { return write(data.data(), data.size_s()); }
|
||||
|
||||
//! \~english Write "data" to shared memory
|
||||
//! \~russian Пишет в разделяемую память "data"
|
||||
int write(const PIByteArray & data, int offset) {return write(data.data(), data.size_s(), offset);}
|
||||
|
||||
int write(const PIByteArray & data, int offset) { return write(data.data(), data.size_s(), offset); }
|
||||
|
||||
|
||||
protected:
|
||||
bool openDevice() override;
|
||||
@@ -97,16 +96,15 @@ protected:
|
||||
void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
PIPropertyStorage constructVariantDevice() const override;
|
||||
void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
ssize_t readDevice(void * read_to, ssize_t max_size) override {return read(read_to, max_size, 0);}
|
||||
ssize_t writeDevice(const void * data, ssize_t max_size) override {return write(data, max_size, 0);}
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
ssize_t readDevice(void * read_to, ssize_t max_size) override { return read(read_to, max_size, 0); }
|
||||
ssize_t writeDevice(const void * data, ssize_t max_size) override { return write(data, max_size, 0); }
|
||||
DeviceInfoFlags deviceInfoFlags() const override { return PIIODevice::Reliable; }
|
||||
|
||||
private:
|
||||
void initPrivate();
|
||||
|
||||
int dsize;
|
||||
PRIVATE_DECLARATION(PIP_EXPORT)
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user