Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-30 02:33:06

0001 #ifndef FWCore_PluginManager_CacheParser_h
0002 #define FWCore_PluginManager_CacheParser_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     PluginManager
0006 // Class  :     CacheParser
0007 //
0008 /**\class CacheParser CacheParser.h FWCore/PluginManager/interface/CacheParser.h
0009 
0010  Description: Parses the cache information about which plugins are in which libraries
0011 
0012  Usage:
0013     The format expected is line oriented, with each lying containing
0014 
0015     <file name> <plugin name> <plugin type>
0016 
0017 If a space exists in either of these three fields, it will be replaced with a %, E.g.
0018     /local/lib/pluginFoo.so Widget Fabulous%Bar%Stuff
0019 
0020 */
0021 //
0022 // Original Author:  Chris Jones
0023 //         Created:  Wed Apr  4 14:30:51 EDT 2007
0024 //
0025 
0026 // system include files
0027 #include <filesystem>
0028 #include <iosfwd>
0029 #include <string>
0030 #include <map>
0031 #include <vector>
0032 // user include files
0033 #include "FWCore/PluginManager/interface/PluginInfo.h"
0034 
0035 // forward declarations
0036 class TestCacheParser;
0037 
0038 namespace edmplugin {
0039   class CacheParser {
0040   public:
0041     typedef std::map<std::string, std::vector<PluginInfo> > CategoryToInfos;
0042     typedef std::pair<std::string, std::string> NameAndType;
0043     typedef std::vector<NameAndType> NameAndTypes;
0044     typedef std::map<std::filesystem::path, NameAndTypes> LoadableToPlugins;
0045 
0046     CacheParser(const CacheParser&) = delete;                   // stop default
0047     const CacheParser& operator=(const CacheParser&) = delete;  // stop default
0048 
0049     // ---------- const member functions ---------------------
0050 
0051     // ---------- static member functions --------------------
0052 
0053     // ---------- member functions ---------------------------
0054     /**The std::vector<PluginInfo>'s in CategoryToInfos are guaranteed to be ordered by
0055         PluginInfo.name_ where identical names are ordered by the order they are passed to read.
0056         In this way multiple calls to read for different directories will preserve the ordering
0057         */
0058     static void read(std::istream&, const std::filesystem::path& iDirectory, CategoryToInfos& oOut);
0059     static void write(const CategoryToInfos&, std::ostream&);
0060 
0061     static void read(std::istream&, LoadableToPlugins& oOut);
0062     static void write(LoadableToPlugins& iIn, std::ostream&);
0063 
0064   private:
0065     //for testing
0066     friend class ::TestCacheParser;
0067 
0068     static bool readline(std::istream& iIn,
0069                          const std::filesystem::path& iDirectory,
0070                          unsigned long iRecordNumber,
0071                          PluginInfo& oInfo,
0072                          std::string& oPluginType);
0073     static std::string& replaceSpaces(std::string& io);
0074     static std::string& restoreSpaces(std::string& io);
0075 
0076     // ---------- member data --------------------------------
0077   };
0078 
0079 }  // namespace edmplugin
0080 #endif