00001 #include "TestApi.h"
00002 #include "Configuration.h"
00003 #include "Sct/Exception.h"
00004
00005 #include "Sct_SctApi/SctApiServer.h"
00006 #include "sctConfIPC/configipc.h"
00007
00008 #include <ipc/core.h>
00009 #include <ipc/object.h>
00010 #include <ipc/server.h>
00011 #include <pmg/pmg_initSync.h>
00012
00013 #include <iostream>
00014 #include <boost/shared_ptr.hpp>
00015
00016 using namespace std;
00017 using namespace boost;
00018 using namespace SctConfiguration;
00019 using namespace SctTest;
00020
00021 IPCServer ipcServer;
00022 shared_ptr<SctConfiguration::Configuration> configServer;
00023
00024
00025
00026
00027
00028
00029
00030
00031 int main(int argc, char** argv) {
00032 Sct::setExceptionHandlers(argv[0]);
00033
00034 IPCCore::init(argc,argv);
00035 IPCPartition p("SCT");
00036
00037
00038 try {
00039
00040
00041
00042 auto_ptr<TestApi> api(new TestApi());
00043
00044 if (!SctTest::Configuration::instance().publish()) {
00045 cout << "Failed to publish Configuration" << endl;
00046 return 2;
00047 }
00048
00049
00050
00051
00052
00053
00054 auto_ptr<SctApiServer> h(new SctApiServer(*api, Sct_SctApi::SctApiIPC::instanceName));
00055
00056
00057 if (!h->publish()) {
00058 cout << "Failed to publish SctTestApi" << std::endl;
00059 return 2;
00060 }
00061
00062 cout << "Serving...\n";
00063
00064
00065 pmg_initSync();
00066 ipcServer.run();
00067
00068 cout << "Run over" << std::endl;
00069 h->withdraw();
00070 SctTest::Configuration::instance().withdraw();
00071
00072
00073 } catch(SctConfiguration::ConfigurationException &c) {
00074 std::cout << "ConfigurationException: " << c.what() << std::endl;
00075
00076 MRSStream mrsStream(p);
00077 mrsStream << "SctTestApi" << MRS_FATAL << MRS_QUALIF("SctTestApi") << MRS_TEXT("Configuration server not running!") << ENDM;
00078
00079 exit(1);
00080 }
00081 }