Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:14:14

0001 #ifndef L1GtConfigProducers_L1GtVhdlTemplateFile_h
0002 #define L1GtConfigProducers_L1GtVhdlTemplateFile_h
0003 
0004 /**
0005  * \class L1GtVhdlTemplateFile
0006  *
0007  *
0008  * \Description The routines of this class provide all necessary features to deal with the VHDL
0009  *  templates for the firmware code of the GT
0010  *
0011  * Implementation:
0012  *    <TODO: enter implementation details>
0013  *
0014  * \author Philipp Wagner
0015  *
0016  *
0017  */
0018 
0019 // system include files
0020 
0021 #include <map>
0022 #include <string>
0023 #include <vector>
0024 
0025 class L1GtVhdlTemplateFile {
0026 private:
0027   /// internal files additionally have entries in parameterMap_
0028   /// for "normal" files parameterMap is empty
0029   bool intern_;
0030   /// containing the content of the VHDL file
0031   std::vector<std::string> lines_;
0032   /// containing the header information of internal files
0033   std::map<std::string, std::string> parameterMap_;
0034 
0035 public:
0036   /// standard constructor
0037   L1GtVhdlTemplateFile();
0038   /// constructor with filename
0039   L1GtVhdlTemplateFile(const std::string &filename);
0040   /// copy constructor
0041   L1GtVhdlTemplateFile(const L1GtVhdlTemplateFile &rhs);
0042   /// destructor
0043   ~L1GtVhdlTemplateFile();
0044   /// replaces searchString with replaceString at it's first occurance in string
0045   static const bool findAndReplaceString(std::string &paramString,
0046                                          const std::string &searchString,
0047                                          const std::string &replaceString);
0048   /// opens a template file. If the header information shall be parsed intern has to be set to true
0049   bool open(const std::string &fileName, bool internal = false);
0050   /// saves the content of the template file to a local file (the content of parameterMap_ will not be saved!)
0051   bool save(const std::string &fileName);
0052   bool close();
0053   /// replaces searchString with replaceString
0054   bool substitute(const std::string &searchString, const std::string &replaceString);
0055   /// replaces the whole line containing atLine and inserts content instead of it
0056   bool insert(const std::string &atLine, const std::vector<std::string> &content);
0057   /// replaces the whole line containing atLine with the content of file
0058   bool insert(const std::string atLine, const L1GtVhdlTemplateFile &file);
0059   /// prints the content of the VHDL File (only lines_)
0060   void print() const;
0061   /// prints the parameter map
0062   void printParameterMap() const;
0063   /// returns a string vector with the current content of the VHDL File
0064   std::vector<std::string> returnLines() const;
0065   /// returns parameter map
0066   std::map<std::string, std::string> returnParameterMap() const;
0067   /// returns a vector with all substitution parameters that are found in the template file
0068   std::vector<std::string> getSubstitutionParametersFromTemplate() const;
0069   /// finds all substitution parameters in str and collects them in the vector parameters.
0070   /// This routine is used by getSubstitutionParametersFromTemplate();
0071   bool extractParametersFromString(const std::string &str, std::vector<std::string> &parameters) const;
0072   /// adds a line at the end of the the file with the content of str
0073   void append(const std::string &str);
0074   /// adds the content of file at the end of (*this); the parameter map won't be changed
0075   void append(const L1GtVhdlTemplateFile &file);
0076   /// removes all lines that contain the str
0077   bool removeLineWithContent(const std::string &str);
0078   /// deletes all empty lines in a template file
0079   bool removeEmptyLines();
0080   /// checks weather a char is a blank
0081   bool isBlank(const char &chr) const;
0082   /// seperates a string at all blanks and saves the elements in result
0083   bool split(const std::string &param, std::vector<std::string> &result) const;
0084   /// extracts all conditions from a algorithm
0085   void getConditionsFromAlgo(std::string condString, std::vector<std::string> &result) const;
0086   /// returns a string with the content of vector lines
0087   std::string lines2String() const;
0088   /// returns a parameter of a internal template file
0089   std::string getInternalParameter(const std::string &indentifier);
0090 };
0091 #endif /*L1GtConfigProducers_L1GtVhdlTemplateFile_h*/