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

« back to all changes in this revision

Viewing changes to demo/scoperunner-A.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_name = string("scope-A");
36
 
 
37
 
    try
38
 
    {
39
 
        RuntimeImpl::UPtr rt = RuntimeImpl::create(scope_name);
40
 
        ScopeLoader::SPtr loader = ScopeLoader::load(scope_name, "lib" + scope_name + ".so", rt->registry());
41
 
        loader->start();
42
 
        MiddlewareBase::SPtr mw = rt->factory()->create(scope_name, "Zmq", "Zmq.Config");
43
 
        ScopeObject::SPtr scope(new ScopeObject(rt.get(), loader->scope_base()));
44
 
        mw->add_scope_object(scope_name, scope);
45
 
        mw->wait_for_shutdown();
46
 
    }
47
 
    catch (unity::Exception const& e)
48
 
    {
49
 
        cerr << e.to_string() << endl;
50
 
        return 1;
51
 
    }
52
 
 
53
 
    return 0;
54
 
}