$treeview $search $mathjax $extrastylesheet
artdaq_core
v3_06_01
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #include "artdaq-core/Data/FragmentNameHelper.hh" 00002 #include "artdaq-core/Data/ContainerFragment.hh" 00003 00004 namespace artdaq { 00005 00006 ArtdaqFragmentNameHelper::ArtdaqFragmentNameHelper(std::string unidentified_instance_name, std::vector<std::pair<artdaq::Fragment::type_t, std::string>> extraTypes) 00007 : FragmentNameHelper(unidentified_instance_name, extraTypes) 00008 { 00009 TLOG(TLVL_DEBUG) << "ArtdaqFragmentNameHelper CONSTRUCTOR START"; 00010 TLOG(TLVL_DEBUG) << "ArtdaqFragmentNameHelper CONSTRUCTOR END"; 00011 } 00012 00013 ArtdaqFragmentNameHelper::~ArtdaqFragmentNameHelper() = default; 00014 00015 std::string ArtdaqFragmentNameHelper::GetInstanceNameForType(artdaq::Fragment::type_t type_id) const 00016 { 00017 if (type_map_.count(type_id) > 0) { return type_map_.at(type_id); } 00018 return unidentified_instance_name_; 00019 } 00020 00021 std::set<std::string> ArtdaqFragmentNameHelper::GetAllProductInstanceNames() const 00022 { 00023 std::set<std::string> output; 00024 for (const auto& map_iter : type_map_) 00025 { 00026 std::string instance_name = map_iter.second; 00027 if (output.count(instance_name) == 0u) 00028 { 00029 output.insert(instance_name); 00030 TLOG(TLVL_TRACE) << "Adding product instance name \"" << map_iter.second 00031 << "\" to list of expected names"; 00032 } 00033 } 00034 00035 auto container_type = type_map_.find(artdaq::Fragment::type_t(artdaq::Fragment::ContainerFragmentType)); 00036 if (container_type != type_map_.end()) 00037 { 00038 std::string container_type_name = container_type->second; 00039 std::set<std::string> tmp_copy = output; 00040 for (const auto& set_iter : tmp_copy) 00041 { 00042 output.insert(container_type_name + set_iter); 00043 } 00044 } 00045 00046 return output; 00047 } 00048 00049 std::pair<bool, std::string> 00050 ArtdaqFragmentNameHelper::GetInstanceNameForFragment(artdaq::Fragment const& fragment) const 00051 { 00052 auto type_map_end = type_map_.end(); 00053 bool success_code = true; 00054 std::string instance_name; 00055 00056 auto primary_type = type_map_.find(fragment.type()); 00057 if (primary_type != type_map_end) 00058 { 00059 TLOG(TLVL_TRACE) << "Found matching instance name " << primary_type->second << " for Fragment type " << fragment.type(); 00060 instance_name = primary_type->second; 00061 if (fragment.type() == artdaq::Fragment::ContainerFragmentType) 00062 { 00063 artdaq::ContainerFragment cf(fragment); 00064 auto contained_type = type_map_.find(cf.fragment_type()); 00065 if (contained_type != type_map_end) 00066 { 00067 instance_name += contained_type->second; 00068 } 00069 } 00070 } 00071 else 00072 { 00073 TLOG(TLVL_TRACE) << "Could not find match for Fragment type " << fragment.type() << ", returning " << unidentified_instance_name_; 00074 instance_name = unidentified_instance_name_; 00075 success_code = false; 00076 } 00077 00078 return std::make_pair(success_code, instance_name); 00079 } 00080 } // namespace artdaq 00081 00082 DEFINE_ARTDAQ_FRAGMENT_NAME_HELPER(artdaq::ArtdaqFragmentNameHelper)