Unity Scopes API
CategoryRenderer.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 <string>
22 #include <memory>
23 #include <unity/util/DefinesPtrs.h>
24 
25 namespace unity
26 {
27 
28 namespace scopes
29 {
30 
31 namespace internal
32 {
33  class CategoryRendererImpl;
34 }
35 
39 constexpr const char* DEFAULT_RENDERER
40 {
41  R"(
42  {
43  "schema-version":1,
44  "template":
45  {
46  "category-layout":"grid"
47  },
48  "components":
49  {
50  "title":"title",
51  "art":"art"
52  }
53  }
54  )"
55 };
56 
60 constexpr const char* MUSIC_GRID_RENDERER
61 {
62  R"(
63  {
64  "schema-version":1,
65  "template":
66  {
67  "category-layout":"grid"
68  },
69  "components":
70  {
71  "title":"title",
72  "subtitle":"subtitle",
73  "art":"art"
74  }
75  }
76  )"
77 };
78 
84 {
85 public:
87  UNITY_DEFINES_PTRS(CategoryRenderer);
89 
96  explicit CategoryRenderer(std::string const& json_text = DEFAULT_RENDERER);
97 
101  //{@
103  CategoryRenderer& operator=(CategoryRenderer const&);
104 
106  CategoryRenderer& operator=(CategoryRenderer&&);
107  virtual ~CategoryRenderer();
109 
114  // TODO: document exception thrown for invalid string.
115  static CategoryRenderer from_file(std::string const& path);
116 
121  std::string data() const;
122 
123 private:
124  std::unique_ptr<internal::CategoryRendererImpl> p;
125 
126  friend class internal::CategoryRendererImpl;
127 };
128 
130 bool operator==(const CategoryRenderer&, const CategoryRenderer&);
132 
133 } // namespace scopes
134 
135 } // namespace unity
static CategoryRenderer from_file(std::string const &path)
Creates a CategoryRenderer from a text file.
A category renderer template in JSON format.
Definition: CategoryRenderer.h:83
constexpr const char * DEFAULT_RENDERER
A default template for generic use.
Definition: CategoryRenderer.h:40
CategoryRenderer(std::string const &json_text=DEFAULT_RENDERER)
Creates a CategoryRenderer from a JSON string.
constexpr const char * MUSIC_GRID_RENDERER
A template suitable for displaying music results.
Definition: CategoryRenderer.h:61
std::string data() const
Returns complete renderer template definition in JSON format.
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Definition: ActionMetadata.h:31