artdaq  v3_12_02
ArtdaqFragmentNamingService.h
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 
15 {
16 public:
20  virtual ~ArtdaqFragmentNamingServiceInterface() = default;
21 
30  ArtdaqFragmentNamingServiceInterface(fhicl::ParameterSet const& ps)
31  : nameHelper_(nullptr)
32  {
33  auto unidentified_instance_name = ps.get<std::string>("unidentified_instance_name", "unidentified");
34  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  auto fragmentNameHelperPluginType = ps.get<std::string>("helper_plugin", "Artdaq");
36 
37  nameHelper_ = artdaq::makeNameHelper(fragmentNameHelperPluginType, unidentified_instance_name, extraTypes);
38  }
39 
43  std::string GetInstanceNameForType(artdaq::Fragment::type_t type_id) const { return nameHelper_->GetInstanceNameForType(type_id); }
44 
51  std::set<std::string> GetAllProductInstanceNames() const { return nameHelper_->GetAllProductInstanceNames(); }
52 
60  std::pair<bool, std::string>
61  GetInstanceNameForFragment(artdaq::Fragment const& fragment) const { return nameHelper_->GetInstanceNameForFragment(fragment); }
62 
67  std::string GetUnidentifiedInstanceName() const { return nameHelper_->GetUnidentifiedInstanceName(); }
68 
69 protected:
70  std::shared_ptr<artdaq::FragmentNameHelper> nameHelper_;
71 
72 private:
77 };
78 DECLARE_ART_SERVICE_INTERFACE(ArtdaqFragmentNamingServiceInterface, LEGACY)
79 
80 #endif /* artdaq_ArtModules_ArtdaqFragmentNamingService_h */
81 
82 // Local Variables:
83 // mode: c++
84 // End:
ArtdaqFragmentNamingServiceInterface(fhicl::ParameterSet const &ps)
ArtdaqFragmentNamingServiceInterface constructor.
virtual ~ArtdaqFragmentNamingServiceInterface()=default
Default virtual destructor.
std::pair< bool, std::string > GetInstanceNameForFragment(artdaq::Fragment const &fragment) const
Returns the product instance name for the specified fragment, based on the types that have been speci...
std::set< std::string > GetAllProductInstanceNames() const
Returns the full set of product instance names which may be present in the data, based on the types t...
std::shared_ptr< artdaq::FragmentNameHelper > nameHelper_
FragmentNameHelper plugin used to resolve Fragment names.
std::string GetUnidentifiedInstanceName() const
Get the name used for unidentified Fragment types.
std::string GetInstanceNameForType(artdaq::Fragment::type_t type_id) const
Returns the basic translation for the specified type. Must be implemented by derived classes...
Interface for ArtdaqFragmentNamingService. This interface is declared to art as part of the required ...