c@118: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@118: /* c@118: Piper C++ c@118: c@118: An API for audio analysis and feature extraction plugins. c@118: c@118: Centre for Digital Music, Queen Mary, University of London. c@118: Copyright 2006-2016 Chris Cannam and QMUL. c@118: c@118: Permission is hereby granted, free of charge, to any person c@118: obtaining a copy of this software and associated documentation c@118: files (the "Software"), to deal in the Software without c@118: restriction, including without limitation the rights to use, copy, c@118: modify, merge, publish, distribute, sublicense, and/or sell copies c@118: of the Software, and to permit persons to whom the Software is c@118: furnished to do so, subject to the following conditions: c@118: c@118: The above copyright notice and this permission notice shall be c@118: included in all copies or substantial portions of the Software. c@118: c@118: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, c@118: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF c@118: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND c@118: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR c@118: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF c@118: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION c@118: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. c@118: c@118: Except as contained in this notice, the names of the Centre for c@118: Digital Music; Queen Mary, University of London; and Chris Cannam c@118: shall not be used in advertising or otherwise to promote the sale, c@118: use or other dealings in this Software without prior written c@118: authorization. c@118: */ c@90: c@90: #ifndef PIPER_SYNCHRONOUS_TRANSPORT_H c@90: #define PIPER_SYNCHRONOUS_TRANSPORT_H c@90: c@90: #include c@92: #include c@121: #include c@90: c@97: namespace piper_vamp { c@97: namespace client { c@90: c@92: class MessageCompletenessChecker // interface c@92: { c@92: public: c@146: enum State { Complete, Incomplete, Invalid }; c@146: c@92: virtual ~MessageCompletenessChecker() = default; c@146: virtual State check(const std::vector &message) const = 0; c@92: }; c@92: c@134: class LogCallback c@134: { c@134: public: c@134: virtual ~LogCallback() { } cannam@282: cannam@282: /** cannam@282: * Log a message. The logger should terminate the message cannam@282: * appropriately after logging; the caller is not expected to end cannam@282: * it with \n or similar. cannam@282: */ c@134: virtual void log(std::string) const = 0; c@134: }; c@134: c@90: class SynchronousTransport // interface c@90: { c@90: public: c@92: virtual ~SynchronousTransport() = default; c@92: c@126: /** c@126: * Set a completeness checker object. The caller retains ownership c@126: * of the checker and must ensure its lifespan outlives the transport. c@126: */ c@92: virtual void setCompletenessChecker(MessageCompletenessChecker *) = 0; c@90: c@126: /** c@126: * Make a synchronous call, passing a serialised request in the data array c@126: * of length bytes, and return the result. c@126: * c@134: * The type field is only used for logging and debug output. c@134: * c@126: * The slow flag is a hint that the recipient may take longer than usual c@126: * to process this request and so the caller may wish to be more relaxed c@126: * about idling to wait for the reply. (This shouldn't make any difference c@126: * with a sensible blocking network API, but you never know...) c@126: * c@126: * May throw ServerCrashed if the server endpoint disappeared during the c@126: * call. Throws std::logic_error if isOK() is not true at the time of c@126: * calling, so check that before you call. c@126: */ c@134: virtual std::vector call(const char *data, size_t bytes, c@134: std::string type, bool slow) = 0; c@126: c@126: /** c@126: * Check whether the transport was initialised correctly and is working. c@126: * This will return false if the endpoint could not be initialised or c@126: * the endpoint service has crashed or become unavailable. Always check c@126: * this before using call(). c@126: */ c@90: virtual bool isOK() const = 0; c@90: }; c@90: c@90: } c@94: } c@90: c@90: #endif