~unity-api-team/unity-scopes-api/child-scopes-option

« back to all changes in this revision

Viewing changes to demo/scoperunner-BC.cpp

  • Committer: Michi Henning
  • Date: 2013-11-19 02:51:46 UTC
  • mto: This revision was merged to the branch mainline in revision 62.
  • Revision ID: michi.henning@canonical.com-20131119025146-kglcalpphl4ozzk7
Fixed scoperegistry to use new scoperunner and to figure out which scopes to run from config files.
Still to do:
- deal with overrides and OEM scopes, particularly the grouping aspect.
- SignalThread needs to invoke a callback for clean shut-down on receipt of SIGINT.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2013 Canonical Ltd
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License version 3 as
6
 
 * published by the Free Software Foundation.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 * Authored by: Michi Henning <michi.henning@canonical.com>
17
 
 */
18
 
 
19
 
#include <scopes/internal/RuntimeImpl.h>
20
 
#include <scopes/internal/ScopeLoader.h>
21
 
#include <scopes/internal/ScopeObject.h>
22
 
#include <unity/UnityExceptions.h>
23
 
 
24
 
#include <iostream>
25
 
 
26
 
using namespace std;
27
 
using namespace unity::api::scopes;
28
 
using namespace unity::api::scopes::internal;
29
 
 
30
 
int
31
 
main(int, char**)
32
 
{
33
 
    // TODO: the hard-wired strings here need to be read from config.
34
 
 
35
 
    string scope_nameB = string("scope-B");
36
 
    string scope_nameC = string("scope-C");
37
 
 
38
 
    try
39
 
    {
40
 
        RuntimeImpl::UPtr rtB = RuntimeImpl::create(scope_nameB);
41
 
        MiddlewareBase::SPtr mwB = rtB->factory()->create(rtB->scope_name(), "Zmq", "Zmq.Config");
42
 
        ScopeLoader::SPtr loaderB = ScopeLoader::load(rtB->scope_name(), "lib" + rtB->scope_name() + ".so",
43
 
                                                      rtB->registry());
44
 
        loaderB->start();
45
 
        ScopeObject::SPtr scopeB(new ScopeObject(rtB.get(), loaderB->scope_base()));
46
 
        mwB->add_scope_object(rtB->scope_name(), scopeB);
47
 
 
48
 
        RuntimeImpl::UPtr rtC = RuntimeImpl::create(scope_nameC);
49
 
        MiddlewareBase::SPtr mwC = rtC->factory()->create(rtC->scope_name(), "Zmq", "Zmq.Config");
50
 
        ScopeLoader::SPtr loaderC = ScopeLoader::load(rtC->scope_name(), "lib" + rtC->scope_name() + ".so",
51
 
                                                      rtC->registry());
52
 
        loaderC->start();
53
 
        ScopeObject::SPtr scopeC(new ScopeObject(rtC.get(), loaderC->scope_base()));
54
 
        mwC->add_scope_object(rtC->scope_name(), scopeC);
55
 
 
56
 
        mwB->wait_for_shutdown();
57
 
        mwC->wait_for_shutdown();
58
 
    }
59
 
 
60
 
    catch (unity::Exception const& e)
61
 
    {
62
 
        cerr << e.to_string() << endl;
63
 
        return 1;
64
 
    }
65
 
 
66
 
    return 0;
67
 
}