JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
MQwPublishable< U, T > Class Template Reference

Mix-in for container classes that manage variable publishing. More...

#include <MQwPublishable.h>

+ Inheritance diagram for MQwPublishable< U, T >:
+ Collaboration diagram for MQwPublishable< U, T >:

Public Member Functions

 MQwPublishable ()
 Default constructor Initializes empty variable publishing maps.
 
 MQwPublishable (const MQwPublishable &source)
 Copy constructor Creates a new container with cleared publishing maps (variables are not copied).
 
virtual ~MQwPublishable ()
 Virtual destructor.
 
Bool_t RequestExternalValue (const TString &name, VQwHardwareChannel *value) const
 Retrieve a variable value from external sources by copying Searches for the named variable in external subsystem arrays and copies its value into the provided data element.
 
const VQwHardwareChannelRequestExternalPointer (const TString &name) const
 Retrieve a direct pointer to an external variable Searches for the named variable in external subsystem arrays and returns a direct pointer to the data element.
 
virtual const VQwHardwareChannelReturnInternalValue (const TString &name) const
 Retrieve an internal variable by name (pointer version) Searches for the named variable among published internal variables and returns a direct pointer to the data element.
 
Bool_t ReturnInternalValue (const TString &name, VQwHardwareChannel *value) const
 Retrieve an internal variable by name (copy version) Searches for the named variable among published internal variables and copies its value into the provided data element.
 
void ListPublishedValues () const
 List all published variables with descriptions Prints a summary of all currently published variables and their descriptions to the logging output for debugging and inspection purposes.
 
Bool_t PublishInternalValue (const TString name, const TString desc, const T *subsys, const VQwHardwareChannel *element)
 Publish an internal variable from a subsystem Registers a variable from one of the contained subsystems in the publishing framework, making it available for external access by name.
 

Data Fields

std::vector< std::vector< TString > > fPublishList
 

Private Member Functions

virtual Bool_t PublishByRequest (TString device_name)
 Try to publish an internal variable on demand Called internally when a variable is requested but not yet published. Iterates through contained subsystems to find and publish the requested variable.
 

Private Attributes

std::map< TString, const VQwHardwareChannel * > fPublishedValuesDataElement
 Published values.
 
std::map< TString, const T * > fPublishedValuesSubsystem
 
std::map< TString, TString > fPublishedValuesDescription
 

Detailed Description

template<class U, class T>
class MQwPublishable< U, T >

Mix-in for container classes that manage variable publishing.

Provides the container-side logic for the variable publishing system, including registering published variables, handling external requests, and maintaining mappings between variable names and data elements.

Definition at line 116 of file MQwPublishable.h.

Constructor & Destructor Documentation

◆ MQwPublishable() [1/2]

template<class U, class T>
MQwPublishable< U, T >::MQwPublishable ( )
inline

Default constructor Initializes empty variable publishing maps.

Definition at line 124 of file MQwPublishable.h.

124{ };

Referenced by MQwPublishable(), and ReturnInternalValue().

+ Here is the caller graph for this function:

◆ MQwPublishable() [2/2]

template<class U, class T>
MQwPublishable< U, T >::MQwPublishable ( const MQwPublishable< U, T > & source)
inline

Copy constructor Creates a new container with cleared publishing maps (variables are not copied).

Parameters
sourceSource object to copy from (maps are cleared, not copied)

Definition at line 131 of file MQwPublishable.h.

131 {
135 }
std::map< TString, const T * > fPublishedValuesSubsystem
std::map< TString, const VQwHardwareChannel * > fPublishedValuesDataElement
Published values.
std::map< TString, TString > fPublishedValuesDescription

References fPublishedValuesDataElement, fPublishedValuesDescription, fPublishedValuesSubsystem, and MQwPublishable().

+ Here is the call graph for this function:

◆ ~MQwPublishable()

template<class U, class T>
virtual MQwPublishable< U, T >::~MQwPublishable ( )
inlinevirtual

Virtual destructor.

Definition at line 138 of file MQwPublishable.h.

138{ };

Member Function Documentation

◆ ListPublishedValues()

template<class U, class T>
void MQwPublishable< U, T >::ListPublishedValues ( ) const

List all published variables with descriptions Prints a summary of all currently published variables and their descriptions to the logging output for debugging and inspection purposes.

