Unity Scopes API
Annotation.h
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 Lesser 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 Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com>
17  */
18 
19 #pragma once
20 
21 #include <unity/scopes/Variant.h>
22 #include <unity/scopes/Link.h>
23 #include <unity/util/DefinesPtrs.h>
24 #include <list>
25 #include <memory>
26 
27 namespace unity
28 {
29 
30 namespace scopes
31 {
32 class CannedQuery;
33 
34 namespace internal
35 {
36 class AnnotationImpl;
37 class ResultReplyObject;
38 }
39 
40 namespace experimental
41 {
42 
43 // TODO: This class looks a lot like a union: either it's a Link or it's a GroupedLink, and
44 // some methods apply to one, but not the other (and vice versa). This might be
45 // two classes instead?
46 
51 class Annotation final
52 {
53 public:
55  UNITY_DEFINES_PTRS(Annotation);
57 
61  enum Type
62  {
63  Link,
64  GroupedLink
65  };
66 
71  explicit Annotation(Type atype);
72 
76  //{@
77  Annotation(Annotation const &other);
78  Annotation(Annotation&&);
79  Annotation& operator=(Annotation const& other);
80  Annotation& operator=(Annotation&&);
82 
84  virtual ~Annotation();
86 
93  void set_label(std::string const& label);
94 
101  void set_icon(std::string const& icon);
102 
111  void add_link(std::string const& label, CannedQuery const& query);
112 
118  std::string label() const;
119 
125  std::string icon() const;
126 
131  std::list<Link::SCPtr> links() const;
132 
137  Type annotation_type() const;
138 
140  VariantMap serialize() const;
142 
143 private:
144  Annotation(internal::AnnotationImpl* impl);
145  std::unique_ptr<internal::AnnotationImpl> p;
146 
147  friend class internal::ResultReplyObject;
148 };
149 
150 } // namespace experimental
151 
152 } // namespace scopes
153 
154 } // namespace unity
Top-level namespace for all things Unity-related.
Definition: Version.h:49
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:38
Definition: ActionMetadata.h:31