Changes between Version 6 and Version 7 of ariba_0_9


Ignore:
Timestamp:
Jun 19, 2013, 4:55:50 PM (11 years ago)
Author:
hock@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ariba_0_9

    v6 v7  
    7979Please note that the ping-pong example still uses the old deprecated ariba messages (see next section "Message formats" for more information).
    8080
     81{{{
     82#!cpp
     83void PingPong::startup()
     84{
     85    using boost::property_tree::ptree;
     86    using boost::property_tree::json_parser::read_json;
     87   
     88    logging_info( "[PINGPONG]\t starting up PingPong service ... " );
     89
     90    // read config
     91    ptree config;
     92    try
     93    {
     94        read_json(config_file, config);
     95    }
     96    catch ( exception& e )
     97    {
     98        logging_warn("ERROR: Failed to read config file »" << config_file << "«: ");
     99        logging_warn(e.what());
     100        logging_warn("---> Using fallback config.");
     101       
     102        config.put("ariba.spovnet_name", "pingpong");
     103    }
     104   
     105    // use node name also in the application
     106    name = config.get("ariba.node_name", "NO_NAME");
     107   
     108    // bind communication and node listener
     109    node.bind( this );                              /*NodeListener*/
     110    node.bind( this, PingPong::PINGPONG_SERVICEID); /*CommunicationListener*/
     111
     112    // connecting
     113    logging_debug( "connecting ... " );
     114
     115    node.connect(config.get_child("ariba"));
     116
     117    // ping pong started up...
     118    logging_info( "[PINGPONG]\t pingpong starting up with"
     119                        << " [spovnetid " << node.getSpoVNetId().toString() << "]"
     120                        << " and [nodeid " << node.getNodeId().toString() << "]" );
     121}
     122}}}
     123
     124  - `ptree config;` is an yet empty instance of boost::property_tree::ptree.
     125  - `read_json(config_file, config);` reads a config file (like the JSON file showed in the previous section) into the ptree instance `config`. The path of the JSON file is stored in `config_file`.
     126    - If the read fails, the except handler prints a warning and initiates a default config directly within the code via: `config.put("ariba.spovnet_name", "pingpong");`
     127  - The node variable is defined as attribute: `ariba::Node node;` (initialized with the standard constructor). Thoe follwing registers the callbacks from ariba:
     128    - `node.bind( this );`
     129    - `node.bind( this, PingPong::PINGPONG_SERVICEID);`
     130  - The following command starts ariba with the config stored in the ptree
     131    - `node.connect(config.get_child("ariba"));`
     132
     133The callbacks (functions in the application that are called from ariba) are declared in `ariba/CommunicationListener.h`.
     134The ariba interface (functions in ariba that can be called from the application) are declared in `ariba/Node.h`.
     135
    81136=== Message formats ===