00001 #include "Service.h" 00002 #include "ArchivingWorkerGroup.h" 00003 #include "archiving/ArchRawScanResult.h" 00004 #include "archiving/ArchFitScanResult.h" 00005 00006 #include "Sct/SctNames.h" 00007 #include "is/isinfo.h" 00008 #include "Sct/IS/IOManagerIS.h" 00009 #include "SctData/TestResult.h" 00010 #include "SctData/RawScanResult.h" 00011 #include "SctData/FitScanResult.h" 00012 #include <string> 00013 00014 using namespace Sct; 00015 using namespace SctData; 00016 using namespace Sct::IS; 00017 using namespace boost; 00018 00019 namespace SctArchivingService { 00020 00021 ArchivingService::ArchivingService() : IPCObject(Archiving_C_ArchivingService_interfaceName, &server()){ 00022 group = new ArchivingWorkerGroup(); 00023 } 00024 00025 00026 IPCServer& ArchivingService::server() { 00027 static IPCServer* server = new IPCServer(Archiving_C_ArchivingService_serverName, SctNames::getPartition()); 00028 return *server; 00029 } 00030 00031 void ArchivingService::run() { 00032 cout<<" I am in ArchivingService::run() " <<endl; 00033 00034 IPCPartition& p = SctNames::getPartition(); 00035 ISInfoReceiver r(p); 00036 00037 group->go(1); 00038 00039 r.subscribe("TestData", ".*TestResult.*", MyISCallback,this); 00040 r.run(); 00041 00042 } 00043 00044 00045 void ArchivingService::MyISCallback(ISCallbackInfo * isc) { 00046 cout<<" I am in ArchivingService::MyISCallback " <<endl; 00047 ArchivingService* a = static_cast<ArchivingService*>(isc->parameter()); 00048 cout<< " !!!! IS Object Name = " << isc->type().name()<<endl; 00049 a->archive(isc); 00050 } 00051 00052 00053 void ArchivingService::archive(ISCallbackInfo * isc) { 00054 cout<<" I am in ArchivingService::archive " <<endl; 00055 00056 if (isc->reason() != ISInfoCreated && isc->reason() != ISInfoUpdated ) return; 00057 00058 00059 shared_ptr<Serializable> ob = IOManagerIS::instance().read(*isc); 00060 cout << "!!!!!!!!! CLASS NAME ==== " << ob->getClassName() <<endl; 00061 if (ob == 0) { 00062 cerr << "Failed to get object from IS" << endl; 00063 return; 00064 } 00065 00066 group->push(ob); 00067 cout << "Bye bye Test" <<endl; 00068 00069 } 00070 00071 ilu_T_CString ArchivingService::ping (ArchivingStatus *_status) { 00072 char* msg = new char[28]; 00073 strcpy(msg, "Hello from ArchivingService"); 00074 return msg; 00075 } 00076 00077 }