artdaq  v3_09_00
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 
60  std::string GetUnidentifiedInstanceName() const { return nameHelper_->GetUnidentifiedInstanceName(); }
61 
62 protected:
63  std::shared_ptr<artdaq::FragmentNameHelper> nameHelper_;
64 
65 private:
70 };
71 DECLARE_ART_SERVICE_INTERFACE(ArtdaqFragmentNamingServiceInterface, LEGACY)
72 
73 // ----------------------------------------------------------------------
74 
75 
80 {
81 public:
85  virtual ~ArtdaqFragmentNamingService();
86 
91  ArtdaqFragmentNamingService(fhicl::ParameterSet const& pset, art::ActivityRegistry&);
92 
93 private:
96  ArtdaqFragmentNamingService& operator=(ArtdaqFragmentNamingService const&) = delete;
98 };
99 
100 DECLARE_ART_SERVICE_INTERFACE_IMPL(ArtdaqFragmentNamingService, ArtdaqFragmentNamingServiceInterface, LEGACY)
101 
102 #endif /* artdaq_ArtModules_ArtdaqFragmentNamingService_h */
103 
104 // Local Variables:
105 // mode: c++
106 // 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::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 ...