Definition at line 141 of file MQwPublishable.cc.

142{
143 QwOut << "List of published values:" << QwLog::endl;
145 for (iter = fPublishedValuesDescription.begin();
147 QwOut << iter->first << ": " << iter->second << QwLog::endl;
148 }
149}
Mix-in for container classes that manage variable publishing.

References QwLog::endl(), fPublishedValuesDescription, and QwOut.

Referenced by main(), PublishByRequest(), and PublishInternalValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PublishByRequest()

template<class U, class T>
Bool_t MQwPublishable< U, T >::PublishByRequest ( TString device_name)
privatevirtual

Try to publish an internal variable on demand Called internally when a variable is requested but not yet published. Iterates through contained subsystems to find and publish the requested variable.

Parameters
device_nameName of the variable being requested
Returns
kTRUE if the variable was found and published, kFALSE otherwise

Definition at line 111 of file MQwPublishable.cc.

112{
114 if (fPublishedValuesSubsystem.count(device_name) > 0) {
115 QwDebug << "MQwPublishable::PublishByRequest: Channel "
116 << device_name << " has already been published."
117 << QwLog::endl;
119 status = kTRUE;
120 } else {
121 U* u = dynamic_cast<U*>(this);
122 if (not u->empty()) {
123 for (auto subsys = u->begin(); subsys != u->end(); ++subsys)
124 {
125 status = (*subsys)->PublishByRequest(device_name);
126 if (status) break;
127 }
128 // Report failure to publish
129 if (! status) {
130 QwDebug << "MQwPublishable::PublishByRequest: Failed to publish channel name: "
132 }
133 }
134 }
135 return status;
136}
virtual Bool_t PublishByRequest(TString device_name)
Try to publish an internal variable on demand Called internally when a variable is requested but not ...
void ListPublishedValues() const
List all published variables with descriptions Prints a summary of all currently published variables ...

References QwLog::endl(), fPublishedValuesSubsystem, ListPublishedValues(), and QwDebug.

Referenced by ReturnInternalValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PublishInternalValue()

template<class U, class T>
Bool_t MQwPublishable< U, T >::PublishInternalValue ( const TString name,
const TString desc,
const T * subsys,
const VQwHardwareChannel * element )

Publish an internal variable from a subsystem Registers a variable from one of the contained subsystems in the publishing framework, making it available for external access by name.

Parameters
nameUnique name/key for the variable
descHuman-readable description of the variable
subsysPointer to the subsystem that owns this variable
elementPointer to the data element representing this variable
Returns
kTRUE if variable was successfully published, kFALSE if name already exists

Definition at line 92 of file MQwPublishable.cc.

97{
98 if (fPublishedValuesSubsystem.count(name) > 0) {
99 QwError << "Attempting to publish existing variable key!" << QwLog::endl;
101 return kFALSE;
102 }
106 return kTRUE;
107}

References QwLog::endl(), fPublishedValuesDataElement, fPublishedValuesDescription, fPublishedValuesSubsystem, ListPublishedValues(), and QwError.

+ Here is the call graph for this function:

◆ RequestExternalPointer()

template<class U, class T>
const VQwHardwareChannel * MQwPublishable< U, T >::RequestExternalPointer ( const TString & name) const

Retrieve a direct pointer to an external variable Searches for the named variable in external subsystem arrays and returns a direct pointer to the data element.

Parameters
nameName of the variable to retrieve
Returns
Pointer to the variable's data element, or nullptr if not found

Definition at line 24 of file MQwPublishable.cc.

25{
26 // If this has a parent, we should escalate the call to that object,
27 // but so far we don't have that capability.
29}
virtual const VQwHardwareChannel * ReturnInternalValue(const TString &name) const
Retrieve an internal variable by name (pointer version) Searches for the named variable among publish...

References ReturnInternalValue().

Referenced by LRBCorrector::ConnectChannels(), QwCombiner::ConnectChannels(), QwCorrelator::ConnectChannels(), and VQwDataHandler::ConnectChannels().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RequestExternalValue()

template<class U, class T>
Bool_t MQwPublishable< U, T >::RequestExternalValue ( const TString & name,
VQwHardwareChannel * value ) const

Retrieve a variable value from external sources by copying Searches for the named variable in external subsystem arrays and copies its value into the provided data element.

