00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00035 #include "streammanager.h"
00036
00037 StreamManager *StreamManager::instance = NULL;
00038
00039 void StreamManager::initInstance(InputStream * _query_istream,
00040 InputStream * _xml_istream,
00041 OutputStream * _debug_ostream,
00042 OutputStream * _eval_ostream) {
00043 instance =
00044 new StreamManager(_query_istream, _xml_istream, _debug_ostream,
00045 _eval_ostream);
00046 }
00047
00048 StreamManager *StreamManager::getInstance() {
00049 return instance;
00050 }
00051
00052 StreamManager::StreamManager(InputStream * _query_istream, InputStream * _xml_istream, OutputStream * _debug_ostream, OutputStream * _eval_ostream):
00053 query_istream(_query_istream), xml_istream(_xml_istream),
00054 debug_ostream(_debug_ostream), eval_ostream(_eval_ostream) {
00055 }
00056
00057 StreamManager::~StreamManager() {
00058 delete query_istream;
00059 delete xml_istream;
00060 delete debug_ostream;
00061 delete eval_ostream;
00062 }
00063
00064 void StreamManager::print() {
00065 (*debug_ostream) << "Query Stream ";
00066 switch (query_istream->getType()) {
00067 case it_file:
00068 (*debug_ostream) << "(Reading From FILE)";
00069 break;
00070 case it_null:
00071 (*debug_ostream) << "(Reading From NULL)";
00072 break;
00073 case it_socket:
00074 (*debug_ostream) << "(Reading From SOCKET)";
00075 break;
00076 case it_stdin:
00077 (*debug_ostream) << "(Reading From STDIN)";
00078 break;
00079 }
00080 if (query_istream->getArg()) {
00081 (*debug_ostream) << ": \"" << query_istream->getArg() << "\"";
00082 }
00083 (*debug_ostream) << NEWLINE;
00084 (*debug_ostream) << "XML Stream ";
00085 switch (xml_istream->getType()) {
00086 case it_file:
00087 (*debug_ostream) << "(Reading From FILE)";
00088 break;
00089 case it_null:
00090 (*debug_ostream) << "(Reading From NULL)";
00091 break;
00092 case it_socket:
00093 (*debug_ostream) << "(Reading From SOCKET)";
00094 break;
00095 case it_stdin:
00096 (*debug_ostream) << "(Reading From STDIN)";
00097 break;
00098 }
00099 if (xml_istream->getArg()) {
00100 (*debug_ostream) << ": \"" << xml_istream->getArg() << "\"";
00101 }
00102 (*debug_ostream) << NEWLINE;
00103 (*debug_ostream) << "Debug Stream ";
00104 switch (debug_ostream->getType()) {
00105 case ot_file:
00106 (*debug_ostream) << "(Writing To FILE)";
00107 break;
00108 case ot_null:
00109 (*debug_ostream) << "(Writing To NULL)";
00110 break;
00111 case ot_socket:
00112 (*debug_ostream) << "(Writing To SOCKET)";
00113 break;
00114 case ot_stdout:
00115 (*debug_ostream) << "(Writing To STDIN)";
00116 break;
00117 }
00118 if (debug_ostream->getArg()) {
00119 (*debug_ostream) << ": \"" << debug_ostream->getArg() << "\"";
00120 }
00121 (*debug_ostream) << NEWLINE;
00122 (*debug_ostream) << "Result Stream ";
00123 switch (eval_ostream->getType()) {
00124 case ot_file:
00125 (*debug_ostream) << "(Writing To FILE)";
00126 break;
00127 case ot_null:
00128 (*debug_ostream) << "(Writing To NULL)";
00129 break;
00130 case ot_socket:
00131 (*debug_ostream) << "(Writing To SOCKET)";
00132 break;
00133 case ot_stdout:
00134 (*debug_ostream) << "(Writing To STDIN)";
00135 break;
00136 }
00137 if (eval_ostream->getArg()) {
00138 (*debug_ostream) << ": \"" << eval_ostream->getArg() << "\"";
00139 }
00140 (*debug_ostream) << NEWLINE;
00141 }