| 13 | '''How it does it''' |
| 14 | Let's take a look at the code now. Writing a service is pretty simple when using ''Ariba'' because most difficulties and annoyances that could come up when struggling with writing network code are taken from the developer. We start with the ''main.cpp''. |
| 15 | |
| 16 | |
| 17 | {{{ |
| 18 | 01 #include <string> |
| 19 | 02 #include "ariba/utility/startup/StartupWrapper.h" |
| 20 | 03 #include "PingPong.h" |
| 21 | 04 |
| 22 | 05 using std::string; |
| 23 | 06 using ariba::utility::StartupWrapper; |
| 24 | 07 using ariba::application::pingpong::PingPong; |
| 25 | 08 |
| 26 | 09 int main( int argc, char** argv ) { |
| 27 | 10 |
| 28 | 11 string config = "../etc/settings.cnf"; |
| 29 | 12 if (argc >= 2) config = argv[1]; |
| 30 | 13 |
| 31 | 14 StartupWrapper::initConfig( config ); |
| 32 | 15 StartupWrapper::initSystem(); |
| 33 | 16 |
| 34 | 17 // this will do the main functionality and block |
| 35 | 18 PingPong ping; |
| 36 | 19 ping.setMode( !Configuration::instance().read<bool>("GENERAL_Initiator") ); |
| 37 | 20 StartupWrapper::startup(&ping, true); |
| 38 | 21 |
| 39 | 22 // this will run blocking until <enter> is hit |
| 40 | 23 |
| 41 | 24 StartupWrapper::shutdown(); |
| 42 | 25 return 0; |
| 43 | 26 } |
| 44 | }}} |
| 45 | The ''main.cpp'' serves us as an entry point to the application. |
| 46 | |
| 47 | |
| 48 | |