| [778abb] | 1 | /* | 
|---|
|  | 2 | * Project: MoleCuilder | 
|---|
|  | 3 | * Description: creates and alters molecular systems | 
|---|
|  | 4 | * Copyright (C)  2011 University of Bonn. All rights reserved. | 
|---|
|  | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 | /* | 
|---|
|  | 9 | * \file ResultGetter.cpp | 
|---|
|  | 10 | * | 
|---|
|  | 11 | * This file strongly follows the Serialization example from the boost::asio | 
|---|
|  | 12 | * library (see client.cpp) | 
|---|
|  | 13 | * | 
|---|
|  | 14 | *  Created on: Nov 27, 2011 | 
|---|
|  | 15 | *      Author: heber | 
|---|
|  | 16 | */ | 
|---|
|  | 17 |  | 
|---|
|  | 18 |  | 
|---|
|  | 19 | // include config.h | 
|---|
|  | 20 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 21 | #include <config.h> | 
|---|
|  | 22 | #endif | 
|---|
|  | 23 |  | 
|---|
|  | 24 | // boost asio needs specific operator new | 
|---|
|  | 25 | #include <boost/asio.hpp> | 
|---|
|  | 26 |  | 
|---|
|  | 27 | #include "CodePatterns/MemDebug.hpp" | 
|---|
|  | 28 |  | 
|---|
|  | 29 | #include <iostream> | 
|---|
|  | 30 | #include <vector> | 
|---|
|  | 31 |  | 
|---|
|  | 32 | #include "atexit.hpp" | 
|---|
|  | 33 | #include "CodePatterns/Info.hpp" | 
|---|
|  | 34 | #include "CodePatterns/Log.hpp" | 
|---|
| [73d6fc] | 35 | #include "Controller/FragmentController.hpp" | 
|---|
| [778abb] | 36 | #include "FragmentJob.hpp" | 
|---|
|  | 37 | #include "FragmentResult.hpp" | 
|---|
|  | 38 |  | 
|---|
|  | 39 |  | 
|---|
|  | 40 | int main(int argc, char* argv[]) | 
|---|
|  | 41 | { | 
|---|
|  | 42 | // from this moment on, we need to be sure to deeinitialize in the correct order | 
|---|
|  | 43 | // this is handled by the cleanup function | 
|---|
|  | 44 | atexit(cleanUp); | 
|---|
|  | 45 |  | 
|---|
|  | 46 | setVerbosity(3); | 
|---|
|  | 47 |  | 
|---|
|  | 48 | size_t Exitflag = 0; | 
|---|
|  | 49 | try | 
|---|
|  | 50 | { | 
|---|
|  | 51 | // Check command line arguments. | 
|---|
|  | 52 | if (argc != 3) | 
|---|
|  | 53 | { | 
|---|
|  | 54 | std::cerr << "Usage: " << argv[0] << " <host> <port>" << std::endl; | 
|---|
|  | 55 | return 1; | 
|---|
|  | 56 | } | 
|---|
|  | 57 |  | 
|---|
|  | 58 | boost::asio::io_service io_service; | 
|---|
|  | 59 | FragmentController controller(io_service, argv[1], argv[2]); | 
|---|
|  | 60 |  | 
|---|
|  | 61 | std::vector<FragmentJob> jobs; | 
|---|
|  | 62 | { | 
|---|
|  | 63 | FragmentJob testJob(std::string("do something"), 1); | 
|---|
|  | 64 | FragmentJob othertestJob(std::string("do something else"), 2); | 
|---|
|  | 65 | jobs.push_back(testJob); | 
|---|
|  | 66 | jobs.push_back(othertestJob); | 
|---|
|  | 67 | } | 
|---|
|  | 68 |  | 
|---|
| [5adb84] | 69 | controller.sendres(); | 
|---|
| [778abb] | 70 | { | 
|---|
|  | 71 | Info info("io_service"); | 
|---|
|  | 72 | io_service.run(); | 
|---|
|  | 73 | } | 
|---|
|  | 74 | std::vector<FragmentResult> results = controller.getResults(); | 
|---|
|  | 75 | for (std::vector<FragmentResult>::const_iterator iter = results.begin(); | 
|---|
|  | 76 | iter != results.end(); ++iter) | 
|---|
|  | 77 | LOG(1, "RESULT: job #"+toString((*iter).getId())+": "+toString((*iter).result)); | 
|---|
|  | 78 | Exitflag = controller.getExitflag(); | 
|---|
|  | 79 | } | 
|---|
|  | 80 | catch (std::exception& e) | 
|---|
|  | 81 | { | 
|---|
|  | 82 | std::cerr << e.what() << std::endl; | 
|---|
|  | 83 | } | 
|---|
|  | 84 |  | 
|---|
|  | 85 | return Exitflag; | 
|---|
|  | 86 | } | 
|---|