PIP
0.4.0_beta2
Platform-Independent Primitives
|
Complex Input/Output point. More...
Public Member Functions | |
PIConnection () | |
Constructs an empty connection. | |
PIConnection (const PIString &config, const PIString &name) | |
Constructs connection and configure it from config file "config" from section "name". | |
bool | configureFromConfig (const PIString &config, const PIString &name) |
Configure connection from config file "config" from section "name". Returns if configuration was successful. More... | |
PIString | makeConfig () const |
Returns config file section of current connection configuration. | |
PIIODevice * | addDevice (const PIString &full_path, PIIODevice::DeviceMode mode=PIIODevice::ReadWrite, bool start=false) |
Add device with full path "full_path", open mode "mode" to Device pool and connection. More... | |
bool | removeDevice (const PIString &full_path) |
Remove device with full path "full_path" from connection. More... | |
void | removeAllDevices () |
Remove all device from connection. More... | |
PIIODevice * | device (const PIString &full_path) const |
Returns device with full path "full_path" or null if there is no such device. | |
PIVector< PIIODevice * > | boundedDevices () const |
Returns all devices bounded to this connection. | |
PIPacketExtractor * | addFilter (const PIString &name, const PIString &full_path, PIPacketExtractor::SplitMode mode=PIPacketExtractor::None) |
Add filter with name "name" to device with full path "full_path". More... | |
PIPacketExtractor * | addFilter (const PIString &name, const PIIODevice *dev, PIPacketExtractor::SplitMode mode=PIPacketExtractor::None) |
Add filter with name "name" to device "dev". | |
bool | removeFilter (const PIString &name, const PIString &full_path) |
Remove from filter with name "name" device with full path "full_path". More... | |
bool | removeFilter (const PIString &name, const PIIODevice *dev) |
Remove from filter with name "name" device "dev". | |
bool | removeFilter (const PIString &name) |
Remove filter with name "name". Returns if filter was removed. | |
void | removeAllFilters () |
Remove all filters from connection. | |
PIVector< PIPacketExtractor * > | filters () const |
Returns all filters of connection. | |
PIStringList | filterNames () const |
Returns all filter names of connection. | |
PIPacketExtractor * | filter (const PIString &name) const |
Returns PIPacketExtractor * assosiated with filter "name" or null if there is no such filter. | |
PIVector< PIIODevice * > | filterBoundedDevices (const PIString &name) const |
Returns all devices bounded to filter "name". | |
bool | addChannel (const PIString &name_from, const PIString &name_to) |
Add to connection channel from "name_from" to "name_to". More... | |
bool | addChannel (const PIString &name_from, const PIIODevice *dev_to) |
Add to connection channel from "name_from" to "dev_to". | |
bool | addChannel (const PIIODevice *dev_from, const PIString &name_to) |
Add to connection channel from "dev_from" to "name_to". | |
bool | addChannel (const PIIODevice *dev_from, const PIIODevice *dev_to) |
Add to connection channel from "dev_from" to "dev_to". | |
bool | removeChannel (const PIString &name_from, const PIString &name_to) |
Remove from connection channel from "name_from" to "name_to". More... | |
bool | removeChannel (const PIString &name_from, const PIIODevice *dev_to) |
Remove from connection channel from "name_from" to "dev_to". | |
bool | removeChannel (const PIIODevice *dev_from, const PIString &name_to) |
Remove from connection channel from "dev_from" to "name_to". | |
bool | removeChannel (const PIIODevice *dev_from, const PIIODevice *dev_to) |
Remove from connection channel from "dev_from" to "dev_to". | |
bool | removeChannel (const PIString &name_from) |
Remove from connection all channels from "name_from". More... | |
bool | removeChannel (const PIIODevice *dev_from) |
Remove from connection all channels from "dev_from". | |
void | removeAllChannels () |
Remove from connection all channels. | |
PIVector< PIPair< PIString, PIString > > | channels () const |
Returns all channels of this connection as full pathes or filter names pair array (from, to) | |
void | startThreadedRead (const PIString &full_path) |
Start read thread of device with full path "full_path". | |
void | startThreadedRead (const PIIODevice *dev) |
Start read thread of device "dev". | |
void | startAllThreadedReads () |
Start read threads of all Device pool device. | |
void | stopThreadedRead (const PIString &full_path) |
Stop read thread of device with full path "full_path". | |
void | stopThreadedRead (const PIIODevice *dev) |
Stop read thread of device "dev". | |
void | stopAllThreadedReads () |
Stop read threads of all Device pool device. | |
bool | isEmpty () const |
Returns if there is no devices in this connection. | |
int | write (const PIString &full_path, const PIByteArray &data) |
Write data "data" to device with full path "full_path" and returns result of write() function of device. | |
![]() | |
PIObject (const PIString &name=PIString()) | |
Contructs PIObject with name "name". | |
PIString | name () const |
Returns object name. | |
virtual const char * | className () const |
Returns object class name. | |
bool | debug () const |
Return if debug of this object is active. | |
void | setName (const PIString &name) |
Set object name. | |
void | setDebug (bool debug) |
Set object debug active. | |
const PIMap< PIString, PIVariant > & | properties () const |
Returns properties of the object. | |
int | propertiesCount () const |
Returns properties count of the object. | |
PIVariant | property (const PIString &name) const |
Returns property with name "name". | |
void | setProperty (const PIString &name, const PIVariant &value) |
Set property with name "name" to "value". If there is no such property in object it will be added. | |
bool | isPropertyExists (const PIString &name) const |
Returns if property with name "name" exists. | |
Static Public Member Functions | |
static PIVector< PIConnection * > | allConnections () |
Returns all connections in application. | |
static PIVector< PIIODevice * > | allDevices () |
Returns all devices in Device pool. | |
![]() | |
static void | piDisconnect (PIObject *src, const PIString &sig) |
Disconnect object "src" from all connections with event name "sig". | |
static void | piDisconnect (PIObject *src) |
Disconnect object "src" from all connections, i.e. all connections where object "src" is emitter. | |
static PIObject * | findByName (const PIString &name) |
Returns PIObject* with name "name" or 0, if there is no object found. | |
Protected Member Functions | |
virtual void | dataReceived (const PIString &from, const PIByteArray &data) |
Executes on data received from device with full path "from". | |
virtual void | packetReceived (const PIString &from, const PIByteArray &data) |
Executes on packet received from filter with name "from". | |
virtual bool | filterValidateHeader (const PIString &filter_name, uchar *src, uchar *rec, int size) |
Validate header "rec" with source header "src" and size "size", executes from filter "filter_name". | |
virtual bool | filterValidateFooter (const PIString &filter_name, uchar *src, uchar *rec, int size) |
Validate footer "rec" with source footer "src" and size "size", executes from filter "filter_name". | |
virtual bool | filterValidatePayload (const PIString &filter_name, uchar *rec, int size) |
Validate payload "rec" with size "size", executes from filter "filter_name". | |
![]() | |
PIObject * | emitter () const |
Returns PIObject* which has raised an event. This value is correct only in definition of some event handler. | |
virtual void | propertyChanged (const PIString &name) |
Virtual function executes after property with name "name" has been changed. | |
Events | |
void | dataReceivedEvent (const PIString &from, const PIByteArray &data) |
Raise on data received from device with full path "from". | |
void | packetReceivedEvent (const PIString &from, const PIByteArray &data) |
Raise on packet received from filter with name "from". | |
Additional Inherited Members | |
![]() | |
#define | piCoutObj |
Macro used for conditional (piDebug and PIObject::debug()) output to PICout for subclasses of PIObject. | |
#define | PIOBJECT(name) |
you should use this macro after class declaration to use EVENT and EVENT_HANDLER and correct piCoutObj output | |
#define | EVENT_HANDLER0(ret, name) ret name() |
declare event handler "event" with name "name" and return type "ret", ret name() | |
#define | EVENT_HANDLER1(ret, name, type0, var0) ret name(type0 var0) |
declare event handler "event" with name "name" and return type "ret", ret name(type0 var0) | |
#define | EVENT_HANDLER2(ret, name, type0, var0, type1, var1) ret name(type0 var0, type1 var1) |
declare event handler "event" with name "name" and return type "ret", ret name(type0 var0, type1 var1) | |
#define | EVENT_HANDLER3(ret, name, type0, var0, type1, var1, type2, var2) ret name(type0 var0, type1 var1, type2 var2) |
declare event handler "event" with name "name" and return type "ret", ret name(type0 var0, type1 var1, type2 var2) | |
#define | EVENT_HANDLER4(ret, name, type0, var0, type1, var1, type2, var2, type3, var3) ret name(type0 var0, type1 var1, type2 var2, type3 var3) |
declare event handler "event" with name "name" and return type "ret", ret name(type0 var0, type1 var1, type2 var2, type3 var3) | |
#define | EVENT_HANDLER EVENT_HANDLER0 |
EVENT_HANDLER is synonym of EVENT_HANDLER0. | |
#define | EVENT_VHANDLER0(ret, name) virtual ret name() |
declare virtual event handler "event" with name "name" and return type "ret", virtual ret name() | |
#define | EVENT_VHANDLER1(ret, name, type0, var0) virtual ret name(type0 var0) |
declare virtual event handler "event" with name "name" and return type "ret", virtual ret name(type0 var0) | |
#define | EVENT_VHANDLER2(ret, name, type0, var0, type1, var1) virtual ret name(type0 var0, type1 var1) |
declare virtual event handler "event" with name "name" and return type "ret", virtual ret name(type0 var0, type1 var1) | |
#define | EVENT_VHANDLER3(ret, name, type0, var0, type1, var1, type2, var2) virtual ret name(type0 var0, type1 var1, type2 var2) |
declare virtual event handler "event" with name "name" and return type "ret", virtual ret name(type0 var0, type1 var1, type2 var2) | |
#define | EVENT_VHANDLER4(ret, name, type0, var0, type1, var1, type2, var2, type3, var3) virtual ret name(type0 var0, type1 var1, type2 var2, type3 var3) |
declare virtual event handler "event" with name "name" and return type "ret", virtual ret name(type0 var0, type1 var1, type2 var2, type3 var3) | |
#define | EVENT_VHANDLER EVENT_VHANDLER0 |
EVENT_VHANDLER is synonym of EVENT_VHANDLER0. | |
#define | EVENT0(name) void name(); |
declare event "event" with name "name", void name(); | |
#define | EVENT1(name, type0, var0) void name(type0 var0); |
declare event "event" with name "name", void name(type0 var0); | |
#define | EVENT2(name, type0, var0, type1, var1) void name(type0 var0, type1 var1); |
declare event "event" with name "name", void name(type0 var0, type1 var1); | |
#define | EVENT3(name, type0, var0, type1, var1, type2, var2) void name(type0 var0, type1 var1, type2 var2); |
declare event "event" with name "name", void name(type0 var0, type1 var1, type2 var2); | |
#define | EVENT4(name, type0, var0, type1, var1, type2, var2, type3, var3) void name(type0 var0, type1 var1, type2 var2, type3 var3); |
declare event "event" with name "name", void name(type0 var0, type1 var1, type2 var2, type3 var3); | |
#define | EVENT EVENT0 |
EVENT is synonym of EVENT0. | |
#define | CONNECT0(ret, src, event, dest, handler) |
connect event "event" from object "src" to event handler "handler" with return type "ret" from object "dest" with check of event and handler exists | |
#define | CONNECT1(ret, type0, src, event, dest, handler) |
connect event "event" from object "src" to event handler "handler" with return type "ret" from object "dest" with check of event and handler exists | |
#define | CONNECT2(ret, type0, type1, src, event, dest, handler) |
connect event "event" from object "src" to event handler "handler" with return type "ret" from object "dest" with check of event and handler exists | |
#define | CONNECT3(ret, type0, type1, type2, src, event, dest, handler) |
connect event "event" from object "src" to event handler "handler" with return type "ret" from object "dest" with check of event and handler exists | |
#define | CONNECT4(ret, type0, type1, type2, type3, src, event, dest, handler) |
connect event "event" from object "src" to event handler "handler" with return type "ret" from object "dest" with check of event and handler exists | |
#define | CONNECT CONNECT0 |
CONNECT is synonym of CONNECT0. | |
#define | WEAK_CONNECT0(ret, src, event, dest, handler) |
connect event "event" from object "src" to event handler "handler" with return type "ret" from object "dest" without check of event exists | |
#define | WEAK_CONNECT1(ret, type0, src, event, dest, handler) |
connect event "event" from object "src" to event handler "handler" with return type "ret" from object "dest" without check of event exists | |
#define | WEAK_CONNECT2(ret, type0, type1, src, event, dest, handler) |
connect event "event" from object "src" to event handler "handler" with return type "ret" from object "dest" without check of event exists | |
#define | WEAK_CONNECT3(ret, type0, type1, type2, src, event, dest, handler) |
connect event "event" from object "src" to event handler "handler" with return type "ret" from object "dest" without check of event exists | |
#define | WEAK_CONNECT4(ret, type0, type1, type2, type3, src, event, dest, handler) |
connect event "event" from object "src" to event handler "handler" with return type "ret" from object "dest" without check of event exists | |
#define | WEAK_CONNECT WEAK_CONNECT0 |
WEAK_CONNECT is synonym of WEAK_CONNECT0. | |
#define | DISCONNECT0(ret, src, event, dest, handler) |
piDisconnect event "event" from object "src" from event handler "handler" with return type "ret" from object "dest" | |
#define | DISCONNECT1(ret, type0, src, event, dest, handler) |
piDisconnect event "event" from object "src" from event handler "handler" with return type "ret" from object "dest" | |
#define | DISCONNECT2(ret, type0, type1, src, event, dest, handler) |
piDisconnect event "event" from object "src" from event handler "handler" with return type "ret" from object "dest" | |
#define | DISCONNECT3(ret, type0, type1, type2, src, event, dest, handler) |
piDisconnect event "event" from object "src" from event handler "handler" with return type "ret" from object "dest" | |
#define | DISCONNECT4(ret, type0, type1, type2, type3, src, event, dest, handler) |
piDisconnect event "event" from object "src" from event handler "handler" with return type "ret" from object "dest" | |
#define | DISCONNECT DISCONNECT0 |
DISCONNECT is synonym of DISCONNECT0. | |
#define | HANDLER(handler) |
Returns pointer to events handler "handler". | |
Complex Input/Output point.
PIConnection provides abstract layer over physical devices, filtering and connecting data streams. Each PIConnection works through Device Pool, so several PIConnections can read from single physical device. General scheme:
Device pool is static object, single for each application, which contains unique devices. Each PIConnection works with real devices through Device pool. Each device has assosiated thread for read and it can be started or stopped with PIConnection functions startThreadedRead() and stopThreadedRead().
You can create PIConnection from config file section or configure it later with function configureFromConfig(). Devices describes with its full pathes, for details see Creating devices by unambiguous string. Example:
Configure connection from config file "config" from section "name". Returns if configuration was successful.
Warning: all devices, filters and channels removed before configure!
PIIODevice * PIConnection::addDevice | ( | const PIString & | full_path, |
PIIODevice::DeviceMode | mode = PIIODevice::ReadWrite , |
||
bool | start = false |
||
) |
Add device with full path "full_path", open mode "mode" to Device pool and connection.
Returns pointer to device or null if device can not be created. If "start" is true, read thread is started immediately. Else, you can start read thread with functions startThreadedRead() or startAllThreadedReads(). By default, read thread doesn`t start
bool PIConnection::removeDevice | ( | const PIString & | full_path | ) |
Remove device with full path "full_path" from connection.
Returns if device was removed. If there is no connection bounded to this device, it will be removed from Device pool
void PIConnection::removeAllDevices | ( | ) |
Remove all device from connection.
If there is no connection bounded to there devices, they removed from Device pool
PIPacketExtractor * PIConnection::addFilter | ( | const PIString & | name, |
const PIString & | full_path, | ||
PIPacketExtractor::SplitMode | mode = PIPacketExtractor::None |
||
) |
Add filter with name "name" to device with full path "full_path".
If there is no filter with name "name", connection create new with split mode "mode" and bound to it device "full_path". If filter with name "name" already exists, device "full_path" add to this filter. Attention! "mode" is altual olny if new filter was created! This function returns PIPacketExtractor * assosiated with this filter
Remove from filter with name "name" device with full path "full_path".
If there is no devices bounded to this filter, it will be removed. Returns if device was removed
Add to connection channel from "name_from" to "name_to".
"name_from" and "name_to" can be full pathes of devices or filter names. Returns false if there if no such device or filter, else create channel and returns true
Remove from connection channel from "name_from" to "name_to".
"name_from" and "name_to" can be full pathes of devices or filter names. Returns false if there if no such device or filter, else remove channel and returns true
bool PIConnection::removeChannel | ( | const PIString & | name_from | ) |
Remove from connection all channels from "name_from".
"name_from" can be full path of device or filter name. Returns false if there if no such device or filter, else remove channels and returns true