Logo Search packages:      
Sourcecode: condor version File versions  Download package

bool BoolExpr::ExprToMultiProfile ( classad::ExprTree *  expr,
MultiProfile *&  mp 
) [static, inherited]

Builds a MultiProfile object from an ExprTree object. The method returns success if the ExprTree is in Disjunctive Profile Form. DPF is simply a disjunction of Profiles.

Parameters:
expr The ExprTree object which must be in DPF.
mp The resulting MultiProfile Object.
Returns:
true on success, false on failure.

Definition at line 43 of file boolExpr.cpp.

References MultiProfile::AppendProfile(), BoolExpr::ExprToProfile(), BoolExpr::Init(), and MultiProfile::isLiteral.

Referenced by ClassAdAnalyzer::AnalyzeExprToBuffer().

{
      if( expr == NULL ) {
            cerr << "error: input ExprTree is null" << endl;
                  //  error: input ExprTree is null
            return false;
      }

      if( !mp->Init( expr ) ) {
            cerr << "error: problem with MultiProfile::Init" << endl;
            return false;
      }

      classad::ExprTree::NodeKind kind;
      classad::Operation::OpKind op;
      classad::ExprTree *left, *right, *junk;
      Profile *currentProfile = new Profile;
      Stack<Profile> profStack;
      classad::Value val;

      classad::ExprTree *currentTree = expr;
      bool atLeftMostProfile = false;
      while( !atLeftMostProfile ) {

            kind = currentTree->GetKind( );
                  
            if( kind == classad::ExprTree::ATTRREF_NODE ) {
                  atLeftMostProfile = true;
                  continue;
            }

            if( kind != classad::ExprTree::OP_NODE ) {
                  cerr << "error: bad form" << endl;
                        // error: bad form
                  return false;
            }

            ( ( classad::Operation * )currentTree )->GetComponents( op, left,
                                                                                                right, junk );

            while( op == classad::Operation::PARENTHESES_OP ) {
                  if( left->GetKind( ) == classad::ExprTree::ATTRREF_NODE ) {
                        atLeftMostProfile = true;
                        break;
                  }
                  ( ( classad::Operation * )left )->GetComponents( op, left, right,
                                                                                           junk );
            }

            if( atLeftMostProfile == true ) {
                  continue;
            }

                  // check if we have reached the leftmost profile
            if( op != classad::Operation::LOGICAL_OR_OP ) {
                  atLeftMostProfile = true;
                  continue;
            }

                  // Peel of the rightmost profile
            if( !ExprToProfile( right, currentProfile ) ) {
                  cerr << "error: problem with ExprToProfile" << endl;
                        // error: problem with ExprToProfile
                  return false;
            }
            else {
                  profStack.Push( currentProfile );
                  currentTree = left;
            }
            currentProfile = new Profile;
      }

            // process the leftmost profile
      if( !ExprToProfile( currentTree, currentProfile ) ) {
            cerr << "error: problem with ExprToProfile" << endl;
                  // error: problem with ExprToProfile
            delete currentProfile;
            return false;
      }

            // pull the profiles off the stack and append them to the MultiProfile
      mp->AppendProfile( currentProfile );

      while( !profStack.IsEmpty( ) ) {
            mp->AppendProfile( profStack.Pop( ) );
      }

      mp->isLiteral = false;

      return true;
}


Generated by  Doxygen 1.6.0   Back to index