Public Member Functions | Private Attributes | List of all members
gov::fnal::cd::rms::RmsSender< C, M > Class Template Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-24/rms/cxx/include/RmsSender.h"

Inheritance diagram for gov::fnal::cd::rms::RmsSender< C, M >:
gov::fnal::cd::rms::base::RmsCloseable

Public Member Functions

 RmsSender (boost::shared_ptr< C > parentConnection, base::RmsDestination dest)
 
 ~RmsSender ()
 
void sendMessage (M &message)
 
void close () throw ()
 
bool hasBeenClosed () throw ()
 

Private Attributes

boost::shared_ptr< C_myConnection
 
base::RmsDestination _myDestination
 
unsigned int _senderHandle
 
bool _hasBeenClosed
 

Detailed Description

template<class C, class M>
class gov::fnal::cd::rms::RmsSender< C, M >

This class contains functionality for sending messages of specified types to a specified destination.

Author
Kurt Biery
Version
Revision
1.9.14.1
Date
2019/09/27 00:07:31

Definition at line 42 of file RmsSender.h.

Constructor & Destructor Documentation

template<class C, class M >
gov::fnal::cd::rms::RmsSender< C, M >::RmsSender ( boost::shared_ptr< C parentConn,
base::RmsDestination  dest 
)

Constructs an RmsSender instance.

Parameters
parentConnConnection object which is used for sending messages.
destThe destination that we are sending messages to.
Exceptions
RmsRuntimeExceptionIf the destination is invalid.

Definition at line 78 of file RmsSender.h.

References gov::fnal::cd::rms::RmsSender< C, M >::_myConnection, gov::fnal::cd::rms::RmsSender< C, M >::_myDestination, gov::fnal::cd::rms::RmsSender< C, M >::_senderHandle, GENERATE_RMS_RUNTIME_EXCEPTION, lem_server::msg, and string.

78  :
79  _myConnection(parentConn),
81  _hasBeenClosed(false)
82 {
83  _myDestination.validate();
84  if (! _myConnection->supportsDestination(_myDestination)) {
86  msg.append("The current connection does not support ");
87  msg.append("the requested destination: ");
88  msg.append(_myDestination.toString());
90  }
91 
92  M dummyObj;
93  _senderHandle = _myConnection->registerSender(dummyObj, _myDestination);
94 }
base::RmsDestination _myDestination
Definition: RmsSender.h:61
boost::shared_ptr< C > _myConnection
Definition: RmsSender.h:51
#define GENERATE_RMS_RUNTIME_EXCEPTION(msg)
enum BeamMode string
template<class C , class M >
gov::fnal::cd::rms::RmsSender< C, M >::~RmsSender ( )

Destructs an RmsSender instance.

Definition at line 99 of file RmsSender.h.

References om::cerr, gov::fnal::cd::rms::RmsSender< C, M >::close(), and allTimeWatchdog::endl.

100 {
101  try {
102  this->close();
103  }
104  catch (...) {
105  std::cerr << "Exception in RmsSender destructor." << std::endl;
106  }
107 }
OStream cerr
Definition: OStream.cxx:7

Member Function Documentation

template<class C , class M >
void gov::fnal::cd::rms::RmsSender< C, M >::close ( )
throw (
)
virtual

Closes the RmsSender.

Implements gov::fnal::cd::rms::base::RmsCloseable.

Definition at line 139 of file RmsSender.h.

References gov::fnal::cd::rms::RmsSender< C, M >::_hasBeenClosed, gov::fnal::cd::rms::RmsSender< C, M >::_myConnection, gov::fnal::cd::rms::RmsSender< C, M >::_senderHandle, om::cout, and allTimeWatchdog::endl.

Referenced by gov::fnal::cd::rms::RmsSender< C, M >::sendMessage(), gov::fnal::cd::rms::RmsSender< C, M >::~RmsSender(), and novaddt::SendTriggerSignal::~SendTriggerSignal().

140 {
141  if (_hasBeenClosed) {
142  return;
143  }
144 
145  _hasBeenClosed = true;
146 
147  try {
148  _myConnection->unRegisterSender(_senderHandle);
149  } catch (...) {}
150 
151  _myConnection.reset();
152 
153 #if CETDDS_DEBUG1
154  std::cout << "Closed RmsSender connection" << std::endl;
155 #endif
156 }
boost::shared_ptr< C > _myConnection
Definition: RmsSender.h:51
OStream cout
Definition: OStream.cxx:6
template<class C, class M>
bool gov::fnal::cd::rms::RmsSender< C, M >::hasBeenClosed ( )
throw (
)
inlinevirtual

Implements gov::fnal::cd::rms::base::RmsCloseable.

Definition at line 51 of file RmsSender.h.

template<class C , class M>
void gov::fnal::cd::rms::RmsSender< C, M >::sendMessage ( M &  message)

Sends the specified message. The message argument is modified by this method - "standard" message fields are filled in as a convenience.

Parameters
messageThe message to be sent.
Exceptions
RmsCommunicationExceptionIf an error occurs when trying to send the message to the destination(s).

Definition at line 117 of file RmsSender.h.

References gov::fnal::cd::rms::RmsSender< C, M >::_hasBeenClosed, gov::fnal::cd::rms::RmsSender< C, M >::_myConnection, gov::fnal::cd::rms::RmsSender< C, M >::_senderHandle, gov::fnal::cd::rms::RmsSender< C, M >::close(), GENERATE_RMS_NOTCONNECTED_EXCEPTION, and LOG_EXCEPTION.

Referenced by novaddt::SendTriggerSignal::analyze().

118 {
119  try
120  {
121  if (_hasBeenClosed)
122  GENERATE_RMS_NOTCONNECTED_EXCEPTION("RMS connection was closed.");
123 
124  _myConnection->sendMessage(_senderHandle, message);
125  }
127  LOG_EXCEPTION("Caught RmsNotConnectedException in RmsSender::sendMessage(); message=", ex );
128  }
129  catch ( ... ) {
130  this->close();
131 
132  LOG_EXCEPTION("Caught exception in RmsSender::sendMessage(). Closing RMS connection.","");
133  }
134 }
#define LOG_EXCEPTION(message, what)
boost::shared_ptr< C > _myConnection
Definition: RmsSender.h:51
#define GENERATE_RMS_NOTCONNECTED_EXCEPTION(msg)

Member Data Documentation

template<class C, class M>
bool gov::fnal::cd::rms::RmsSender< C, M >::_hasBeenClosed
private
template<class C, class M>
boost::shared_ptr<C> gov::fnal::cd::rms::RmsSender< C, M >::_myConnection
private
template<class C, class M>
base::RmsDestination gov::fnal::cd::rms::RmsSender< C, M >::_myDestination
private

RmsDestination that we are listening to

Definition at line 61 of file RmsSender.h.

Referenced by gov::fnal::cd::rms::RmsSender< C, M >::RmsSender().

template<class C, class M>
unsigned int gov::fnal::cd::rms::RmsSender< C, M >::_senderHandle
private

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