/********************************************************************** * Project Name: FixExpress * * Program Name: fix_receiver.cpp * * Auther : Changpeng Yu * * Date : 03/24/2008 * * * * Copyright @ 2008 FT Computer Solutions * * * * Date Name PNO Description * * ------------------------------------------------------------------- * * 03/24/08 Changpeng Yu Create program module * ****************************************#*****************************/ #include #include #include #include #include #include using namespace std; #include "Common.h" #include "Options.h" #include "Time.h" #include "Shm.h" #include "MsgQueue.h" #include "Fix.h" int main(int argc, char *argv[]) { Options opt(argc, argv); if (opt.getCount() < 2) { cout << "Usage: fix_receiver shm mq [-t n] \n" << endl; exit(-1); } string shmKey = opt.getArgument(1); try { Shm shm(shmKey); Cell *cell; string qname = opt.getArgument(2); int mtype = 0; string mtypeStr; if (opt.is_present('t')) { mtypeStr = opt.getOption('t'); mtype = to_int(mtypeStr); } MsgQueue mq(qname, mtype); Fix fix; string site; for (;;) { fix.message = mq.read(mtype); site = fix.getTagValue(TagSenderCompID); cell = shm.getCell(site); cell->In.pend--; cell->In.proc++; cout << fix.printable() << "\n" << endl; } } catch (ShmException &me) { cerr << me.what() << "\n" << endl; exit (-1); } catch (MQException &e) { cerr << e.what() << "\n" << endl; exit (-1); }; return 0; }