//
// ***************************************************************************
+#include <iostream>
#include "bamtools_filter_engine.h"
#include "BamAux.h"
using namespace std;
// localize string version of our filter value
const string& valueString = Value.get<string>();
-
+
// string matching based on our filter type
switch ( Type ) {
case ( PropertyFilterValue::CONTAINS) : return ( query.find(valueString) != string::npos );
return false;
}
-// --------------------------------------------------------
-// PropertyFilter implementation
-PropertyFilter::PropertyFilter(void)
- : Type(PropertyFilter::EXACT)
- , LeftChild(0)
- , RightChild(0)
-{ }
-
-PropertyFilter::~PropertyFilter(void) {
- delete LeftChild;
- LeftChild = 0;
-
- delete RightChild;
- RightChild = 0;
-}
-
// ---------------------------------------------------------
// FilterEngine implementation
if ( (*propIter).IsEnabled ) names.push_back( (*propIter).Name );
return names;
}
-
-// ================================================================
-// DEBUGGING
-
-void FilterEngine::print(void) {
- cout << endl;
- printAllProperties();
- printEnabledProperties();
- printFilters();
-}
-
-void FilterEngine::printAllProperties(void) {
-
- cout << "=======================================" << endl;
- cout << "All Properties: " << endl;
- cout << endl;
-
- const vector<string> propertyNames = allPropertyNames();
- vector<string>::const_iterator nameIter = propertyNames.begin();
- vector<string>::const_iterator nameEnd = propertyNames.end();
- for ( ; nameIter != nameEnd; ++nameIter )
- cout << (*nameIter) << endl;
- cout << endl;
-}
-
-void FilterEngine::printEnabledProperties(void) {
-
- cout << "=======================================" << endl;
- cout << "Enabled Properties: " << endl;
- cout << endl;
-
- const vector<string> propertyNames = enabledPropertyNames();
- vector<string>::const_iterator nameIter = propertyNames.begin();
- vector<string>::const_iterator nameEnd = propertyNames.end();
- for ( ; nameIter != nameEnd; ++nameIter )
- cout << (*nameIter) << endl;
- cout << endl;
-}
-
-void FilterEngine::printFilters(void) {
-
- cout << "=======================================" << endl;
- cout << "Current Filters: " << endl;
- cout << endl;
-
- // iterate over all filters in FilterEngine
- FilterMap::const_iterator filterIter = m_filters.begin();
- FilterMap::const_iterator filterEnd = m_filters.end();
- for ( ; filterIter != filterEnd; ++filterIter ) {
- cout << "Filter Name: " << (*filterIter).first << endl;
-
- // see if filter set has this property enabled
- const PropertyFilter& filter = (*filterIter).second;
- PropertyMap::const_iterator propIter = filter.Properties.begin();
- PropertyMap::const_iterator propEnd = filter.Properties.end();
- for ( ; propIter != propEnd; ++propIter ) {
-
- cout << " - " << (*propIter).first << " : ";
- const PropertyFilterValue& filterValue = (*propIter).second;
-
- if ( filterValue.Value.is_type<bool>() ) cout << "\t" << boolalpha << filterValue.Value.get<bool>();
- else if ( filterValue.Value.is_type<int>() ) cout << "\t" << filterValue.Value.get<int>();
- else if ( filterValue.Value.is_type<unsigned int>() ) cout << "\t" << filterValue.Value.get<unsigned int>();
- else if ( filterValue.Value.is_type<unsigned short>() ) cout << "\t" << filterValue.Value.get<unsigned short>();
- else if ( filterValue.Value.is_type<float>() ) cout << "\t" << filterValue.Value.get<float>();
- else if ( filterValue.Value.is_type<string>() ) cout << "\t" << filterValue.Value.get<string>();
- else cout << "** UNKNOWN VALUE TYPE!! **";
-
- switch( filterValue.Type ) {
- case (PropertyFilterValue::CONTAINS) : cout << " (contains)"; break;
- case (PropertyFilterValue::ENDS_WITH) : cout << " (ends_with)"; break;
- case (PropertyFilterValue::EXACT) : cout << " (exact)"; break;
- case (PropertyFilterValue::GREATER_THAN) : cout << " (greater_than)"; break;
- case (PropertyFilterValue::GREATER_THAN_EQUAL) : cout << " (greater_than_equal)"; break;
- case (PropertyFilterValue::LESS_THAN) : cout << " (less_than)"; break;
- case (PropertyFilterValue::LESS_THAN_EQUAL) : cout << " (less_than_equal)"; break;
- case (PropertyFilterValue::NOT) : cout << " (not)"; break;
- case (PropertyFilterValue::STARTS_WITH) : cout << " (starts_with)"; break;
- default : cout << " : ** UNKNOWN COMPARE TYPE!! **";
- }
- cout << endl;
- }
- }
-}