-
Notifications
You must be signed in to change notification settings - Fork 4
/
Results.h
94 lines (79 loc) · 1.73 KB
/
Results.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
/*
Pharmit
Copyright (c) David Ryan Koes, University of Pittsburgh and contributors.
All rights reserved.
Pharmit is licensed under both the BSD 3-clause license and the GNU
Public License version 2. Any use of the code that retains its reliance
on the GPL-licensed OpenBabel library is subject to the terms of the GPL2.
Use of the Pharmit code independently of OpenBabel (or any other
GPL2 licensed software) may choose between the BSD or GPL licenses.
See the LICENSE file provided with the distribution for more information.
*/
/*
* Results.h
*
* Created on: Jun 3, 2013
* Author: dkoes
*
* Base class for results containers. Default behavior is to do nothing at all.
*/
#ifndef RESULTS_H_
#define RESULTS_H_
#include <vector>
#include <string>
class Results
{
public:
Results()
{
}
virtual ~Results()
{
}
virtual void clear()
{
}
virtual void add(const char *data, double score) = 0;
virtual void reserve(unsigned n)
{
}
virtual unsigned size() const
{
return 0;
}
virtual bool stopEarly() const { return false; }
};
//for ojects that just store a string identifier (null terminated)
class StringResults: public Results
{
std::vector<std::string> strs;
std::vector<double> scores;
public:
StringResults()
{
}
virtual ~StringResults()
{
}
virtual void clear()
{
strs.clear();
}
virtual void add(const char *data, double score)
{
strs.push_back(data); //better be null terminated
scores.push_back(score);
}
virtual void reserve(unsigned n)
{
strs.reserve(n);
scores.reserve(n);
}
virtual unsigned size() const
{
return strs.size();
}
const std::string& getString(unsigned i) const { return strs[i]; }
double getScore(unsigned i) const { return scores[i]; }
};
#endif /* RESULTS_H_ */