1 #ifndef _artdaq_core_Data_FragmentNameHelper_hh_
2 #define _artdaq_core_Data_FragmentNameHelper_hh_
8 #include <cetlib/BasicPluginFactory.h>
9 #include <cetlib/compiler_macros.h>
11 #include "artdaq-core/Data/Fragment.hh"
13 #ifndef EXTERN_C_FUNC_DECLARE_START
14 #define EXTERN_C_FUNC_DECLARE_START \
22 #define DEFINE_ARTDAQ_FRAGMENT_NAME_HELPER(klass) \
23 EXTERN_C_FUNC_DECLARE_START \
24 std::shared_ptr<artdaq::FragmentNameHelper> make(std::string unidentified, std::vector<std::pair<artdaq::Fragment::type_t, std::string>> types) \
26 return std::shared_ptr<artdaq::FragmentNameHelper>(new klass(unidentified, types)); \
47 FragmentNameHelper(std::string unidentified_instance_name, std::vector<std::pair<artdaq::Fragment::type_t, std::string>> extraTypes)
52 for (
auto it = extraTypes.begin(); it != extraTypes.end(); ++it)
61 void SetBasicTypes(std::map<artdaq::Fragment::type_t, std::string>
const& type_map)
63 for (
auto& type_pair : type_map)
65 type_map_[type_pair.first] = type_pair.second;
103 virtual std::pair<bool, std::string>
107 std::map<artdaq::Fragment::type_t, std::string>
type_map_;
117 inline std::shared_ptr<FragmentNameHelper>
118 makeNameHelper(std::string
const& plugin_name, std::string
const& unidentified_instance_name, std::vector<std::pair<artdaq::Fragment::type_t, std::string>> extraTypes)
120 static cet::BasicPluginFactory bpf(
"fragmentNameHelper",
"make");
122 return bpf.makePlugin<std::shared_ptr<FragmentNameHelper>>(plugin_name, unidentified_instance_name, extraTypes);
137 ArtdaqFragmentNameHelper(std::string unidentified_instance_name, std::vector<std::pair<artdaq::Fragment::type_t, std::string>> extraTypes);
158 virtual std::pair<bool, std::string>
169 #endif //_artdaq_core_Data_FragmentNameHelper_hh_
void AddExtraType(artdaq::Fragment::type_t type_id, std::string const &type_name)
Adds an additional type to be translated.
virtual ~ArtdaqFragmentNameHelper()
DefaultArtdaqFragmentNameHelper Destructor.
std::string unidentified_instance_name_
The name to use for unknown Fragment types.
virtual std::set< std::string > GetAllProductInstanceNames() const =0
Returns the full set of product instance names which may be present in the data, based on the types t...
virtual ~FragmentNameHelper()=default
Default virtual destructor.
virtual 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...
detail::RawFragmentHeader::type_t type_t
typedef for type_t from RawFragmentHeader
std::map< artdaq::Fragment::type_t, std::string > type_map_
Map relating Fragment Type to strings.
FragmentNameHelper(std::string unidentified_instance_name, std::vector< std::pair< artdaq::Fragment::type_t, std::string >> extraTypes)
FragmentNameHelper constructor.
static std::map< type_t, std::string > MakeSystemTypeMap()
Returns a map of the most commonly-used system types.
virtual 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::string GetUnidentifiedInstanceName() const
Get the configured unidentified_instance_name.
virtual std::pair< bool, std::string > GetInstanceNameForFragment(artdaq::Fragment const &fragment) const =0
Returns the product instance name for the specified fragment, based on the types that have been speci...
A Fragment contains the data from one piece of the DAQ system for one event The artdaq::Fragment is t...
void SetBasicTypes(std::map< artdaq::Fragment::type_t, std::string > const &type_map)
Sets the basic types to be translated. (Should not include "container" types.)
virtual std::string GetInstanceNameForType(artdaq::Fragment::type_t type_id) const =0
Returns the basic translation for the specified type. Must be implemented by derived classes...
ArtdaqFragmentNameHelper(std::string unidentified_instance_name, std::vector< std::pair< artdaq::Fragment::type_t, std::string >> extraTypes)
NetMonTransportService Constructor.
virtual std::string GetInstanceNameForType(artdaq::Fragment::type_t type_id) const
Returns the basic translation for the specified type. Defaults to the specified unidentified_instance...