CMS 3D CMS Logo

Node.h

Go to the documentation of this file.
00001 #ifndef FWCore_ParameterSet_Node_h
00002 #define FWCore_ParameterSet_Node_h
00003 
00004 #include <iosfwd>
00005 #include <list>
00006 #include <map>
00007 #include <vector>
00008 #include <string>
00009 #include "boost/shared_ptr.hpp"
00010 
00011 namespace edm {
00012 
00013   class Entry;
00014   class ParameterSet;
00015   class ProcessDesc;
00016 
00017   namespace pset {
00018 
00019     class Visitor;
00020     class ReplaceNode;
00021 
00022     // Base type for all nodes.  All nodes have a type associated
00023     // with them - this is basically the keyword that caused the
00024     // generation of this node.  All nodes have a name - this is the
00025     // name assigned to the entity
00026 
00027     class Node
00028     {
00029     public:
00030       Node(std::string const& n, int li);
00031 
00032       std::string name() const {return name_;}
00033       void setName(const std::string & n) {name_ = n;}
00034       int line() const {return line_;}
00035 
00037       virtual Node * clone() const = 0;
00038 
00039       typedef boost::shared_ptr<Node> Ptr;
00040 
00041       virtual std::string type() const = 0;
00042 
00043       virtual void  setParent(Node*  parent) { parent_ = parent;}
00044       virtual Node* getParent() const { return parent_; }
00045       bool isInclude() const;
00047       virtual const Node * getIncludeParent() const;
00049       std::string includeParentSuffix() const;
00050            
00051 
00053       virtual void setAsChildrensParent() {}
00056       virtual bool findChild(const std::string & child, boost::shared_ptr<Node> & result) {return false;}
00058       virtual void validate() const {}
00059 
00060 
00062       virtual void dotDelimitedPath(std::string & path) const;
00065       virtual void printTrace(std::ostream& ost) const;
00067       std::string traceback() const;
00068 
00071       virtual void locate(const std::string & s, std::ostream& ost) const;
00072 
00074       enum PrintOptions { COMPRESSED, EXPANDED };
00075       virtual void print(std::ostream& ost, PrintOptions options=COMPRESSED) const = 0;
00076       virtual ~Node();
00077       virtual void accept(Visitor& v) const = 0;
00078 
00079       virtual void setModified(bool value);
00080       virtual bool isModified() const {return modified_;}
00081 
00083       virtual void setCloned(bool value) {cloned_ = value;}
00084       virtual bool isCloned() const {return cloned_;}
00085 
00087       virtual bool isTracked() const {return false;}
00088       virtual bool isReplaceable() const {return false;}
00089       virtual void replaceWith(const ReplaceNode * replaceNode);
00090 
00091       typedef std::map<std::string, Ptr> NodeMap;
00093       virtual void resolve(std::list<std::string> & openFiles, 
00094                            std::list<std::string> & sameLevelIncludes,
00095                            bool strict) {}
00096       virtual void resolveUsingNodes(const NodeMap & blocks, bool strict) {}
00097 
00100       virtual void insertInto(ProcessDesc & procDesc) const;
00103       virtual void insertInto(edm::ParameterSet & pset) const;
00105       virtual edm::Entry makeEntry() const;
00106 
00107 
00108     private:
00109       std::string name_;
00110       int         line_;
00111       // nodes can only be modified once, so the config files can be order-independent
00112       bool modified_;
00113       bool cloned_;
00114       Node * parent_;
00115     };
00116 
00117     typedef boost::shared_ptr<Node>        NodePtr;
00118     typedef std::vector<std::string>       StringList;
00119     typedef boost::shared_ptr<StringList>  StringListPtr;
00120     typedef std::list<NodePtr>             NodePtrList;
00121     typedef boost::shared_ptr<NodePtrList> NodePtrListPtr;
00122     typedef NodePtrListPtr                 ParseResults;
00123 
00124     inline std::ostream& operator<<(std::ostream& ost, NodePtr p)
00125     {
00126       p->print(ost, Node::COMPRESSED);
00127       return ost;
00128     }
00129 
00130     inline std::ostream& operator<<(std::ostream& ost, const Node& p)
00131     {
00132       p.print(ost, Node::COMPRESSED);
00133       return ost;
00134     }
00135 
00136   }
00137 }
00138 
00139 #endif
00140 

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