CMS 3D CMS Logo

RenamedIncludeNode.cc

Go to the documentation of this file.
00001 #include "FWCore/ParameterSet/interface/RenamedIncludeNode.h"
00002 #include "FWCore/Utilities/interface/EDMException.h"
00003 #include <iosfwd>
00004 
00005 namespace edm {
00006   namespace pset {
00007 
00008     RenamedIncludeNode::RenamedIncludeNode(const std::string & type, const std::string & name,
00009                          const std::string & targetType, const std::string & newName, 
00010                          const std::string & targetName, int line)
00011     : IncludeNode("includeRenamed", name, line),
00012       targetType_(targetType),
00013       newName_(newName),
00014       targetName_(targetName)
00015     {
00016     }
00017 
00018 
00019     bool RenamedIncludeNode::checkTarget(NodePtr node) const
00020     {
00021       bool result = ( node->name() == targetName_ );
00022       if( result )
00023       {
00024         // check that the type was specified correctly
00025         if(node->type() != targetType_)
00026         {
00027           throw edm::Exception(errors::Configuration)
00028             << "Included node " << newName_
00029             << "is of type " << node->type()
00030             << ", not " <<  targetType_
00031             << "\nfrom " << traceback();
00032         }
00033         node->setName(newName_);
00034         node->setCloned(true);
00035       }
00036       // always true, but might have to rename a node
00037       return result;
00038     }
00039 
00040 
00041     bool RenamedIncludeNode::check(bool strict) const
00042     {
00043       //@@ doesn't check for things like multiple modules in a file
00044       bool found = false;
00045       for(NodePtrList::iterator nodeItr = nodes_->begin(), nodeItrEnd = nodes_->end();
00046           !found && nodeItr != nodeItrEnd; ++nodeItr)
00047       {
00048         found = checkTarget(*nodeItr);
00049       }
00050 
00051       if(!found)
00052       {
00053         throw edm::Exception(errors::Configuration)
00054           << "Could not find node " << targetName_
00055           << " in file " << name()
00056           << "\nfrom " << traceback();
00057       }
00058       return found;
00059     }
00060 
00061 
00062     void RenamedIncludeNode::print(std::ostream & out, 
00063                                    Node::PrintOptions options) const
00064     {
00065       if(options == COMPRESSED  && !isModified())
00066       {
00067         out << targetType_ << " " << newName_ << " = " << targetName_ 
00068             << " from \"" << name() << "\"\n";
00069       }
00070       else
00071       {
00072         // expand
00073         IncludeNode::print(out, options);
00074       }
00075     }
00076 
00077   }
00078 }
00079 

Generated on Tue Jun 9 17:36:31 2009 for CMSSW by  doxygen 1.5.4