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

explain.h

/***************************************************************
 *
 * Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
 * University of Wisconsin-Madison, WI.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License.  You may
 * obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ***************************************************************/


#ifndef __EXPLAIN_H__
#define __EXPLAIN_H__

#define WANT_CLASSAD_NAMESPACE
#include "condor_fix_iostream.h"
#include "classad/classad_distribution.h"
#include "list.h"
#include "interval.h"

/** A base class representing an annotation for an expression.  Current derived
      current derived classes include MultiProfileExplain, ProfileExplain, and
      ConditionExplain.
 */
00034 class Explain
{
 public:

            /** Virtual method for generating a string equivalent to the Explain.
                  @param buffer A string for the explain to be printed to
                  @return true on success, false on failure.
            */
      virtual bool ToString( std::string &buffer ) = 0;

            /** Virtual destructor */
      virtual ~Explain( ) = 0;
 protected:
      bool initialized;
      Explain( );
};

/** A derived class of Explain used to annotate a MultiProfile expression.
      @see MultiProfile
*/
00054 class MultiProfileExplain: Explain
{
 public:

            /** True if the MultiProfile matches some ClassAd, false otherwise */ 
00059       bool match;

            /** Number of ClassAds matched by the MultiProfile expression */
00062       int numberOfMatches;

            /** Which ClassAds the job matches */
00065       IndexSet matchedClassAds;

            /** Total number of ClassAds */
00068       int numberOfClassAds;

            /** Default Constructor */
      MultiProfileExplain( );

            /** Destructor */
      ~MultiProfileExplain( );

            /** Initializes the MultiProfileExplain.
                  @param match A boolean value for the match member variable.
                  @param numberOfMatches An integer value for the numberOfMatches
                  member variable
.                 @return true on success, false on failure.
            */
      bool Init( bool match, int numberOfMatches, IndexSet &matchedClassAds,
                     int numberOfClassAds );

            /** Generate a string representation of the MultiProfileExplain
                  @param buffer A string to print the result to.
                  @return true on success, false on failure.
            */ 
      bool ToString( std::string &buffer );
};

/** A derived class of Explain used to annotate a Profile expression.
      @see Profile
*/
00095 class ProfileExplain: Explain
{
 public:

            /** True if the Profile matches some ClassAd, false otherwise */ 
00100       bool match;

            /** Number of ClassAds matched by the Profile expression */
00103       int numberOfMatches;

            /** Which Conditions conflict with one another */
00106       List< IndexSet > *conflicts;

            /** Default Constructor */
      ProfileExplain( );

            /** Destructor */
      ~ProfileExplain( );

            /** Initializes the ProfileExplain.
                  @param match A boolean value for the match member variable.
                  @param numberOfMatches An integer value for the numberOfMatches
                  member variable
.                 @return true on success, false on failure.
            */
      bool Init( bool match, int numberOfMatches );

            /** Generate a string representation of the ProfileExplain
                  @param buffer A string to print the result to.
                  @return true on success, false on failure.
            */ 
      bool ToString( std::string &buffer );
};

