diff --git a/src_main/io/pibinarylog.h b/src_main/io/pibinarylog.h index f000044c..d8b47b66 100644 --- a/src_main/io/pibinarylog.h +++ b/src_main/io/pibinarylog.h @@ -282,6 +282,7 @@ protected: bool closeDevice(); void propertyChanged(const PIString &); bool threadedRead(uchar *readed, int size); + DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Reliable;} private: struct BinLogRecord { diff --git a/src_main/io/piethernet.cpp b/src_main/io/piethernet.cpp index b02dce1c..d3a192e8 100755 --- a/src_main/io/piethernet.cpp +++ b/src_main/io/piethernet.cpp @@ -790,6 +790,18 @@ int PIEthernet::writeDevice(const void * data, int max_size) { } +PIIODevice::DeviceInfoFlags PIEthernet::deviceInfoFlags() const { + switch (type()) { + case UDP: return 0; + case TCP_Client: + case TCP_Server: + case TCP_SingleTCP: return Sequential | Reliable; + default: break; + } + return 0; +} + + void PIEthernet::clientDeleted() { clients_mutex.lock(); clients_.removeOne((PIEthernet*)emitter()); diff --git a/src_main/io/piethernet.h b/src_main/io/piethernet.h index 31c1e34e..7f1974c0 100755 --- a/src_main/io/piethernet.h +++ b/src_main/io/piethernet.h @@ -467,6 +467,7 @@ protected: bool configureDevice(const void * e_main, const void * e_parent = 0); int readDevice(void * read_to, int max_size); int writeDevice(const void * data, int max_size); + DeviceInfoFlags deviceInfoFlags() const; //! Executes when any read function was successful. Default implementation does nothing virtual void received(const void * data, int size) {;} diff --git a/src_main/io/pifile.h b/src_main/io/pifile.h index 93b698f4..db23f15c 100755 --- a/src_main/io/pifile.h +++ b/src_main/io/pifile.h @@ -293,6 +293,7 @@ protected: int writeDevice(const void * data, int max_size); bool openDevice(); bool closeDevice(); + DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Sequential | PIIODevice::Reliable;} private: PIString strType(const PIIODevice::DeviceMode type); diff --git a/src_main/io/piiobytearray.h b/src_main/io/piiobytearray.h index 2b9f241c..d6dfcd6b 100644 --- a/src_main/io/piiobytearray.h +++ b/src_main/io/piiobytearray.h @@ -72,6 +72,7 @@ protected: bool openDevice(); int readDevice(void * read_to, int size); int writeDevice(const void * data_, int size); + DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Sequential | PIIODevice::Reliable;} ssize_t pos; PIByteArray * data_; diff --git a/src_main/io/piiodevice.h b/src_main/io/piiodevice.h index 958d8831..4267a073 100755 --- a/src_main/io/piiodevice.h +++ b/src_main/io/piiodevice.h @@ -69,7 +69,14 @@ public: BlockingWrite /*! \a write block until data is sent, default off */ = 0x02 }; + //! \brief Characteristics of PIIODevice subclass + enum DeviceInfoFlag { + Sequential /*! Continuous channel */ = 0x01, + Reliable /*! Channel is safe */ = 0x02 + }; + typedef PIFlags DeviceOptions; + typedef PIFlags DeviceInfoFlags; explicit PIIODevice(const PIString & path, DeviceMode mode = ReadWrite); virtual ~PIIODevice(); @@ -92,6 +99,9 @@ public: //! Set device option "o" to "yes" and return previous state bool setOption(DeviceOption o, bool yes = true); + //! Returns device characteristic flags + DeviceInfoFlags infoFlags() const {return deviceInfoFlags();} + //! Current path of device PIString path() const {return property(PIStringAscii("path")).toString();} @@ -336,6 +346,9 @@ protected: //! Reimplement to apply new device options virtual void optionsChanged() {;} + //! Reimplement to return correct \a DeviceInfoFlags. Default implementation returns 0 + virtual DeviceInfoFlags deviceInfoFlags() const {return 0;} + //! Reimplement to apply new \a threadedReadBufferSize() virtual void threadedReadBufferSizeChanged() {;} diff --git a/src_main/io/piiostring.h b/src_main/io/piiostring.h index 091880d0..3843b3d8 100644 --- a/src_main/io/piiostring.h +++ b/src_main/io/piiostring.h @@ -75,6 +75,7 @@ protected: bool openDevice(); int readDevice(void * read_to, int max_size); int writeDevice(const void * data, int max_size); + DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Sequential | PIIODevice::Reliable;} ssize_t pos; PIString * str; diff --git a/src_main/io/pipacketextractor.h b/src_main/io/pipacketextractor.h index c0f00471..c8e04339 100755 --- a/src_main/io/pipacketextractor.h +++ b/src_main/io/pipacketextractor.h @@ -159,6 +159,7 @@ private: PIString fullPathPrefix() const {return PIStringAscii("pckext");} PIString constructFullPathDevice() const; bool openDevice() {if (dev == 0) return false; return dev->open();} + DeviceInfoFlags deviceInfoFlags() const {if (dev) return dev->infoFlags(); return 0;} PIIODevice * dev; PIByteArray buffer, tmpbuf, src_header, src_footer, trbuf; diff --git a/src_main/io/pipeer.h b/src_main/io/pipeer.h index 673f86c4..09376472 100755 --- a/src_main/io/pipeer.h +++ b/src_main/io/pipeer.h @@ -171,7 +171,7 @@ private: void configureFromFullPathDevice(const PIString &full_path); int readDevice(void * read_to, int max_size); int writeDevice(const void * data, int size); - + DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Reliable;} PeerInfo * quickestPeer(const PIString & to); bool sendToNeighbour(PeerInfo * peer, const PIByteArray & ba); diff --git a/src_main/io/piserial.h b/src_main/io/piserial.h index 175e0a2f..f7628047 100755 --- a/src_main/io/piserial.h +++ b/src_main/io/piserial.h @@ -208,7 +208,8 @@ protected: void threadedReadBufferSizeChanged(); int readDevice(void * read_to, int max_size); int writeDevice(const void * data, int max_size); - + DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Sequential;} + //! Executes when any read function was successful. Default implementation does nothing virtual void received(const void * data, int size) {;} diff --git a/src_main/io/pisharedmemory.h b/src_main/io/pisharedmemory.h index 8762cc0a..2dec679d 100644 --- a/src_main/io/pisharedmemory.h +++ b/src_main/io/pisharedmemory.h @@ -78,6 +78,7 @@ protected: void configureFromFullPathDevice(const PIString & full_path); int readDevice(void * read_to, int max_size) {return read(read_to, max_size, 0);} int writeDevice(const void * data, int max_size) {return write(data, max_size, 0);} + DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Reliable;} private: void initPrivate(); diff --git a/src_main/io/pitransparentdevice.h b/src_main/io/pitransparentdevice.h index 1d6fa894..e7d9db09 100644 --- a/src_main/io/pitransparentdevice.h +++ b/src_main/io/pitransparentdevice.h @@ -42,6 +42,7 @@ protected: int readDevice(void * read_to, int max_size); int writeDevice(const void * data, int max_size); PIString fullPathPrefix() const {return PIStringAscii("tr");} + DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Reliable;} PIMutex que_mutex; PIQueue que; diff --git a/src_main/io/piusb.h b/src_main/io/piusb.h index 31ece53e..3d4749e7 100755 --- a/src_main/io/piusb.h +++ b/src_main/io/piusb.h @@ -135,6 +135,7 @@ protected: //bool init(); bool openDevice(); bool closeDevice(); + DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Reliable;} PIVector eps; ushort vid_, pid_; diff --git a/src_main/piversion.h b/src_main/piversion.h index 60571897..86cb7985 100644 --- a/src_main/piversion.h +++ b/src_main/piversion.h @@ -3,8 +3,8 @@ #define PIVERSION_H #define PIP_VERSION_MAJOR 1 -#define PIP_VERSION_MINOR 3 +#define PIP_VERSION_MINOR 4 #define PIP_VERSION_REVISION 0 -#define PIP_VERSION_SUFFIX "_alpha" +#define PIP_VERSION_SUFFIX "" #endif // PIVERSION_H