lib/score/tools/Metadata.hpp
1 #pragma once
2 #include <score/plugins/UuidKey.hpp>
3 #define EMPTY_MACRO
4 
35 template <typename Metadata_T, typename Object>
36 struct Metadata;
37 
42 class ObjectKey_k;
43 
48 class PrettyName_k;
49 
54 class UndoName_k;
55 
61 class Description_k;
62 
67 class Category_k;
68 
73 class Tags_k;
74 
79 class ConcreteKey_k;
80 
87 class Json_k;
88 
97 #define AUTO_METADATA(Export, Model, Key, Text) \
98  template <> \
99  struct Export Metadata<Key, Model> \
100  { \
101  static auto get() \
102  { \
103  return Text; \
104  } \
105  };
106 
107 #define TYPED_METADATA(Export, Model, Key, Type, Value) \
108  template <> \
109  struct Export Metadata<Key, Model> \
110  { \
111  static Type get() \
112  { \
113  return Value; \
114  } \
115  };
116 
117 #define TR_TEXT_METADATA(Export, Model, Key, Text) \
118  AUTO_METADATA(Export, Model, Key, QObject::tr(Text))
119 #define LIT_TEXT_METADATA(Export, Model, Key, Text) \
120  AUTO_METADATA(Export, Model, Key, QStringLiteral(Text))
121 
122 #define OBJECTKEY_METADATA(Export, Model, ObjectKey) \
123  LIT_TEXT_METADATA(Export, Model, ObjectKey_k, ObjectKey)
124 
125 #define DESCRIPTION_METADATA(Export, Model, Text) \
126  TR_TEXT_METADATA(Export, Model, Description_k, Text)
127 #define CATEGORY_METADATA(Export, Model, Text) \
128  TR_TEXT_METADATA(Export, Model, Category_k, Text)
129 #define TAGS_METADATA(Export, Model, Text) \
130  TYPED_METADATA(Export, Model, Tags_k, QStringList, Text)
131 
132 #define UNDO_NAME_METADATA(Export, Model, Text) \
133  TR_TEXT_METADATA(Export, Model, UndoName_k, Text)
134 
135 #define DEFAULT_MODEL_METADATA(Model, Description) \
136  OBJECTKEY_METADATA(EMPTY_MACRO, Model, #Model) \
137  DESCRIPTION_METADATA(EMPTY_MACRO, Model, Description)
138 
139 #define JSON_METADATA(Type, Text) LIT_TEXT_METADATA(, Type, Json_k, Text)
140 
141 #define STATIC_METADATA(Export, Model, Key, Type, Value) \
142  template <> \
143  struct Export Metadata<Key, Model> \
144  { \
145  static constexpr Type get() \
146  { \
147  const constexpr Type k{Value}; \
148  \
149  return k; \
150  } \
151  };
152 
153 #define UUID_METADATA(Export, Factory, Model, Uuid) \
154  STATIC_METADATA(Export, Model, ConcreteKey_k, UuidKey<Factory>, Uuid)
155 
156 #define MODEL_METADATA(Export, Factory, Model, Uuid, ObjectKey, PrettyName) \
157  OBJECTKEY_METADATA(Export, Model, ObjectKey) \
158  UUID_METADATA(Export, Factory, Model, Uuid) \
159  TR_TEXT_METADATA(Export, Model, PrettyName_k, PrettyName)
Metadata to categorize objects: curves, audio, etc.
Definition: lib/score/tools/Metadata.hpp:61
Metadata to get the description that will be shown in the undo-redo panel.
Definition: lib/score/tools/Metadata.hpp:54
Metadata to give the JSON key that matches a given type.
Definition: lib/score/tools/Metadata.hpp:79
Metadata to get the key part of ObjectIdentifier.
Definition: lib/score/tools/Metadata.hpp:36
Metadata to get the name that will be shown in the user interface.
Definition: lib/score/tools/Metadata.hpp:42
Metadata to associate tags to objects.
Definition: lib/score/tools/Metadata.hpp:67
Metadata to get the name that will be shown in the undo-redo panel.
Definition: lib/score/tools/Metadata.hpp:48
Static metadata implementation.
Definition: lib/score/tools/Metadata.hpp:36