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
|
// -*- related-file-name: "../../libefont/findmet.cc" -*-
#ifndef EFONT_FINDMET_HH
#define EFONT_FINDMET_HH
#include <lcdf/hashmap.hh>
#include <lcdf/vector.hh>
#include <lcdf/permstr.hh>
class Filename;
class ErrorHandler;
namespace Efont {
class Metrics;
class AmfmMetrics;
class PsresDatabase;
class MetricsFinder { public:
MetricsFinder() : _next(0), _prev(0) { }
virtual ~MetricsFinder();
MetricsFinder *next() const { return _next; }
void add_finder(MetricsFinder *);
Metrics *find_metrics(PermString, ErrorHandler * = 0);
AmfmMetrics *find_amfm(PermString, ErrorHandler * = 0);
virtual Metrics *find_metrics_x(PermString, MetricsFinder *, ErrorHandler *);
virtual AmfmMetrics *find_amfm_x(PermString, MetricsFinder *, ErrorHandler *);
void record(Metrics *m);
virtual void record(Metrics *, PermString);
virtual void record(AmfmMetrics *);
private:
MetricsFinder *_next;
MetricsFinder *_prev;
MetricsFinder(const MetricsFinder &) { }
MetricsFinder &operator=(const MetricsFinder &) { return *this; }
protected:
Metrics *try_metrics_file(const Filename &, MetricsFinder *, ErrorHandler *);
AmfmMetrics *try_amfm_file(const Filename &, MetricsFinder *, ErrorHandler *);
};
class CacheMetricsFinder: public MetricsFinder { public:
CacheMetricsFinder();
~CacheMetricsFinder();
Metrics *find_metrics_x(PermString, MetricsFinder *, ErrorHandler *);
AmfmMetrics *find_amfm_x(PermString, MetricsFinder *, ErrorHandler *);
void record(Metrics *, PermString);
void record(AmfmMetrics *);
void clear();
private:
HashMap<PermString, int> _metrics_map;
Vector<Metrics *> _metrics;
HashMap<PermString, int> _amfm_map;
Vector<AmfmMetrics *> _amfm;
};
class InstanceMetricsFinder: public MetricsFinder { public:
InstanceMetricsFinder(bool call_mmpfb = true);
Metrics *find_metrics_x(PermString, MetricsFinder *, ErrorHandler *);
private:
bool _call_mmpfb;
Metrics *find_metrics_instance(PermString, MetricsFinder *, ErrorHandler *);
};
class PsresMetricsFinder: public MetricsFinder { public:
PsresMetricsFinder(PsresDatabase *);
Metrics *find_metrics_x(PermString, MetricsFinder *, ErrorHandler *);
AmfmMetrics *find_amfm_x(PermString, MetricsFinder *, ErrorHandler *);
private:
PsresDatabase *_psres;
};
class DirectoryMetricsFinder: public MetricsFinder { public:
DirectoryMetricsFinder(PermString);
Metrics *find_metrics_x(PermString, MetricsFinder *, ErrorHandler *);
AmfmMetrics *find_amfm_x(PermString, MetricsFinder *, ErrorHandler *);
private:
PermString _directory;
};
}
#endif
|