Sayonara Player
globals.h
1 /* globals.h */
2 
3 /* Copyright (C) 2012 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef GLOBALS_H_
22 #define GLOBALS_H_
23 
24 #include <QObject>
25 #include <QString>
26 #include <QTime>
27 #include <QTranslator>
28 #include "Helper/Logger/Logger.h"
29 
30 #include <type_traits>
31 
32 #define SINGLETON_QOBJECT(class_name) protected: \
33  class_name (QObject* object=0); \
34  public: \
35  static class_name *getInstance() { static class_name instance; return &instance; } \
36  virtual ~class_name ();
37 
38 
39 #define SINGLETON(class_name) protected: \
40  class_name (); \
41  public: \
42  static class_name *getInstance() { static class_name instance; return &instance; } \
43  virtual ~class_name ();
44 
45 #define DARK_BLUE(x) QString("<font color=#0000FF>") + x + QString("</font>")
46 #define LIGHT_BLUE(x) QString("<font color=#8888FF>") + x + QString("</font>")
47 
48 #define CAR_RET QString("<br />")
49 #define BOLD(x) QString("<b>") + x + QString("</b>")
50 #define BLACK(x) QString("<font color=#000000>") + x + QString("</font>")
51 
52 
53 // name, target, dark, string
54 #define LINK(n, t, d, s) if(d) s=QString("<a href=\"t\">)") + LIGHT_BLUE(n) + QString("</a>"); \
55  else s=QString("<a href=\"t\">)") + DARK_BLUE(n) + QString("</a>");
56 
57 #define SAYONARA_ORANGE_STR QString("#e8841a")
58 #define SAYONARA_ORANGE_COL QColor(232, 132, 26)
59 
60 
61 #define PLUGIN_NUM 5
62 #define PLUGIN_NONE 0
63 #define PLUGIN_LFM_RADIO 1
64 #define PLUGIN_STREAM 2
65 #define PLUGIN_PODCASTS 3
66 #define PLUGIN_EQUALIZER 4
67 #define PLUGIN_PLAYLIST_CHOOSER 5
68 #define PLUGIN_LEVEL 6
69 /*
70 
71 #define PLUGIN_NAME_LFM_RADIO tr("Last.&fm")
72 #define PLUGIN_NAME_STREAM tr("&Stream")
73 #define PLUGIN_NAME_PODCASTS tr("P&odcasts")
74 #define PLUGIN_NAME_EQUALIZER tr("&Equalizer")
75 #define PLUGIN_NAME_PLAYLIST_CHOOSER tr("&PlaylistChooser")
76 */
77 
78 #define GOOGLE_IMG_ICON QString("icon")
79 #define GOOGLE_IMG_SMALL QString("small")
80 #define GOOGLE_IMG_MEDIUM QString("medium")
81 #define GOOGLE_IMG_LARGE QString("large")
82 #define GOOGLE_IMG_XLARGE QString("xlarge")
83 #define GOOGLE_IMG_XXLARGE QString("xxlarge")
84 #define GOOGLE_IMG_HUGE QString("huge")
85 
86 #define GOOGLE_FT_JPG QString("jpg")
87 #define GOOGLE_FT_PNG QString("png")
88 #define GOOGLE_FT_GIF QString("gif")
89 #define GOOGLE_FT_BMP QString("bmp")
90 
91 typedef QPair<QString, QString> StringPair;
92 typedef QList<int> IntList;
93 typedef QList<int> IDList;
94 typedef QList<int> IdxList;
95 typedef QList<bool> BoolList;
96 typedef qint32 ArtistID;
97 typedef qint32 AlbumID;
98 typedef qint32 TrackID;
99 
100 enum LameBitrate {
101 
102  LameBitrate_64=64,
103  LameBitrate_128=128,
104  LameBitrate_192=192,
105  LameBitrate_256=256,
106  LameBitrate_320=320,
107 
108  LameBitrate_var_0=0,
109  LameBitrate_var_1=1,
110  LameBitrate_var_2=2,
111  LameBitrate_var_3=3,
112  LameBitrate_var_4=4,
113  LameBitrate_var_5=5,
114  LameBitrate_var_6=6,
115  LameBitrate_var_7=7,
116  LameBitrate_var_8=8,
117  LameBitrate_var_9=9
118 };
119 
120 #define N_BINS 70
121 
122 #define MEASURE_TIME(x) QTime myTimer; \
123  myTimer.start(); \
124  { \
125  x \
126  } \
127  qDebug() << "Time: " << myTimer.elapsed();
128 
129 //#define between(idx, start, size) ( idx >= start && idx < size)
130 
131 
132 template<typename TINT, typename T>
133 typename std::enable_if<std::is_pointer<T>::value, bool>::type
134 between( TINT idx, const T& cont){
135  return (idx >= 0 && idx < cont->size());
136 }
137 
138 template<typename TINT, typename T>
139 typename std::enable_if<std::is_class<T>::value, bool>::type
140 between( TINT idx, const T cont){
141  return (idx >= 0 && idx < cont.size());
142 }
143 
144 template<typename TINT>
145 typename std::enable_if<std::is_integral<TINT>::value, bool>::type
146 between( TINT idx, TINT max){
147  return (idx >= 0 && idx < max);
148 }
149 
150 
151 
152 /*template<typename TINT>
153 between(const TINT num1, const TINT num2, const TINT num3){
154  return (num1 >= num2 && num1 < num3);
155 }*/
156 
157 
158 #endif /* GLOBALS_H_ */