Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 #ifndef UNITY_SCOPES_CATEGORYRENDERER_H
20 #define UNITY_SCOPES_CATEGORYRENDERER_H
21 
22 #include <string>
23 #include <memory>
24 #include <unity/util/DefinesPtrs.h>
25 
26 namespace unity
27 {
28 
29 namespace scopes
30 {
31 
32 namespace internal
33 {
34  class CategoryRendererImpl;
35 }
36 
40 constexpr const char* DEFAULT_RENDERER
41 {
42  R"(
43  {
44  "schema-version":1,
45  "template":
46  {
47  "category-layout":"grid"
48  },
49  "components":
50  {
51  "title":"title",
52  "art":"art"
53  }
54  }
55  )"
56 };
57 
61 constexpr const char* MUSIC_GRID_RENDERER
62 {
63  R"(
64  {
65  "schema-version":1,
66  "template":
67  {
68  "category-layout":"grid"
69  },
70  "components":
71  {
72  "title":"title",
73  "subtitle":"subtitle",
74  "art":"art"
75  }
76  }
77  )"
78 };
79 
85 {
86 public:
88  UNITY_DEFINES_PTRS(CategoryRenderer);
90 
97  explicit CategoryRenderer(std::string const& json_text = DEFAULT_RENDERER);
98 
102  //{@
104  CategoryRenderer& operator=(CategoryRenderer const&);
105 
107  CategoryRenderer& operator=(CategoryRenderer&&);
108  virtual ~CategoryRenderer();
110 
115  // TODO: document exception thrown for invalid string.
116  static CategoryRenderer from_file(std::string const& path);
117 
122  std::string data() const;
123 
124 private:
125  std::unique_ptr<internal::CategoryRendererImpl> p;
126 
127  friend class internal::CategoryRendererImpl;
128 };
129 
131 bool operator==(const CategoryRenderer&, const CategoryRenderer&);
133 
134 } // namespace scopes
135 
136 } // namespace unity
137 
138 #endif
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:84
constexpr const char * DEFAULT_RENDERER
A default template for generic use.
Definition: CategoryRenderer.h:41
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:62
std::string data() const
Returns complete renderer template definition in JSON format.