CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends

DDSpecificsFilter Class Reference

The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs. More...

#include <DDFilter.h>

Inheritance diagram for DDSpecificsFilter:
DDFilter

List of all members.

Classes

struct  SpecificCriterion

Public Types

enum  comp_op {
  equals, matches, not_equals, not_matches,
  smaller, bigger, smaller_equals, bigger_equals
}
enum  log_op { AND, OR }
 

logical operations to obtain one result from two filter comparisons

More...

Public Member Functions

bool accept (const DDExpandedView &) const
 true, if the DDExpandedNode fulfills the filter criteria
 DDSpecificsFilter ()
void setCriteria (const DDValue &nameVal, comp_op, log_op l=AND, bool asString=true, bool merged=true)
 ~DDSpecificsFilter ()

Protected Types

typedef std::vector
< criterion_type
criteria_type
typedef SpecificCriterion criterion_type
typedef std::vector< log_oplogops_type

Protected Member Functions

bool accept_impl (const DDExpandedView &) const

Protected Attributes

criteria_type criteria_
logops_type logOps_

Friends

std::ostream & operator<< (std::ostream &os, const DDSpecificsFilter &f)

Detailed Description

The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.

Definition at line 37 of file DDFilter.h.


Member Typedef Documentation

typedef std::vector<criterion_type> DDSpecificsFilter::criteria_type [protected]

Definition at line 86 of file DDFilter.h.

Definition at line 85 of file DDFilter.h.

typedef std::vector<log_op> DDSpecificsFilter::logops_type [protected]

Definition at line 87 of file DDFilter.h.


Member Enumeration Documentation

comparison operators to be used with this filter

Enumerator:
equals 
matches 
not_equals 
not_matches 
smaller 
bigger 
smaller_equals 
bigger_equals 

Definition at line 45 of file DDFilter.h.

logical operations to obtain one result from two filter comparisons

Enumerator:
AND 
OR 

Definition at line 48 of file DDFilter.h.

{ AND, OR };

Constructor & Destructor Documentation

DDSpecificsFilter::DDSpecificsFilter ( )

Definition at line 278 of file DDFilter.cc.

  : DDFilter()
{ }
DDSpecificsFilter::~DDSpecificsFilter ( )

Definition at line 282 of file DDFilter.cc.

{}

Member Function Documentation

bool DDSpecificsFilter::accept ( const DDExpandedView ) const [virtual]

true, if the DDExpandedNode fulfills the filter criteria

Implements DDFilter.

Definition at line 296 of file DDFilter.cc.

References accept_impl().

{
  return accept_impl(node);
} 
bool DDSpecificsFilter::accept_impl ( const DDExpandedView node) const [protected]

Definition at line 302 of file DDFilter.cc.

References AND, criteria_, DDLogicalPart::hasDDValue(), DDExpandedView::logicalPart(), logOps_, DDExpandedView::mergedSpecificsV(), OR, query::result, and DDExpandedView::specificsV().

Referenced by accept().

{
  bool result = true;
  criteria_type::const_iterator it = criteria_.begin();
  criteria_type::const_iterator crEnd = criteria_.end();
  logops_type::const_iterator logOpIt = logOps_.begin();
  //logops_type::iterator logOpEnd = logOps_.end();
  const DDLogicalPart & logp = node.logicalPart();
  DDsvalues_type  sv;
  std::vector<const DDsvalues_type *> specs;
  for (; it != crEnd; ++it, ++logOpIt) {
    // avoid useless evaluations
    if ( (   result &&(*logOpIt)==OR ) ||
         ( (!result)&&(*logOpIt)==AND) ) continue; 

    bool locres=false;
    if (logp.hasDDValue(it->nameVal_)) { 
      
      if (it->merged_) {
        
        if (sv.empty())  node.mergedSpecificsV(sv);
        
        if (it->asString_) { // merged specifics & compare std::strings
          locres = sfs_compare(*it,sv); 
        }
        else { // merged specifics & compare doubles
          locres = sfd_compare(*it,sv);
        }
      }
      else {
        
        if (specs.empty()) node.specificsV(specs);
        
        if (it->asString_) { // non-merged specifics & compare std::strings
          locres = sfs_compare_nm(*it, specs);
        }
        else { // non-merged specifics & compare doubles
          locres = sfd_compare_nm(*it, specs);
        }  
      }
    }
    if (*logOpIt==AND) {
      result &= locres;
    }
    else {
      result |= locres;
    }
  }
  return result;
}
void DDSpecificsFilter::setCriteria ( const DDValue nameVal,
comp_op  op,
log_op  l = AND,
bool  asString = true,
bool  merged = true 
)

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const DDSpecificsFilter f 
) [friend]

Member Data Documentation

Definition at line 89 of file DDFilter.h.

Referenced by accept_impl(), and setCriteria().

Definition at line 90 of file DDFilter.h.

Referenced by accept_impl(), and setCriteria().