save name/address of bus interface
This commit is contained in:
@ -17,6 +17,7 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include "StreamBusInterface.h"
|
#include "StreamBusInterface.h"
|
||||||
#include "StreamError.h"
|
#include "StreamError.h"
|
||||||
|
|
||||||
@ -68,7 +69,20 @@ find(Client* client, const char* busname, int addr, const char* param)
|
|||||||
bus = r->find(client, busname, addr, param);
|
bus = r->find(client, busname, addr, param);
|
||||||
debug("StreamBusInterface::find %s %s\n",
|
debug("StreamBusInterface::find %s %s\n",
|
||||||
r->name, bus ? "matches" : "does not match");
|
r->name, bus ? "matches" : "does not match");
|
||||||
if (bus) return bus;
|
if (bus)
|
||||||
|
{
|
||||||
|
if (addr >= 0)
|
||||||
|
{
|
||||||
|
bus->_name = new char[strlen(busname) + sizeof(int)*2 + sizeof(int)/2 + 2];
|
||||||
|
sprintf(bus->_name, "%s %d", busname, addr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bus->_name = new char[strlen(busname) + 1];
|
||||||
|
strcpy(bus->_name, busname);
|
||||||
|
}
|
||||||
|
return bus;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,9 @@ public:
|
|||||||
|
|
||||||
class Client
|
class Client
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
friend class StreamBusInterface;
|
friend class StreamBusInterface;
|
||||||
|
|
||||||
virtual void lockCallback(StreamIoStatus status) = 0;
|
virtual void lockCallback(StreamIoStatus status) = 0;
|
||||||
virtual void writeCallback(StreamIoStatus status);
|
virtual void writeCallback(StreamIoStatus status);
|
||||||
virtual ssize_t readCallback(StreamIoStatus status,
|
virtual ssize_t readCallback(StreamIoStatus status,
|
||||||
@ -96,27 +98,29 @@ public:
|
|||||||
private:
|
private:
|
||||||
friend class StreamBusInterfaceClass; // the iterator
|
friend class StreamBusInterfaceClass; // the iterator
|
||||||
friend class Client;
|
friend class Client;
|
||||||
|
char* _name;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Client* client;
|
Client* client;
|
||||||
virtual ~StreamBusInterface() {};
|
virtual ~StreamBusInterface() {};
|
||||||
|
const char* name() { return _name; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
StreamBusInterface(Client* client);
|
StreamBusInterface(Client* client);
|
||||||
|
|
||||||
// map client functions into StreamBusInterface namespace
|
// map client functions into StreamBusInterface namespace
|
||||||
void lockCallback(StreamIoStatus status)
|
void lockCallback(StreamIoStatus status = StreamIoSuccess)
|
||||||
{ client->lockCallback(status); }
|
{ client->lockCallback(status); }
|
||||||
void writeCallback(StreamIoStatus status)
|
void writeCallback(StreamIoStatus status = StreamIoSuccess)
|
||||||
{ client->writeCallback(status); }
|
{ client->writeCallback(status); }
|
||||||
ssize_t readCallback(StreamIoStatus status,
|
ssize_t readCallback(StreamIoStatus status,
|
||||||
const void* input = NULL, size_t size = 0)
|
const void* input = NULL, size_t size = 0)
|
||||||
{ return client->readCallback(status, input, size); }
|
{ return client->readCallback(status, input, size); }
|
||||||
void eventCallback(StreamIoStatus status)
|
void eventCallback(StreamIoStatus status = StreamIoSuccess)
|
||||||
{ client->eventCallback(status); }
|
{ client->eventCallback(status); }
|
||||||
void connectCallback(StreamIoStatus status)
|
void connectCallback(StreamIoStatus status = StreamIoSuccess)
|
||||||
{ client->connectCallback(status); }
|
{ client->connectCallback(status); }
|
||||||
void disconnectCallback(StreamIoStatus status)
|
void disconnectCallback(StreamIoStatus status = StreamIoSuccess)
|
||||||
{ client->disconnectCallback(status); }
|
{ client->disconnectCallback(status); }
|
||||||
const char* getInTerminator(size_t& length)
|
const char* getInTerminator(size_t& length)
|
||||||
{ return client->getInTerminator(length); }
|
{ return client->getInTerminator(length); }
|
||||||
|
Reference in New Issue
Block a user