// Author: David Lawrence June 25, 2004 // // // hd_ana.cc // #include using namespace std; #include #include "MyProcessor.h" #include "DANA/DApplication.h" #include "HDDM/DEventSourceHDDMGenerator.h" void PrintFactoryList(DApplication *app); void ParseCommandLineArguments(int &narg, char *argv[]); void Usage(void); bool LIST_FACTORIES = false; //----------- // main //----------- int main(int narg, char *argv[]) { // Parse the command line ParseCommandLineArguments(narg, argv); // Instantiate our event processor MyProcessor myproc; // Instantiate an event loop object DApplication *app = new DApplication(narg, argv); // If LIST_FACTORIES is set, print all factories and exit if(LIST_FACTORIES){ PrintFactoryList(app); return 0; } // This monkey shines is needed to get getchar() to return single // characters without waiting for the user to hit return struct termios t; tcgetattr(fileno(stdin), &t); t.c_lflag &= (~ICANON); //t.c_cc[VMIN] = 1; tcsetattr(fileno(stdin), TCSANOW, &t); // Run though all events, calling our event processor's methods app->SetShowTicker(0); app->monitor_heartbeat = false; app->Run(&myproc); delete app; return 0; } //----------- // PrintFactoryList //----------- void PrintFactoryList(DApplication *app) { // When we get here, the Run() method hasn't been // called so the JEventLoop objects haven't // been created yet and cansequently the factory objects // don't yet exist. Since we want the "list factories" // option to work even without an input file, we need // to first make the factories before we can list them. // To do this we only need to instantiate a JEventLoop object // passing it our "app" pointer. The JEventLoop will automatically // register itself with the DApplication and the factories // will be made, even ones from plugins passed on the command // line. JEventLoop *loop = new JEventLoop(app); // Print header cout< factories = loop->GetFactories(); vector::iterator iter = factories.begin(); for(; iter!=factories.end(); iter++){ cout<<" "<<(*iter)->GetDataClassName(); if(strlen((*iter)->Tag()) !=0){ cout<<" : "<<(*iter)->Tag(); } cout<