00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "EventDisplayBase/IoModule.h"
00010 extern "C" {
00011 #include <unistd.h>
00012 }
00013 #include <iostream>
00014 #include <string>
00015 #include <cstdio>
00016 #include "TGMsgBox.h"
00017 #include "EventDataModel/Event.h"
00018 #include "EventDisplayBase/evdb.h"
00019 #include "EventDisplayBase/AutoAdvance.h"
00020 #include "EventDisplayBase/JobInterface.h"
00021 #include "IoModules/ReadWriteModule.h"
00022 #include "IoModules/Filter.h"
00023 using namespace evdb;
00024
00025 AutoAdvance* gsAutoAdvance = 0;
00026
00027
00028
00029 void IoModule::StartAutoAdvance()
00030 {
00031 if (gsAutoAdvance==0) gsAutoAdvance = new AutoAdvance();
00032 }
00033
00034
00035
00036 void IoModule::StopAutoAdvance()
00037 {
00038 if (gsAutoAdvance==0) return;
00039 delete gsAutoAdvance;
00040 gsAutoAdvance = 0;
00041 }
00042
00043
00044
00045 io::ReadWriteModule& IoModule::IoMod() { return *fIoMod; }
00046
00047
00048
00049 IoModule* IoModule::Instance()
00050 {
00051 static IoModule* iom = 0;
00052 if (iom==0) iom = new IoModule();
00053 return iom;
00054 }
00055
00056
00057
00058 IoModule::IoModule()
00059 {
00060 fIoMod = new io::ReadWriteModule();
00061 }
00062
00063
00064
00065 IoModule::~IoModule() { }
00066
00067
00068
00069 int IoModule::AddFile(const char* file_regexp)
00070 {
00071 int n = 0;
00072 if (file_regexp) n = fIoMod->AddFile(file_regexp);
00073 if (n==0) {
00074 std::string s;
00075 s += "Add: No files matching '";
00076 if (file_regexp) s += file_regexp;
00077 else s += "0x0";
00078 s += "' openned.";
00079 this->Warn(s.c_str());
00080 }
00081 fIoMod->Report();
00082
00083 return n;
00084 }
00085
00086
00087
00088 int IoModule::RemoveFile(const char* file_regexp)
00089 {
00090 int n = fIoMod->RemoveFile(file_regexp);
00091 if (n==0) {
00092 std::string s;
00093 s += "Remove: No files match '";
00094 s += file_regexp;
00095 s += "'.";
00096 this->Warn(s.c_str());
00097 }
00098 return n;
00099 }
00100
00101
00102
00103 int IoModule::GoToFile(const char* file)
00104 {
00105 int istat = fIoMod->GoToFile(file);
00106 JobInterface::ProcEvent(this->GetEvent());
00107 this->NewEvent();
00108 return istat;
00109 }
00110
00111
00112
00113 int IoModule::AdvanceFile(int n)
00114 {
00115 int istat = fIoMod->AdvanceFile(n);
00116 JobInterface::ProcEvent(this->GetEvent());
00117 this->NewEvent();
00118 return istat;
00119 }
00120
00121
00122
00123 int IoModule::RewindFile(int n)
00124 {
00125 int istat = fIoMod->RewindFile(n);
00126 JobInterface::ProcEvent(this->GetEvent());
00127 this->NewEvent();
00128 return istat;
00129 }
00130
00131
00132
00133 int IoModule::GoTo(int run, int event)
00134 {
00135 int istat = fIoMod->GoTo(run,event);
00136 JobInterface::ProcEvent(this->GetEvent());
00137 this->NewEvent();
00138 return istat;
00139 }
00140
00141
00142
00143 int IoModule::Advance(int n)
00144 {
00145 int istat = fIoMod->Advance(n);
00146 JobInterface::ProcEvent(this->GetEvent());
00147 this->NewEvent();
00148 return istat;
00149 }
00150
00151
00152
00153 int IoModule::Rewind(int n)
00154 {
00155 int istat = fIoMod->Rewind(n);
00156 JobInterface::ProcEvent(this->GetEvent());
00157 this->NewEvent();
00158 return istat;
00159 }
00160
00161
00162
00163 int IoModule::Reload()
00164 {
00165 int istat = fIoMod->Reload();
00166 JobInterface::ProcEvent(this->GetEvent());
00167 this->NewEvent();
00168 return istat;
00169 }
00170
00171
00172
00173 void IoModule::SetOutputFileName(const char* n)
00174 {
00175 fIoMod->SetOutputFileName(n);
00176 }
00177
00178
00179
00180 edm::EventHandle& IoModule::GetEvent()
00181 {
00182 return fIoMod->GetEvent();
00183 }
00184
00185
00186
00187 int IoModule::WriteEvent()
00188 {
00189 int istat = fIoMod->WriteEvent();
00190 if (istat == 0) {
00191 this->Warn("Write failed.\n");
00192 }
00193 return istat;
00194 }
00195
00196
00197
00198 const char* IoModule::CurrentFile() const
00199 {
00200 return fIoMod->CurrentFile();
00201 }
00202
00203
00204
00205 const char* IoModule::FileName(int i) const
00206 {
00207 return fIoMod->FileName(i);
00208 }
00209
00210
00211
00212 void IoModule::Warn(const char* w)
00213 {
00214 new TGMsgBox(evdb::TopWindow(), evdb::TopWindow(),
00215 "Warning", w, kMBIconExclamation);
00216 }
00217
00218
00219
00220 void IoModule::NewEvent()
00221 {
00222 Emit("NewEvent()");
00223 }
00224