Parameters
nameName of the variable to retrieve
valuePointer to data element that will receive the variable's value
Returns
kTRUE if variable was found and copied, kFALSE otherwise

Definition at line 16 of file MQwPublishable.cc.

17{
18 // If this has a parent, we should escalate the call to that object,
19 // but so far we don't have that capability.
21}

References ReturnInternalValue().

Referenced by QwBlinder::Update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReturnInternalValue() [1/2]

template<class U, class T>
const VQwHardwareChannel * MQwPublishable< U, T >::ReturnInternalValue ( const TString & name) const
virtual

Retrieve an internal variable by name (pointer version) Searches for the named variable among published internal variables and returns a direct pointer to the data element.

Parameters
nameName of the variable to retrieve
Returns
Pointer to the variable's data element, or nullptr if not found

Definition at line 34 of file MQwPublishable.cc.

35{
36 // First try to find the value in the list of published values.
40 return iter1->second;
41 }
42 /*
43 // Second, ask the subsystem that has claimed the value
44 typename std::map<TString, const T*>::const_iterator iter2 =
45 fPublishedValuesSubsystem.find(name);
46 if (iter2 != fPublishedValuesSubsystem.end()) {
47 return (iter2->second)->ReturnInternalValue(name);
48 }
49 */
50 // If the value is not yet published, try requesting it.
51 if (const_cast<MQwPublishable*>(this)->PublishByRequest(name)){
54 return iter1->second;
55 }
56 QwError << "PublishByRequest succeeded, but can't find the record for "
57 << name << QwLog::endl;
58
59 } else {
60 QwDebug << "PublishByRequest failed for " << name << QwLog::endl;
61 }
62 // Not found
63 return 0;
64}
MQwPublishable()
Default constructor Initializes empty variable publishing maps.

References QwLog::endl(), fPublishedValuesDataElement, MQwPublishable(), PublishByRequest(), QwDebug, and QwError.

Referenced by QwAlarmHandler::ConnectChannels(), RequestExternalPointer(), and RequestExternalValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReturnInternalValue() [2/2]

template<class U, class T>
Bool_t MQwPublishable< U, T >::ReturnInternalValue ( const TString & name,
VQwHardwareChannel * value ) const

Retrieve an internal variable by name (copy version) Searches for the named variable among published internal variables and copies its value into the provided data element.

Parameters
nameName of the variable to retrieve
valuePointer to data element that will receive the variable's value
Returns
kTRUE if variable was found and copied, kFALSE otherwise

Definition at line 68 of file MQwPublishable.cc.

69{
71
72 // Check for null pointer
73 if (! value)
74 QwWarning << "MQwPublishable::ReturnInternalValue requires that "
75 << "'value' be a non-null pointer to a VQwHardwareChannel."
76 << QwLog::endl;
77
78 // Get a const pointer to the internal value
80 if (value && internal_value) {
81 value->AssignValueFrom(internal_value);
82 foundit = kTRUE;
83 } else
84 QwWarning << "MQwPublishable::ReturnInternalValue: name \""
85 << name << "\" not found in array." << QwLog::endl;
86
87 return foundit;
88}

Field Documentation

◆ fPublishedValuesDataElement

template<class U, class T>
std::map<TString, const VQwHardwareChannel*> MQwPublishable< U, T >::fPublishedValuesDataElement
private

Published values.

Definition at line 215 of file MQwPublishable.h.

Referenced by MQwPublishable(), PublishInternalValue(), and ReturnInternalValue().

◆ fPublishedValuesDescription

template<class U, class T>
std::map<TString, TString> MQwPublishable< U, T >::fPublishedValuesDescription
private

Definition at line 217 of file MQwPublishable.h.

Referenced by ListPublishedValues(), MQwPublishable(), and PublishInternalValue().

◆ fPublishedValuesSubsystem

template<class U, class T>
std::map<TString, const T*> MQwPublishable< U, T >::fPublishedValuesSubsystem
private

Definition at line 216 of file MQwPublishable.h.

Referenced by MQwPublishable(), PublishByRequest(), and PublishInternalValue().

◆ fPublishList

template<class U, class T>
std::vector<std::vector<TString> > MQwPublishable< U, T >::fPublishList

Definition at line 141 of file MQwPublishable.h.


The documentation for this class was generated from the following files: