1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
3
* Copyright (C) 2011 Canonical Ltd
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 3 as
7
* published by the Free Software Foundation.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
18
Nick Dedekind <nick.dedeknd@canoncial.com>
21
#ifndef UNITY_SCOPES_H
22
#define UNITY_SCOPES_H
24
#include <sigc++/trackable.h>
25
#include <sigc++/signal.h>
34
typedef std::vector<ScopeData::Ptr> ScopeDataList;
36
class ScopesReader : public sigc::trackable, boost::noncopyable
39
typedef std::shared_ptr<ScopesReader> Ptr;
40
virtual ~ScopesReader() {}
42
virtual void LoadScopes() = 0;
43
virtual ScopeDataList const& GetScopesData() const = 0;
45
virtual ScopeData::Ptr GetScopeDataById(std::string const& scope_id) const = 0;
47
sigc::signal<void, ScopeDataList const&> scopes_changed;
50
class Scopes : public sigc::trackable, boost::noncopyable
53
typedef std::shared_ptr<Scopes> Ptr;
54
typedef std::vector<Scope::Ptr> ScopeList;
56
Scopes(ScopesReader::Ptr scope_reader);
59
virtual void LoadScopes();
62
* Get the currently loaded Scopess. This is necessary as some of the consumers
63
* of this object employ a lazy-loading technique to reduce the overhead of
64
* starting Unity. Therefore, the Scopes may already have been loaded by the time
65
* the objects have been initiated (and so just connecting to the signals is not
68
virtual ScopeList const& GetScopes() const;
69
virtual Scope::Ptr GetScope(std::string const& scope_id, int* position = nullptr) const;
70
virtual Scope::Ptr GetScopeAtIndex(std::size_t index) const;
71
virtual Scope::Ptr GetScopeForShortcut(std::string const& scope_shortcut) const;
73
nux::ROProperty<std::size_t> count;
75
sigc::signal<void, Scope::Ptr const&, int> scope_added;
76
sigc::signal<void, Scope::Ptr const&> scope_removed;
78
sigc::signal<void, ScopeList const&> scopes_reordered;
80
virtual void AppendScope(std::string const& scope_id);
81
virtual void InsertScope(std::string const& scope_id, unsigned index);
82
virtual void RemoveScope(std::string const& scope_id);
85
virtual Scope::Ptr CreateScope(ScopeData::Ptr const& scope_data);
89
std::unique_ptr<Impl> pimpl;
91
friend class TestScope;
97
#endif // UNITY_SCOPES_H