Line data Source code
1 : #ifndef artdaq_ArtModules_ArtdaqFragmentNamingService_h
2 : #define artdaq_ArtModules_ArtdaqFragmentNamingService_h
3 :
4 : #include "art/Framework/Services/Registry/ServiceDeclarationMacros.h"
5 : #include "artdaq-core/Plugins/FragmentNameHelper.hh"
6 :
7 : namespace fhicl {
8 : class ParameterSet;
9 : }
10 :
11 : /**
12 : * \brief Interface for ArtdaqFragmentNamingService. This interface is declared to art as part of the required registration of an art Service
13 : */
14 : class ArtdaqFragmentNamingServiceInterface
15 : {
16 : public:
17 : /**
18 : * \brief Default virtual destructor
19 : */
20 0 : virtual ~ArtdaqFragmentNamingServiceInterface() = default;
21 :
22 : /**
23 : * \brief ArtdaqFragmentNamingServiceInterface constructor
24 : * \param ps ParameterSet used to configure ArtdaqFragmentNamingServiceInterface
25 : *
26 : * ArtdaqFragmentNamingServiceInterface accepts the following Parameters:
27 : * "unidentified_instance_name" (Default: "unidentified"): Name to use for any Fragments which are not successfully translated by the ArtdaqFragmentNamingServiceInterface
28 : * "fragment_type_map" (Default: []): A list of Fragment type_t to string pairs for additional types to register with the ArtdaqFragmentNamingServiceInterface
29 : */
30 0 : ArtdaqFragmentNamingServiceInterface(fhicl::ParameterSet const& ps)
31 0 : : nameHelper_(nullptr)
32 : {
33 0 : auto unidentified_instance_name = ps.get<std::string>("unidentified_instance_name", "unidentified");
34 0 : auto extraTypes = ps.get<std::vector<std::pair<artdaq::Fragment::type_t, std::string>>>("fragment_type_map", std::vector<std::pair<artdaq::Fragment::type_t, std::string>>());
35 0 : auto fragmentNameHelperPluginType = ps.get<std::string>("helper_plugin", "Artdaq");
36 :
37 0 : nameHelper_ = artdaq::makeNameHelper(fragmentNameHelperPluginType, unidentified_instance_name, extraTypes);
38 0 : }
39 :
40 : /**
41 : * \brief Returns the basic translation for the specified type. Must be implemented by derived classes
42 : */
43 0 : std::string GetInstanceNameForType(artdaq::Fragment::type_t type_id) const { return nameHelper_->GetInstanceNameForType(type_id); }
44 :
45 : /**
46 : * \brief Returns the full set of product instance names which may be present in the data, based on
47 : * the types that have been specified in the SetBasicTypes() and AddExtraType() methods. This
48 : * *does* include "container" types, if the container type mapping is part of the basic types.
49 : * Must be implemented by derived classes
50 : */
51 0 : std::set<std::string> GetAllProductInstanceNames() const { return nameHelper_->GetAllProductInstanceNames(); }
52 :
53 : /**
54 : * \brief Returns the product instance name for the specified fragment, based on the types that have
55 : * been specified in the SetBasicTypes() and AddExtraType() methods. This *does* include the
56 : * use of "container" types, if the container type mapping is part of the basic types. If no
57 : * mapping is found, the specified unidentified_instance_name is returned.
58 : * Must be implemented by derived classes
59 : */
60 : std::pair<bool, std::string>
61 0 : GetInstanceNameForFragment(artdaq::Fragment const& fragment) const { return nameHelper_->GetInstanceNameForFragment(fragment); }
62 :
63 : /**
64 : * @brief Get the name used for unidentified Fragment types
65 : * @return The name used for unidentified Fragment types
66 : */
67 0 : std::string GetUnidentifiedInstanceName() const { return nameHelper_->GetUnidentifiedInstanceName(); }
68 :
69 : protected:
70 : std::shared_ptr<artdaq::FragmentNameHelper> nameHelper_; ///< FragmentNameHelper plugin used to resolve Fragment names
71 :
72 : private:
73 : ArtdaqFragmentNamingServiceInterface(ArtdaqFragmentNamingServiceInterface const&) = delete;
74 : ArtdaqFragmentNamingServiceInterface(ArtdaqFragmentNamingServiceInterface&&) = delete;
75 : ArtdaqFragmentNamingServiceInterface& operator=(ArtdaqFragmentNamingServiceInterface const&) = delete;
76 : ArtdaqFragmentNamingServiceInterface& operator=(ArtdaqFragmentNamingServiceInterface&&) = delete;
77 : };
78 0 : DECLARE_ART_SERVICE_INTERFACE(ArtdaqFragmentNamingServiceInterface, LEGACY)
79 :
80 : #endif /* artdaq_ArtModules_ArtdaqFragmentNamingService_h */
81 :
82 : // Local Variables:
83 : // mode: c++
84 : // End:
|