// $Id$ // // File: DEventSourceETGenerator.cc // Created: Wed Aug 9 2006 // Creator: davidl (on Darwin Harriet.local 8.6.0 powerpc) // #include using std::string; #include #include "DEventSourceETFactoryGenerator.h" #include "DEventSourceETGenerator.h" #include "DEventSourceET.h" // Routine used to allow us to register our JEventSourceGenerator extern "C"{ void InitPlugin(JApplication *app){ app->AddEventSourceGenerator(new DEventSourceETGenerator()); app->AddFactoryGenerator(new DEventSourceETFactoryGenerator()); } } // "C" //--------------------------------- // Description //--------------------------------- const char* DEventSourceETGenerator::Description(void) { return "ET:EVIO"; } //--------------------------------- // CheckOpenable //--------------------------------- double DEventSourceETGenerator::CheckOpenable(string source) { /// If the source starts with an "ET:" it is an ET source /// and we assume it is in EVIO format. If it does not /// start with "ET:", then assume it is an EVIO file /// try opening it to see if the magic header is there. if(source.substr(0,3) == "ET:"){ // ET return 0.9; }else{ // File int handle; int err = evOpen((char*)source.c_str(),"r", &handle); if(err == S_SUCCESS){ evClose(handle); return 1.0; } } return 0.0; } //--------------------------------- // MakeJEventSource //--------------------------------- JEventSource* DEventSourceETGenerator::MakeJEventSource(string source) { return new DEventSourceET(source.c_str()); }