diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch) | |
tree | 9047cf9e6b5c43878d5bf82660adae77ceee097a /mpeglib/example/yaf/yafcore/outputInterface.cpp | |
download | tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'mpeglib/example/yaf/yafcore/outputInterface.cpp')
-rw-r--r-- | mpeglib/example/yaf/yafcore/outputInterface.cpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/mpeglib/example/yaf/yafcore/outputInterface.cpp b/mpeglib/example/yaf/yafcore/outputInterface.cpp new file mode 100644 index 00000000..b57563fd --- /dev/null +++ b/mpeglib/example/yaf/yafcore/outputInterface.cpp @@ -0,0 +1,85 @@ +/* + This class sends an output to the outputstream + Copyright (C) 1998 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + + +#include "outputInterface.h" +#include <iostream> + +using namespace std; + +OutputInterface::OutputInterface(ostream* out) { + protocolSyntax=false; + this->out=out; + outBuffer=new Buffer(250); + setlinebuf(stdout); + pthread_mutex_init(&writeOutMut,NULL); +} + + +OutputInterface::~OutputInterface() { + delete outBuffer; +} + +void OutputInterface::flushBuffer() { + if (protocolSyntax) { + (*out) << outBuffer->getData() << endl; +#ifdef _DEBUG_OUTPUT + ofstream outfile("outstream.dbg",ios::app); + outfile << outBuffer->getData() << endl; + outfile.flush(); + outfile.close(); +#endif + return; + } else { + (*out) << "Command:" << nr << " Msg:" << outBuffer->getData() << endl; +#ifdef _DEBUG_OUTPUT + ofstream outfile("outstream.dbg",ios::app); + outfile << "Command:" << nr << " Msg:" << outBuffer->getData() << endl; + outfile.flush(); + outfile.close(); +#endif + } + fflush(NULL); +} + + + +void OutputInterface::setProtocolSyntax(int proto) { + protocolSyntax=proto; +} + + +void OutputInterface::setNr(int nr) { + this->nr=nr; +} + +void OutputInterface::clearBuffer() { + outBuffer->clear(); +} + + +void OutputInterface::appendBuffer(const char* msg) { + outBuffer->append(msg); +} + + + +void OutputInterface::lock() { + pthread_mutex_lock(&writeOutMut); +} + + +void OutputInterface::unlock() { + pthread_mutex_unlock(&writeOutMut); +} + |