5 #include "cetlib/LibraryManager.h" 16 using cet::LibraryManager;
20 std::string
const regex_prefix{
"([-A-Za-z0-9]*_)*"};
21 std::regex
const slash{
"/"};
22 std::regex
const artPrefix{R
"(\S*art/.*)"}; 25 plugin_suffix(std::size_t
const sz)
27 return sz != 1ull ?
"s" :
"";
33 StatusBar(std::string
const& libType,
34 std::size_t
const width,
35 std::size_t
const denom,
37 : libType_{libType}, w_{width}, d_{denom}, v_{verbose}
50 print_progress(std::size_t
const num)
const 54 std::size_t
const per{100 * num / d_};
55 std::cerr <<
" Loaded " << std::setw(w_) <<
std::right << num <<
'/' 56 << d_ <<
" " << libType_ << plugin_suffix(d_) <<
" (" << per
57 <<
"%) " << std::flush;
62 std::string
const libType_;
69 pattern(std::string
const& spec)
71 std::string
const canonSpec = std::regex_replace(spec, slash,
"_");
72 return regex_prefix + canonSpec +
"_";
76 getProvider(std::string
const& fullSpec)
78 return std::regex_search(fullSpec, artPrefix) ?
"art" :
"user";
81 inline std::vector<std::string>
82 getLibraries(LibraryManager
const& lm)
84 std::vector<std::string> result;
85 lm.getLoadableLibraries(result);
92 bool const print_only_message = (spec ==
"scheduler");
95 if (print_only_message || print_available_services) {
98 std::make_pair(
"scheduler",
""),
110 messagefacility_included(std::string
const& spec,
113 bool const print_only_message = (spec ==
"message");
116 if (print_only_message || print_available_services) {
119 std::make_pair(
"message",
""),
121 "https://cdcvs.fnal.gov/redmine/projects/art/wiki/Messagefacility ]",
135 fhicl_name(std::string
const& suffix)
138 return "<module_label>";
141 return "<plugin_label>";
144 return "<tool_label>";
150 return "<destination_label>";
153 return "<statistics_destination_label>";
159 collection_for_plugins(std::string
const& suffix,
160 std::string
const& spec,
164 LibraryManager
const lm{suffix, pattern(spec)};
166 auto const& libs = getLibraries(lm);
167 auto const sz = libs.size();
169 StatusBar
const status_bar{lm.libType(),
w, sz, verbose};
170 for (
auto const& lib : libs) {
171 auto const& libspecs = lm.getSpecsByPath(lib);
172 std::string
const& spec =
173 libspecs.second.empty() ? libspecs.first : libspecs.second;
182 status_bar.print_progress(++i);
188 collection_for_services(std::string
const& spec,
bool const verbose)
191 std::set<std::string>
const systemServicesToIgnore{
"TriggerNamesService"};
194 auto libs = getLibraries(lm);
197 libs.erase(std::remove_if(libs.begin(),
199 [&lm, &systemServicesToIgnore](
auto const& path) {
200 return cet::search_all(
201 systemServicesToIgnore,
202 lm.getSpecsByPath(path).first);
208 StatusBar
const status_bar{
212 for (
auto const& lib : libs) {
213 auto const& libspecs = lm.getSpecsByPath(lib);
214 auto const& [shortspec, fullspec] = libspecs;
220 lm, shortspec, shortspec),
221 getProvider(fullspec),
224 status_bar.print_progress(++i);
226 if (scheduler_included(spec, result)) {
227 status_bar.print_progress(++i);
229 if (messagefacility_included(spec, result)) {
230 status_bar.print_progress(++i);
240 std::string
const& pattern,
244 return collection_for_services(pattern, verbose);
246 return collection_for_plugins(suffix, pattern, verbose);
std::string getType(cet::LibraryManager const &lm, std::string const &fullSpec)
static std::string const & mfStatsPlugin()
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
LibraryInfoCollection get_LibraryInfoCollection(std::string const &suffix, std::string const &pattern, bool verbose=false)
static std::string const & source()
std::unique_ptr< fhicl::ConfigurationTable > getAllowedConfiguration(cet::LibraryManager const &lm, std::string const &fullSpec, std::string const &name)
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
std::string getFilePath(cet::LibraryManager const &lm, std::string const &fullspec)
static std::string const & plugin()
static std::string const & tool()
static std::string const & mfPlugin()
static std::string const & service()
static std::string const & module()
constexpr char const * dflt_spec_pattern()
std::multiset< LibraryInfo > LibraryInfoCollection