artdaq  v3_11_02
ArtdaqFragmentNamingService.h
1 #ifndef artdaq_ArtModules_ArtdaqFragmentNamingService_h
2 #define artdaq_ArtModules_ArtdaqFragmentNamingService_h
3 
4 #include "art/Framework/Services/Registry/ServiceMacros.h"
5 #include "artdaq-core/Data/FragmentNameHelper.hh"
6 #include "fhiclcpp/types/Atom.h"
7 
12 {
13 public:
17  virtual ~ArtdaqFragmentNamingServiceInterface() = default;
18 
27  ArtdaqFragmentNamingServiceInterface(fhicl::ParameterSet const& ps)
28  : nameHelper_(nullptr)
29  {
30  auto unidentified_instance_name = ps.get<std::string>("unidentified_instance_name", "unidentified");
31  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>>());
32  auto fragmentNameHelperPluginType = ps.get<std::string>("helper_plugin", "Artdaq");
33 
34  nameHelper_ = artdaq::makeNameHelper(fragmentNameHelperPluginType, unidentified_instance_name, extraTypes);
35  }
36 
40  std::string GetInstanceNameForType(artdaq::Fragment::type_t type_id) const { return nameHelper_->GetInstanceNameForType(type_id); }
41 
48  std::set<std::string> GetAllProductInstanceNames() const { return nameHelper_->GetAllProductInstanceNames(); }
49 
57  std::pair<bool, std::string>
58  GetInstanceNameForFragment(artdaq::Fragment const& fragment) const { return nameHelper_->GetInstanceNameForFragment(fragment); }
59 
64  std::string GetUnidentifiedInstanceName() const { return nameHelper_->GetUnidentifiedInstanceName(); }
65 
66 protected:
67  std::shared_ptr<artdaq::FragmentNameHelper> nameHelper_;
68 
69 private:
74 };
75 DECLARE_ART_SERVICE_INTERFACE(ArtdaqFragmentNamingServiceInterface, LEGACY)
76 
77 // ----------------------------------------------------------------------
78 
79 
84 {
85 public:
89  virtual ~ArtdaqFragmentNamingService();
90 
95  ArtdaqFragmentNamingService(fhicl::ParameterSet const& pset, art::ActivityRegistry&);
96 
97 private:
100  ArtdaqFragmentNamingService& operator=(ArtdaqFragmentNamingService const&) = delete;
102 };
103 
104 DECLARE_ART_SERVICE_INTERFACE_IMPL(ArtdaqFragmentNamingService, ArtdaqFragmentNamingServiceInterface, LEGACY)
105 
106 #endif /* artdaq_ArtModules_ArtdaqFragmentNamingService_h */
107 
108 // Local Variables:
109 // mode: c++
110 // 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...
ArtdaqFragmentNamingService extends ArtdaqFragmentNamingServiceInterface. This implementation uses th...
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 ...