Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:18

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   /// replaces searchString with replaceString at it's first occurance in string
0041   static const bool findAndReplaceString(std::string &paramString,
0042                                          const std::string &searchString,
0043                                          const std::string &replaceString);
0044   /// opens a template file. If the header information shall be parsed intern has to be set to true
0045   bool open(const std::string &fileName, bool internal = false);
0046   /// saves the content of the template file to a local file (the content of parameterMap_ will not be saved!)
0047   bool save(const std::string &fileName);
0048   bool close();
0049   /// replaces searchString with replaceString
0050   bool substitute(const std::string &searchString, const std::string &replaceString);
0051   /// replaces the whole line containing atLine and inserts content instead of it
0052   bool insert(const std::string &atLine, const std::vector<std::string> &content);
0053   /// replaces the whole line containing atLine with the content of file
0054   bool insert(const std::string atLine, const L1GtVhdlTemplateFile &file);
0055   /// prints the content of the VHDL File (only lines_)
0056   void print() const;
0057   /// prints the parameter map
0058   void printParameterMap() const;
0059   /// returns a string vector with the current content of the VHDL File
0060   std::vector<std::string> returnLines() const;
0061   /// returns parameter map
0062   std::map<std::string, std::string> returnParameterMap() const;
0063   /// returns a vector with all substitution parameters that are found in the template file
0064   std::vector<std::string> getSubstitutionParametersFromTemplate() const;
0065   /// finds all substitution parameters in str and collects them in the vector parameters.
0066   /// This routine is used by getSubstitutionParametersFromTemplate();
0067   bool extractParametersFromString(const std::string &str, std::vector<std::string> &parameters) const;
0068   /// adds a line at the end of the the file with the content of str
0069   void append(const std::string &str);
0070   /// adds the content of file at the end of (*this); the parameter map won't be changed
0071   void append(const L1GtVhdlTemplateFile &file);
0072   /// removes all lines that contain the str
0073   bool removeLineWithContent(const std::string &str);
0074   /// deletes all empty lines in a template file
0075   bool removeEmptyLines();
0076   /// checks weather a char is a blank
0077   bool isBlank(const char &chr) const;
0078   /// seperates a string at all blanks and saves the elements in result
0079   bool split(const std::string &param, std::vector<std::string> &result) const;
0080   /// extracts all conditions from a algorithm
0081   void getConditionsFromAlgo(std::string condString, std::vector<std::string> &result) const;
0082   /// returns a string with the content of vector lines
0083   std::string lines2String() const;
0084   /// returns a parameter of a internal template file
0085   std::string getInternalParameter(const std::string &indentifier);
0086 };
0087 #endif /*L1GtConfigProducers_L1GtVhdlTemplateFile_h*/