/** A derived class of Explain used to annotate a Condition expression.
      @see Condition
*/
00132 class ConditionExplain: Explain
{
 public:
00135       enum Suggestion
      {
00137     /** no suggestion */ NONE,
00138       /** keep the Condtition*/ KEEP,
00139       /** remove the Condition */ REMOVE,
      /** modify the value part of the Condition to the Value stored in 
00141         newValue*/ MODIFY
      };


            /** True if the Condition matches some ClassAd, false otherwise */ 
00146       bool match;

            /** Number of ClassAds matched by the Condition expression */
00149       int numberOfMatches;

            /** A suggestion for what to do with the Condition */
00152       Suggestion suggestion;

            /** If suggestion = MODIFY the new Value will be stored here */
00155       classad::Value newValue;


            /** Default Constructor */
      ConditionExplain( );

            /** Destructor */
      ~ConditionExplain( );

            /** Initializes the ConditionExplain. suggestion is set to NONE
                  @param match A boolean value for the match member variable.
                  @param numberOfMatches An integer value for the numberOfMatches
                  member variable
.                 @return true on success, false on failure.
            */
      bool Init( bool match, int numberOfMatches );

            /** Initializes the ConditionExplain.
                  @param match A boolean value for the match member variable.
                  @param numberOfMatches An integer value for the numberOfMatches
                  member variable
                  @param suggestion A Suggestion value ( usually KEEP or REMOVE ) 
.                 @return true on success, false on failure.
            */
      bool Init( bool match, int numberOfMatches, Suggestion suggestion );

            /** Initializes the ConditionExplain.  Suggestion is set to MODIFY.
                  @param match A boolean value for the match member variable.
                  @param numberOfMatches An integer value for the numberOfMatches
                  member variable
                  @param newValue A Value to be stored in the newValue member
                  variable
.                 @return true on success, false on failure.
            */
      bool Init( bool match, int numberOfMatches, classad::Value &newValue );

            /** Generate a string representation of the ConditionExplain
                  @param buffer A string to print the result to.
                  @return true on success, false on failure.
            */ 
      bool ToString( std::string &buffer );
};

/** A derived class of Explain used to suggest a modification to an attribute
      of a ClassAd. */
00200 class AttributeExplain: Explain
{
 public:
00203       enum Suggestion
      {
00205       /** no suggestion */ NONE,
00206       /** modify the value */ MODIFY
      };

            /** The attribute to be modified or left alone */
00210       std::string attribute;

            /** The suggestion for what to do with the attribute */
00213       Suggestion suggestion;

            /** true if suggesting a range of values, false if suggesting a
                  discrete value */
00217       bool isInterval;

            /** A value for the attribute to be modified to */
00220       classad::Value discreteValue;

            /** A range of values for the attribute to be modified to */
00223       Interval *intervalValue;

            /** Default Constructor */
      AttributeExplain( );

            /** Destructor */
      ~AttributeExplain( );

            /** Initializes the ClassAdExplain.  suggestion is set to NONE.
                  @param _attribute A string representing an attribute to be left
                  alone.*/
      bool Init( std::string _attribute );

            /** Initializes the ClassAdExplain.  suggestion is set to MODIFY.
                  The suggestion is to replace the value of the attribute with
                  the value represented by discreteValue.
                  @param _attribute A string representing an attribute to modify
                  @param _discreteValue The suggested new value for the attribute.
            */
      bool Init( std::string _attribute, classad::Value &_discreteValue );

            /** Initializes the ClassAdExplain.  suggestion is set to MODIFY.
                  The suggestion is to replace the value of the attribute with
                  a value in the range represented by intervalValue.
                  @param _attribute A string representing an attribute to modify
                  @param _intervalValue The suggested range for the new value for the
                  attribute.
            */
      bool Init( std::string _attribute, Interval *_intervalValue );

            /** Generate a string representation of the AttributeExplain
                  @param buffer A string to print the result to.
                  @return true on success, false on failure.
            */ 
      bool ToString( std::string &buffer );
};

/** A derived class of Explain used to suggest modification of attributes of a
      ClassAd. */
00262 class ClassAdExplain: Explain
{
 public:

            /** A list of attributes that are undefined in the ClassAd */
00267       List<std::string> undefAttrs;

            /** A list of AttrExplain objects corresponding attributes in the
                  ClassAd.*/
00271       List<AttributeExplain> attrExplains;

            /** Default Constructor */
      ClassAdExplain( );

            /** Destructor */
      ~ClassAdExplain( );

            /** Initializes the ClassAdExplain.
                  @param _undefAttrs A list of strings which will be copied
                  @param _attrExplains A list of pointers to AttrExplain objects. The
                  pointers are copied into attrExplains, the objects are not copied.
            */
      bool Init( List<std::string> &_undefAttrs,
                     List<AttributeExplain> &_attrExplains );

            /** Generate a string representation of the ClassAdExplain
                  @param buffer A string to print the result to.
                  @return true on success, false on failure.
            */ 
      bool ToString( std::string &buffer );
};
#endif      // __EXPLAIN_H__


Generated by  Doxygen 1.6.0   Back to index