forked from mihow/bpmdj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyzer-impl.h
118 lines (106 loc) · 2.82 KB
/
analyzer-impl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/****
BpmDj v4.2-pl4: Free Dj Tools
Copyright (C) 2001-2012 Werner Van Belle
http://bpmdj.yellowcouch.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose. See the
GNU General Public License for more details.
See the authors.txt for a full list of people involved.
****/
#ifndef __loaded__analyzer_impl_h__
#define __loaded__analyzer_impl_h__
using namespace std;
#include <boost/smart_ptr.hpp>
#include <vector>
#include <map>
#include <qstring.h>
#include <typeinfo>
#include "common.h"
using namespace std;
class AnalyzerProgress
{
public:
virtual void status(const char* name)=0;
virtual void progress(int a, int t)=0;
virtual void finished()=0;
};
struct Axis
{
float8 min;
float8 max;
string description;
float8 show_grid;
Axis(const char* label);
void val(float8 v);
};
struct LineData
{
map<float8, float8> xy;
Axis* X;
Axis* Y;
string description;
LineData();
void point(float8 x, float8 y);
};
struct AnalyzerPlot
{
vector<Axis*> allocated;
map<int, LineData > line_xy;
virtual void point(int z, float8 x, float8 y);
Axis* axis(const char* tmpstr);
void axes(int z, Axis* X, Axis* Y, string description);
void clear_plot_data();
};
/**
* The essential content of an analysis class is that it can report
* its progress and that it can work in a stepwise fashion.
*/
class AnalyzerImpl
{
protected:
AnalyzerProgress* progress_impl;
AnalyzerPlot* plot;
void status(const char* name, ...);
void progress(int a, int b)
{
if (progress_impl) progress_impl->progress(a,b);
}
Axis* axis(const char* name, ...);
void axes(int z, Axis* X, Axis* Y, string description)
{
if (plot) plot->axes(z,X,Y,description);
}
void point(int z, float8 x, float8 y)
{
if (plot) plot->point(z,x,y);
}
void finished()
{
if (progress_impl) progress_impl->finished();
}
public:
AnalyzerImpl();
void attach_progress(AnalyzerProgress* p);
void attach_plot(AnalyzerPlot* p);
virtual bool step()=0;
virtual ~AnalyzerImpl();
};
typedef boost::shared_ptr<AnalyzerImpl> AnalyzerAlg;
//---------------------------------------------------------
// A helper class to deal with a textual output
//---------------------------------------------------------
class TextualAnalyzerProgress: public AnalyzerProgress
{
int last_progress;
public:
TextualAnalyzerProgress();
virtual void status(const char*);
virtual void progress(int a, int t);
virtual void finished();
};
#endif // __loaded__analyzer_impl_h__