git-svn-id: svn://db.shs.com.ru/pip@673 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "piiodevice.h"
|
||||
#include "piconfig.h"
|
||||
#include "piconnection.h"
|
||||
#include "pipropertystorage.h"
|
||||
|
||||
|
||||
/*! \class PIIODevice
|
||||
@@ -199,6 +200,18 @@ void PIIODevice::write_func() {
|
||||
}
|
||||
|
||||
|
||||
PIIODevice * PIIODevice::newDeviceByPrefix(const PIString & prefix) {
|
||||
if (prefix.isEmpty()) return 0;
|
||||
PIVector<const PIObject * > rd(PICollection::groupElements("__PIIODevices__"));
|
||||
piForeachC (PIObject * d, rd) {
|
||||
if (prefix == ((const PIIODevice * )d)->fullPathPrefix()) {
|
||||
return ((const PIIODevice * )d)->copy();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void PIIODevice::terminate() {
|
||||
timer.stop();
|
||||
thread_started_ = false;
|
||||
@@ -321,6 +334,23 @@ void PIIODevice::configureFromFullPath(const PIString & full_path) {
|
||||
}
|
||||
|
||||
|
||||
PIVariantTypes::IODevice PIIODevice::constructVariant() const {
|
||||
PIVariantTypes::IODevice ret;
|
||||
ret.prefix = fullPathPrefix();
|
||||
ret.mode = mode();
|
||||
ret.options = options();
|
||||
ret.set(constructVariantDevice());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void PIIODevice::configureFromVariant(const PIVariantTypes::IODevice & d) {
|
||||
setMode((DeviceMode)d.mode);
|
||||
setOptions((DeviceOptions)d.options);
|
||||
configureFromVariantDevice(d.get());
|
||||
}
|
||||
|
||||
|
||||
void PIIODevice::splitFullPath(PIString fpwm, PIString * full_path, DeviceMode * mode, DeviceOptions * opts) {
|
||||
int dm = 0;
|
||||
DeviceOptions op = 0;
|
||||
@@ -363,17 +393,19 @@ PIString PIIODevice::fullPathOptions() const {
|
||||
|
||||
PIIODevice * PIIODevice::createFromFullPath(const PIString & full_path) {
|
||||
PIString prefix = full_path.left(full_path.find(":"));
|
||||
if (prefix.isEmpty()) return 0;
|
||||
PIVector<const PIObject * > rd(PICollection::groupElements("__PIIODevices__"));
|
||||
piForeachC (PIObject * d, rd) {
|
||||
if (prefix == ((const PIIODevice * )d)->fullPathPrefix()) {
|
||||
PIIODevice * nd = ((const PIIODevice * )d)->copy();
|
||||
if (nd) nd->configureFromFullPath(full_path.mid(prefix.length() + 3));
|
||||
cacheFullPath(full_path, nd);
|
||||
return nd;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
PIIODevice * nd = newDeviceByPrefix(prefix);
|
||||
if (!nd) return 0;
|
||||
nd->configureFromFullPath(full_path.mid(prefix.length() + 3));
|
||||
cacheFullPath(full_path, nd);
|
||||
return nd;
|
||||
}
|
||||
|
||||
|
||||
PIIODevice * PIIODevice::createFromVariant(const PIVariantTypes::IODevice & d) {
|
||||
PIIODevice * nd = newDeviceByPrefix(d.prefix);
|
||||
if (!nd) return 0;
|
||||
nd->configureFromVariant(d);
|
||||
return nd;
|
||||
}
|
||||
|
||||
|
||||
@@ -405,3 +437,15 @@ bool PIIODevice::threadedRead(uchar *readed, int size) {
|
||||
if (ret_func_ != 0) return ret_func_(ret_data_, readed, size);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
PIPropertyStorage PIIODevice::constructVariantDevice() const {
|
||||
PIPropertyStorage ret;
|
||||
ret.addProperty("path", path());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void PIIODevice::configureFromVariantDevice(const PIPropertyStorage & d) {
|
||||
setPath(d.propertyValueByName("path").toString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user