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