Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Private Member Functions | Static Private Attributes
Arc::RSL Class Reference

#include <RSLParser.h>

Inheritance diagram for Arc::RSL:
Inheritance graph
[legend]
Collaboration diagram for Arc::RSL:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RSL ()
virtual ~RSL ()
RSLEvaluate () const
virtual void Print (std::ostream &os=std::cout) const =0

Private Member Functions

RSLEvaluate (std::map< std::string, std::string > &vars) const

Static Private Attributes

static Logger logger

Detailed Description

Definition at line 136 of file RSLParser.h.


Constructor & Destructor Documentation

Definition at line 187 of file RSLParser.cpp.

{}
Arc::RSL::~RSL ( ) [virtual]

Definition at line 189 of file RSLParser.cpp.

{}

Member Function Documentation

RSL * Arc::RSL::Evaluate ( ) const

Definition at line 191 of file RSLParser.cpp.

                           {
    const RSLBoolean *b = dynamic_cast<const RSLBoolean*>(this);
    if (b && (b->Op() == RSLMulti)) {
      RSLBoolean *result = new RSLBoolean(RSLMulti);
      for (std::list<RSL*>::const_iterator it = b->begin();
           it != b->end(); it++) {
        RSL *rsl = (*it)->Evaluate();
        if (!rsl) {
          std::stringstream ss;
          ss << **it;
          logger.msg(ERROR, "RLS (inside multi) could not be evaluated: %s",
                     ss.str());
          delete rsl;
          return NULL;
        }
        result->Add(rsl);
      }
      return result;
    }
    else {
      std::map<std::string, std::string> vars;
      RSL *result = Evaluate(vars);
      if (!result) {
        std::stringstream ss;
        ss << *this;
        logger.msg(ERROR, "RLS could not be evaluated: %s", ss.str());
        return NULL;
      }
      return result;
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

RSL * Arc::RSL::Evaluate ( std::map< std::string, std::string > &  vars) const [private]

Definition at line 223 of file RSLParser.cpp.

                                                             {
    const RSLBoolean *b;
    const RSLCondition *c;
    if ((b = dynamic_cast<const RSLBoolean*>(this))) {
      if (b->Op() == RSLMulti) {
        logger.msg(ERROR, "RSL multi operator not at top level");
        return NULL;
      }
      else {
        RSLBoolean *result = new RSLBoolean(b->Op());
        std::map<std::string, std::string> vars2(vars);
        for (std::list<RSL*>::const_iterator it = b->begin();
             it != b->end(); it++) {
          RSL *rsl = (*it)->Evaluate(vars2);
          if (!rsl) {
            std::stringstream ss;
            ss << **it;
            logger.msg(ERROR, "Can't evaluate RLS fragment: %s", ss.str());
            delete rsl;
            return NULL;
          }
          result->Add(rsl);
        }
        return result;
      }
    }
    else if ((c = dynamic_cast<const RSLCondition*>(this))) {
      RSLList *l = new RSLList;
      if (c->Attr() == "rslsubstitution") // Underscore, in 'rsl_substitution', is removed by normalization.
        for (std::list<RSLValue*>::const_iterator it = c->begin();
             it != c->end(); it++) {
          const RSLSequence *s = dynamic_cast<const RSLSequence*>(*it);
          if (!s) {
            std::stringstream ss;
            ss << **it;
            logger.msg(ERROR, "RLS substitution is not a sequence: %s",
                       ss.str());
            delete l;
            return NULL;
          }
          if (s->size() != 2) {
            std::stringstream ss;
            ss << *s;
            logger.msg(ERROR, "RLS substitution sequence is not of "
                       "length 2: %s", ss.str());
            delete l;
            return NULL;
          }
          std::list<RSLValue*>::const_iterator it2 = s->begin();
          RSLValue *var = (*it2)->Evaluate(vars);
          if (!var) {
            std::stringstream ss;
            ss << **it2;
            logger.msg(ERROR, "Can't evaluate RLS substitution variable "
                       "name: %s", ss.str());
            delete l;
            return NULL;
          }
          it2++;
          RSLValue *val = (*it2)->Evaluate(vars);
          if (!val) {
            std::stringstream ss;
            ss << **it2;
            logger.msg(ERROR, "Can't evaluate RLS substitution variable "
                       "value: %s", ss.str());
            delete l;
            delete var;
            return NULL;
          }
          RSLLiteral *nvar = dynamic_cast<RSLLiteral*>(var);
          if (!nvar) {
            std::stringstream ss;
            ss << *var;
            logger.msg(ERROR, "RLS substitution variable name does not "
                       "evaluate to a literal: %s", ss.str());
            delete l;
            delete var;
            delete val;
            return NULL;
          }
          RSLLiteral *nval = dynamic_cast<RSLLiteral*>(val);
          if (!nval) {
            std::stringstream ss;
            ss << *val;
            logger.msg(ERROR, "RLS substitution variable value does not "
                       "evaluate to a literal: %s", ss.str());
            delete l;
            delete var;
            delete val;
            return NULL;
          }
          vars[nvar->Value()] = nval->Value();
          RSLList *seq = new RSLList;
          seq->Add(var);
          seq->Add(val);
          l->Add(new RSLSequence(seq));
        }
      else
        for (std::list<RSLValue*>::const_iterator it = c->begin();
             it != c->end(); it++) {
          RSLValue *v = (*it)->Evaluate(vars);
          if (!v) {
            std::stringstream ss;
            ss << **it;
            logger.msg(ERROR, "Can't evaluate RSL condition value: %s",
                       ss.str());
            delete l;
            return NULL;
          }
          l->Add(v);
        }
      return new RSLCondition(c->Attr(), c->Op(), l);
    }
    else {
      logger.msg(ERROR, "Unknown RSL type - should not happen");
      return NULL;
    }
  }

Here is the call graph for this function:

virtual void Arc::RSL::Print ( std::ostream &  os = std::cout) const [pure virtual]

Implemented in Arc::RSLCondition, and Arc::RSLBoolean.


Member Data Documentation

Logger Arc::RSL::logger [static, private]

Definition at line 144 of file RSLParser.h.


The documentation for this class was generated from the following files: