Skip to content

Commit

Permalink
Update janacontrol to use new JComponentSummary
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwbrei committed May 3, 2024
1 parent 2fe9303 commit 8a7894b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/libraries/JANA/JFactorySet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void JFactorySet::Release() {
}
}

/// Summarize() generates a JFactorySummary data object describing each JFactory
/// Summarize() fills in component summaries for each JFactory in the set.
/// that this JFactorySet contains. The data is extracted from the JFactory itself.
void JFactorySet::Summarize(JComponentSummary& summary) const {

Expand All @@ -235,7 +235,7 @@ void JFactorySet::Summarize(JComponentSummary& summary) const {

JComponentSummary::Collection output;
output.collection_name = pair.second->GetTag();
output.collection_tag = pair.second->GetObjectName();
output.class_name = pair.second->GetObjectName();
c.outputs.push_back(output);

summary.components.push_back(c);
Expand Down
12 changes: 5 additions & 7 deletions src/plugins/janacontrol/src/JControlEventProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void JControlEventProcessor::NextEvent(void){
// Get count of objects already created for the current event
// for each type of factory.
//-------------------------------------------------------------
void JControlEventProcessor::GetObjectStatus( std::map<JFactorySummary, std::size_t> &factory_object_counts ){
void JControlEventProcessor::GetObjectStatus( std::map<JComponentSummary::Collection, std::size_t> &factory_object_counts ){

// bombproof against getting called with no active JEvent
if(_jevent.get() == nullptr ) return;
Expand All @@ -93,12 +93,10 @@ void JControlEventProcessor::GetObjectStatus( std::map<JFactorySummary, std::siz
// which only lists registered factories.
auto factories = _jevent->GetAllFactories();
for( auto fac : factories ){
JFactorySummary fac_info;
fac_info.plugin_name = fac->GetPluginName();
fac_info.factory_name = fac->GetFactoryName();
fac_info.factory_tag = fac->GetTag();
fac_info.object_name = fac->GetObjectName();
if(fac_info.factory_name == "") fac_info.factory_name = "JFactoryT<" + fac_info.object_name + ">";
JComponentSummary::Collection fac_info;
fac_info.class_name = fac->GetObjectName();
fac_info.collection_name = fac->GetTag();
fac_info.collection_tag = fac->GetTag();
if( fac ) factory_object_counts[fac_info] = fac->GetNumObjects();
}
}
Expand Down
18 changes: 3 additions & 15 deletions src/plugins/janacontrol/src/JControlEventProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ class JControlEventProcessor : public JEventProcessor {
// Shared state (e.g. histograms, TTrees, TFiles) live
std::mutex m_mutex;

struct JFactorySummaryCompare
{
bool operator() (const JFactorySummary& lhs, const JFactorySummary& rhs) const
{
if( lhs.object_name != rhs.object_name ) return lhs.object_name < rhs.object_name;
if( lhs.factory_tag != rhs.factory_tag ) return lhs.factory_tag < rhs.factory_tag;
if( lhs.factory_name != rhs.factory_name ) return lhs.factory_name < rhs.factory_name;
return lhs.plugin_name < rhs.plugin_name;
}
};


public:

Expand Down Expand Up @@ -77,10 +66,9 @@ class JControlEventProcessor : public JEventProcessor {
// Compare function to allow JFactorySummary to be used as keys in std::map
// ( used in argument to JControlEventProcessor::GetObjectStatus() )
inline bool operator<(const JFactorySummary& lhs, const JFactorySummary& rhs){
if( lhs.object_name != rhs.object_name ) return lhs.object_name < rhs.object_name;
if( lhs.factory_tag != rhs.factory_tag ) return lhs.factory_tag < rhs.factory_tag;
if( lhs.factory_name != rhs.factory_name ) return lhs.factory_name < rhs.factory_name;
return lhs.plugin_name < rhs.plugin_name;
if( lhs.class_name != rhs.class_name ) return lhs.class_name < rhs.class_name;
if( lhs.collection_name != rhs.collection_name ) return lhs.collection_name < rhs.collection_name;
return lhs.collection_base < rhs.collection_base;
}

#endif // _JControlEventProcessor_h_
Expand Down

0 comments on commit 8a7894b

Please sign in to comment.