mwe.cpp

Hendrik Buschmeier, 2016-12-07 21:48

Download (1.317 KB)

 
1
#include <sstream>
2
#include <iostream>
3
#include <fstream>
4

    
5
#include <ipaaca/ipaaca.h>
6

    
7
void initialize_ipaaca(std::string host, std::string port) {
8
        std::ofstream configFile;
9
        configFile.open("rsb.conf");
10
        configFile << "# (file auto-generated by EyeX component)\n";
11
        configFile << "[plugins.cpp]\n";
12
        configFile << "load = rsbspread\n";
13
        configFile << "path = C:\\\\Users\\\\KOMPASS\\\\repo\\\\rsb-win-scs\\\\bin\n";
14
        configFile << "\n";
15
        configFile << "[transport.socket]\n";
16
        configFile << "host = " << host << "\n";
17
        configFile << "port = " << port << "\n";
18
        configFile << "server = 0\n";
19
        configFile << "enabled = 0\n";
20
        configFile << "\n";
21
        configFile << "[transport.spread]\n";
22
        configFile << "host = " << host << "\n";
23
        configFile << "port = " << port << "\n";
24
        configFile << "enabled = 1\n";
25
        configFile.close();
26

    
27
        ipaaca::Initializer::initialize_backend();
28
}
29

    
30
int main()
31
{
32
        initialize_ipaaca("localhost", "4803");
33
        ipaaca::OutputBuffer::ptr ob = ipaaca::OutputBuffer::create("testbuf");
34
        ipaaca::IU::ptr iu = ipaaca::IU::create("testcategory");
35
        iu->payload()["hello"] = std::map<std:string, std::string>{{"1", "hello"}, {"2", "world"}, {"3", "!"}};
36
        ob->add(iu);
37
        {
38
                ipaaca::Locker mylocker(iu->payload());
39
                iu->payload()["hello"]["1"] = "hallo";
40
                iu->payload()["hello"]["2"] = "welt"; // Only this update will be send
41
        }
42
        return 0;
43
}