summaryrefslogtreecommitdiff
path: root/orkbasecxx/TapeProcessor.cpp
diff options
context:
space:
mode:
authorHenri Herscher <henri@oreka.org>2006-07-05 01:59:32 +0000
committerHenri Herscher <henri@oreka.org>2006-07-05 01:59:32 +0000
commitc27745d1b387606b7e1a5869b7fe4b566410720d (patch)
tree978a3e5176ff6db2f6b0856d8031e662b68ff03d /orkbasecxx/TapeProcessor.cpp
parent0d758fbcf5a581ca5909245cef65c00652219283 (diff)
* Tape processor interface becomes usable and used
* Reporting and BatchProcessing become "standard" tape processors * Imediate processing kicks off the tape processor chain * Object now references Serializer * ConfigManager singleton not an ACE singleton anymore because ACE singletons are not unique across DLL boundaries. git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@296 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkbasecxx/TapeProcessor.cpp')
-rw-r--r--orkbasecxx/TapeProcessor.cpp120
1 files changed, 120 insertions, 0 deletions
diff --git a/orkbasecxx/TapeProcessor.cpp b/orkbasecxx/TapeProcessor.cpp
new file mode 100644
index 0000000..a3d055b
--- /dev/null
+++ b/orkbasecxx/TapeProcessor.cpp
@@ -0,0 +1,120 @@
+/*
+ * Oreka -- A media capture and retrieval platform
+ *
+ * Copyright (C) 2005, orecx LLC
+ *
+ * http://www.orecx.com
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ * Please refer to http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#pragma warning( disable: 4786 )
+
+#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+
+#include <log4cxx/logger.h>
+#include "TapeProcessor.h"
+#include "ConfigManager.h"
+
+using namespace log4cxx;
+
+TapeProcessor::TapeProcessor()
+{
+ ;
+}
+
+void TapeProcessor::SetNextProcessor(TapeProcessorRef& nextProcessor)
+{
+ m_nextProcessor = nextProcessor;
+}
+
+void TapeProcessor::RunNextProcessor(AudioTapeRef& tape)
+{
+ if(m_nextProcessor.get())
+ {
+ m_nextProcessor->AddAudioTape(tape);
+ }
+}
+
+
+//=====================================================
+LoggerPtr s_log;
+
+TapeProcessorRegistry::TapeProcessorRegistry()
+{
+ s_log = Logger::getLogger("tape.taperegistry");
+}
+
+
+void TapeProcessorRegistry::RegisterTapeProcessor(TapeProcessorRef& tapeProcessor)
+{
+ m_TapeProcessors.push_back(tapeProcessor);
+ LOG4CXX_INFO(s_log, CStdString("Registered processor: ") + tapeProcessor->GetName());
+}
+
+
+TapeProcessorRef TapeProcessorRegistry::GetNewTapeProcessor(CStdString& TapeProcessorName)
+{
+ for(std::list<TapeProcessorRef>::iterator it = m_TapeProcessors.begin(); it!=m_TapeProcessors.end(); it++)
+ {
+ TapeProcessorRef TapeProcessor = *it;
+
+ if( TapeProcessor->GetName().CompareNoCase(TapeProcessorName) == 0 )
+ {
+ return TapeProcessor->Instanciate();
+ }
+ }
+ return TapeProcessorRef(); // No TapeProcessor found
+}
+
+TapeProcessorRegistry* TapeProcessorRegistry::m_singleton = 0;
+
+TapeProcessorRegistry* TapeProcessorRegistry::instance()
+{
+ if(m_singleton == NULL)
+ {
+ m_singleton = new TapeProcessorRegistry();
+ }
+ return m_singleton;
+}
+
+void TapeProcessorRegistry::CreateProcessingChain()
+{
+ TapeProcessorRef previousProcessor;
+
+ //ConfigManager* cm = ConfigManagerSingleton::instance();
+
+ for(std::list<CStdString>::iterator it = CONFIG.m_tapeProcessors.begin(); it != CONFIG.m_tapeProcessors.end(); it++)
+ {
+ CStdString tapeProcessorName = *it;
+ TapeProcessorRef processor = GetNewTapeProcessor(tapeProcessorName);
+ if(processor.get())
+ {
+ if(m_firstTapeProcessor.get() == NULL)
+ {
+ m_firstTapeProcessor = processor;
+ }
+ if(previousProcessor.get())
+ {
+ previousProcessor->SetNextProcessor(processor);
+ }
+ previousProcessor = processor;
+ LOG4CXX_DEBUG(s_log, CStdString("Adding processor to chain:") + tapeProcessorName);
+ }
+ else
+ {
+ LOG4CXX_ERROR(s_log, CStdString("Processor:") + tapeProcessorName + " does not exist, please check <TapeProcessors> in config.xml");
+ }
+ }
+}
+
+void TapeProcessorRegistry::RunProcessingChain(AudioTapeRef& tape)
+{
+ if(m_firstTapeProcessor.get())
+ {
+ m_firstTapeProcessor->AddAudioTape(tape);
+ }
+}