1
#ifndef IONDOWNSAMPLE_H
2
#define IONDOWNSAMPLE_H
5
#include "../translation.h"
6
//!Random picker filter
7
class IonDownsampleFilter : public Filter
11
//When usng fixed number output, maximum to allow out.
12
size_t maxAfterFilter;
13
//!Allow only a fixed number at output, alternate is random fraction (binomial dist).
19
//!Should we use a per-species split or not?
21
//This is filter's enabled ranges. 0 if we don't have a range
22
RangeStreamData *rsdIncoming;
24
//!Fractions to output for species specific
25
std::vector<float> ionFractions;
26
std::vector<size_t> ionLimits;
28
IonDownsampleFilter();
29
//!Duplicate filter contents, excluding cache.
30
Filter *cloneUncached() const;
31
//!Returns FILTER_TYPE_IONDOWNSAMPLE
32
unsigned int getType() const { return FILTER_TYPE_IONDOWNSAMPLE;};
33
//!Initialise filter prior to tree propagation
34
virtual void initFilter(const std::vector<const FilterStreamData *> &dataIn,
35
std::vector<const FilterStreamData *> &dataOut);
37
//!Set mode, fixed num out/approximate out (fraction)
38
void setControlledOut(bool controlled) {fixedNumOut=controlled;};
40
//!Set the number of ions to generate after the filtering (when using count based fitlering).
41
void setFilterCount(size_t nMax) { maxAfterFilter=nMax;};
43
//!Get (approx) number of bytes required for cache
44
virtual size_t numBytesForCache(size_t nObjects) const;
46
unsigned int refresh(const std::vector<const FilterStreamData *> &dataIn,
47
std::vector<const FilterStreamData *> &getOut,
48
ProgressData &progress, bool (*callback)(bool));
50
//!return string naming the human readable type of this class
51
virtual std::string typeString() const { return std::string(TRANS("Ion Sampler"));}
55
//!Get the properties of the filter, in key-value form. First vector is for each output.
56
void getProperties(FilterProperties &propertyList) const;
58
//!Set the properties for the nth filter
59
bool setProperty(unsigned int set, unsigned int key, const std::string &value, bool &needUpdate);
60
//!Get the human readable error string associated with a particular error code during refresh(...)
61
std::string getErrString(unsigned int code) const;
63
//!Dump state to output stream, using specified format
64
bool writeState(std::ofstream &f,unsigned int format,
65
unsigned int depth=0) const;
66
//!Read the state of the filter from XML file. If this
67
//fails, filter will be in an undefined state.
68
bool readState(xmlNodePtr &node, const std::string &packDir);
70
//!Set internal property value using a selection binding (Disabled, this filter has no bindings)
71
void setPropFromBinding(const SelectionBinding &b) {ASSERT(false);} ;
73
//!Get the stream types that will be dropped during ::refresh
74
unsigned int getRefreshBlockMask() const;
76
//!Get the stream types that will be generated during ::refresh
77
unsigned int getRefreshEmitMask() const;
80
//Fire off the unit tests for this class. returns false if *any* test fails