Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

ProxyPublish.cpp

00001 #include "Sct/ISProxy/ISProxy.h"
00002 #include "Sct/SctNames.h"
00003 #include "Sct/File/IONameFile.h"
00004 #include "Sct/ISProxy/IOManagerISProxy.h"
00005 #include <iostream>
00006 #include <string>
00007 
00016 using namespace Sct;
00017 using namespace Sct::IS;
00018 using namespace Sct::File;
00019 using namespace Sct::ISProxy;
00020 using namespace std;
00021 
00022 int printHelp() {
00023         cout << "Usage: ProxyPublish <IS server> <class name> <uniqueID>" << endl;
00024     cout << "   or: ProxyPublish -f <filelist>" << endl;
00025         cout << "ProxyPublish puts an ISProxy into IS given appropriate information" << endl;
00026         cout << "This is useful if you still have the data transfer files, but the IS server has been restarted" << endl;
00027         cout << "The arguments should be obvious from the usage" << endl;
00028         return 0;
00029 }
00030 
00031 void publishProxy(string isServer, string className, string uniqueID) {
00032         IOParamsIS params(isServer);
00033         Sct::ISProxy::ISProxy proxy(uniqueID, className);
00034         IOManagerISProxy::instance().write(proxy, &params);
00035 }
00036 
00037 void publishFile(string fileName) {
00038     IONameFile file(fileName);
00039     //Try and guess ISServer name    
00040     string isServer = SctNames::getEventDataName();
00041     if (file.getClassName() == "SctData::RawScanResult") isServer = SctNames::getEventDataName();
00042     else if (file.getClassName() == "SctData::FitScanResult") isServer = SctNames::getFittedDataName();
00043     else if (file.getClassName().find("TestResult") != file.getClassName().npos) isServer = SctNames::getTestDataName();
00044     publishProxy(isServer, file.getClassName(), file.getUniqueID());
00045 }
00046 
00047 int main(int argc, char** argv) {
00048         if (argc < 2) return printHelp();
00049     try {
00050         if (argv[1] == string("-f")) {
00051         for (int i=2; i<argc; ++i) {
00052             publishFile(argv[i]);
00053         }
00054         } else {
00055         if (argc != 4) return printHelp();
00056         publishProxy(argv[1], argv[2], argv[3]);
00057         }
00058         } catch (Throwable& t) {
00059                 cout << t.what() << endl;
00060                 return 1;
00061         }
00062         return 0;
00063 }

Generated on Thu Jul 15 09:50:50 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5