|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | + |
| 11 | +#ifndef O2_DCS_ALIAS_EXPANDER_H |
| 12 | +#define O2_DCS_ALIAS_EXPANDER_H |
| 13 | + |
| 14 | +#include <vector> |
| 15 | +#include <string> |
| 16 | + |
| 17 | +namespace o2::dcs |
| 18 | +{ |
| 19 | +/** |
| 20 | + * expandAlias converts a single pattern into a list of strings. |
| 21 | + * |
| 22 | + * @param pattern a pattern is made of a number of "XX[YY]" blocks (at least one) |
| 23 | + * |
| 24 | + * where : |
| 25 | + * - XX is any text |
| 26 | + * - YY describes either a integral range or a textual list |
| 27 | + * |
| 28 | + * An integral range is [a..b] where the formatting of the biggest of the |
| 29 | + * two integers a and b dictates, by default, the formatting of the output |
| 30 | + * alias. For instance [0..3] is expanded to the set 0,1,2,3 while [00..03] |
| 31 | + * is expanded to 00,01,02,03. If you want more control on the formatting, |
| 32 | + * you can use a python/fmt format {} e.g. [0..15{:d}] would yields 0,1, |
| 33 | + * 2,...,14,15 simply (no 0 filling). |
| 34 | + * |
| 35 | + * A textual list is simply a list of values separated by commas, |
| 36 | + * e.g. "vMon,iMon" |
| 37 | + * |
| 38 | + * @returns a vector of strings containing all the possible expansions of |
| 39 | + * the pattern. That vector is not guaranteed to be sorted. |
| 40 | + * |
| 41 | + * For example, pattern=DET[A,B]/Channel[000,002]/[iMon,vMon] yields : |
| 42 | + * |
| 43 | + * - DETA/Channel000/iMon |
| 44 | + * - DETA/Channel001/iMon |
| 45 | + * - DETA/Channel002/iMon |
| 46 | + * - DETA/Channel000/vMon |
| 47 | + * - DETA/Channel001/vMon |
| 48 | + * - DETA/Channel002/vMon |
| 49 | + * - DETB/Channel000/iMon |
| 50 | + * - DETB/Channel001/iMon |
| 51 | + * - DETB/Channel002/iMon |
| 52 | + * - DETB/Channel000/vMon |
| 53 | + * - DETB/Channel001/vMon |
| 54 | + * - DETB/Channel002/vMon |
| 55 | +
|
| 56 | +*/ |
| 57 | +std::vector<std::string> expandAlias(const std::string& pattern); |
| 58 | + |
| 59 | +/** expandAliases converts a list of patterns into a list of strings. |
| 60 | + * |
| 61 | + * each input pattern is treated by expandAlias() |
| 62 | + * |
| 63 | + * @returns a _sorted_ vector of strings containing all the possible |
| 64 | + * expansions of the pattern. |
| 65 | + */ |
| 66 | +std::vector<std::string> expandAliases(const std::vector<std::string>& patternedAliases); |
| 67 | +} // namespace o2::dcs |
| 68 | + |
| 69 | +#endif |
0 commit comments