5 #include "cetlib/LibraryManager.h" 16 using cet::LibraryManager;
20 std::string
const regex_prefix{
"([-A-Za-z0-9]*_)*"};
21 std::regex
const slash{
"/"};
24 plugin_suffix(std::size_t
const sz)
26 return sz != 1ull ?
"s" :
"";
32 StatusBar(std::string
const& libType,
33 std::size_t
const width,
34 std::size_t
const denom,
36 : libType_{libType}, w_{width}, d_{denom}, v_{verbose}
49 print_progress(std::size_t
const num)
const 53 std::size_t
const per{100 * num / d_};
54 std::cerr <<
" Loaded " << std::setw(w_) <<
std::right << num <<
'/' 55 << d_ <<
" " << libType_ << plugin_suffix(d_) <<
" (" << per
56 <<
"%) " << std::flush;
61 std::string
const libType_;
68 pattern(std::string
const& spec)
70 std::string
const canonSpec = std::regex_replace(spec, slash,
"_");
71 return regex_prefix + canonSpec +
"_";
75 getProvider(std::string
const& fullSpec)
77 return std::regex_search(fullSpec, std::regex{R
"(\S*art/.*)"}) ? "art" :
81 inline std::vector<std::string>
82 getLibraries(LibraryManager
const& lm)
84 std::vector<std::string> result;
85 lm.getLoadableLibraries(result);
90 messagefacility_included(std::string
const& spec,
93 bool const print_only_message = (spec ==
"message");
96 if (print_only_message || print_available_services) {
99 std::make_pair(
"message",
""),
101 "https://cdcvs.fnal.gov/redmine/projects/art/wiki/Messagefacility ]",
119 return "<module_label>";
121 return "<plugin_label>";
123 return "<tool_label>";
127 return "<destination_label>";
129 return "<statistics_destination_label>";
133 <<
"' suffix is not supported for function: " << __func__ <<
'\n';
137 template <suffix_type st>
144 auto const& libs = getLibraries(lm);
145 auto const sz = libs.size();
147 StatusBar
const status_bar{lm.libType(),
w, sz, verbose};
148 for (
auto const& lib : libs) {
149 auto const& libspecs = lm.getSpecsByPath(lib);
150 std::string
const& spec =
151 libspecs.second.empty() ? libspecs.first : libspecs.second;
155 getFilePath<st>(lm, spec),
156 getAllowedConfiguration<st>(lm, spec, fhicl_name(st)),
158 getType<st>(lm, spec));
160 status_bar.print_progress(++i);
167 getCollection<suffix_type::service>(std::string
const& spec,
171 std::set<std::string>
const systemServicesToIgnore{
172 "CurrentModule",
"ScheduleContext",
"TriggerNamesService"};
178 auto libs = getLibraries(lm);
181 libs.erase(std::remove_if(libs.begin(),
183 [&lm, &systemServicesToIgnore](
auto const& path) {
184 return cet::search_all(
185 systemServicesToIgnore,
186 lm.getSpecsByPath(path).first);
192 StatusBar
const status_bar{
196 for (
auto const& lib : libs) {
197 auto const& libspecs = lm.getSpecsByPath(lib);
198 std::string
const& spec = libspecs.first;
199 std::string
const& fullspec = libspecs.second;
204 std::make_pair(fclname, fullspec),
205 getFilePath<suffix_type::service>(lm, spec),
206 getAllowedConfiguration<suffix_type::service>(
208 getProvider(fullspec),
209 getType<suffix_type::service>(lm, libspecs.second));
211 status_bar.print_progress(++i);
213 if (messagefacility_included(spec, result)) {
214 status_bar.print_progress(++i);
224 std::string
const& pattern,
229 return getCollection<suffix_type::module>(pattern, verbose);
231 return getCollection<suffix_type::service>(pattern, verbose);
233 return getCollection<suffix_type::source>(pattern, verbose);
235 return getCollection<suffix_type::plugin>(pattern, verbose);
237 return getCollection<suffix_type::tool>(pattern, verbose);
239 return getCollection<suffix_type::mfPlugin>(pattern, verbose);
241 return getCollection<suffix_type::mfStatsPlugin>(pattern, verbose);
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
auto getCollection(Event const &event, OptionalArgs &&...optionalArgs)
Creates a proxy to a data product collection.
constexpr const char * dflt_spec_pattern()
LibraryInfoCollection get_LibraryInfoCollection(suffix_type suffix, std::string const &pattern, bool const verbose=false)
static std::string const & libname(std::string const &fclname)
static std::string const & fclname(std::string const &libname)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
static std::string const & get(suffix_type st)
std::multiset< LibraryInfo > LibraryInfoCollection