diff --git a/src/StreamBusInterface.cc b/src/StreamBusInterface.cc index 2eb041a..d7789fb 100644 --- a/src/StreamBusInterface.cc +++ b/src/StreamBusInterface.cc @@ -17,6 +17,7 @@ * * ***************************************************************/ +#include #include "StreamBusInterface.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); debug("StreamBusInterface::find %s %s\n", 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; } diff --git a/src/StreamBusInterface.h b/src/StreamBusInterface.h index ce57096..888d381 100644 --- a/src/StreamBusInterface.h +++ b/src/StreamBusInterface.h @@ -34,7 +34,9 @@ public: class Client { + private: friend class StreamBusInterface; + virtual void lockCallback(StreamIoStatus status) = 0; virtual void writeCallback(StreamIoStatus status); virtual ssize_t readCallback(StreamIoStatus status, @@ -96,27 +98,29 @@ public: private: friend class StreamBusInterfaceClass; // the iterator friend class Client; + char* _name; public: Client* client; virtual ~StreamBusInterface() {}; + const char* name() { return _name; } protected: StreamBusInterface(Client* client); // map client functions into StreamBusInterface namespace - void lockCallback(StreamIoStatus status) + void lockCallback(StreamIoStatus status = StreamIoSuccess) { client->lockCallback(status); } - void writeCallback(StreamIoStatus status) + void writeCallback(StreamIoStatus status = StreamIoSuccess) { client->writeCallback(status); } ssize_t readCallback(StreamIoStatus status, const void* input = NULL, size_t size = 0) { return client->readCallback(status, input, size); } - void eventCallback(StreamIoStatus status) + void eventCallback(StreamIoStatus status = StreamIoSuccess) { client->eventCallback(status); } - void connectCallback(StreamIoStatus status) + void connectCallback(StreamIoStatus status = StreamIoSuccess) { client->connectCallback(status); } - void disconnectCallback(StreamIoStatus status) + void disconnectCallback(StreamIoStatus status = StreamIoSuccess) { client->disconnectCallback(status); } const char* getInTerminator(size_t& length) { return client->getInTerminator(length); }