Classes | Public Member Functions | Protected Attributes | Private Attributes | List of all members
gov::fnal::cd::rms::provider::LocalhostConnection Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-02-24/rms/cxx/include/provider/LocalhostConnection.h"

Inheritance diagram for gov::fnal::cd::rms::provider::LocalhostConnection:
gov::fnal::cd::rms::provider::RmsConnection

Classes

class  ListenerContainer
 

Public Member Functions

 LocalhostConnection (const std::string applicationName, const int applicationPartition)
 
bool supportsDestination (const base::RmsDestination &candidateDestination)
 
void sendString (const base::RmsDestination &dest, const std::string &messageString)
 
void sendMessage (const base::RmsDestination &dest, const base::RmsMessage &message)
 
void addListener (const base::RmsDestination &dest, ProviderListener *listener)
 
void removeListener (const base::RmsDestination &dest, ProviderListener *listener)
 
bool ping (const base::RmsDestination &pingDestination)
 
void close ()
 
base::RmsDestination getMessageSource ()
 
const std::string getUUID ()
 

Protected Attributes

util::UUIDGenerator_uuidGenerator
 
base::RmsDestination _messageSource
 

Private Attributes

std::vector< ListenerContainer_destinationList
 

Detailed Description

A simple provider useful for testing the RMS interface routines. This provider will route messages between consumers and producers that are connected to it.

Author
Kurt Biery
Steve Foulkes
Version
Revision
1.1.1.1.18.1
Date
2019/09/27 00:07:31

Definition at line 33 of file LocalhostConnection.h.

Constructor & Destructor Documentation

gov::fnal::cd::rms::provider::LocalhostConnection::LocalhostConnection ( const std::string  applicationName,
const int  applicationPartition 
)

Create a new LocalhostConnection.

Parameters
applicationNameThe name of the application generating/receiving messages.
applicationPartitionThe partition of the application that is generating/receiving messages.

Definition at line 21 of file LocalhostConnection.cpp.

References gov::fnal::cd::rms::provider::RmsConnection::_messageSource, gov::fnal::cd::rms::provider::RmsConnection::_uuidGenerator, and gov::fnal::cd::rms::base::RmsDestination::TARGET_PROPERTY_NAME.

22  {
23  _messageSource.setProperty(base::RmsDestination::TARGET_PROPERTY_NAME, applicationName);
24  _messageSource.setPartitionProperty(applicationPartition);
25 
26  char hostname[32];
27  if (gethostname(hostname, 31) == 0) {
28  _uuidGenerator = new util::UUIDGenerator(hostname);
29  }
30  else {
31  _uuidGenerator = new util::UUIDGenerator("C++LocalhostConnection");
32  }
33 }
static const std::string TARGET_PROPERTY_NAME

Member Function Documentation

void gov::fnal::cd::rms::provider::LocalhostConnection::addListener ( const base::RmsDestination &  dest,
ProviderListener listener 
)
virtual

Register a listener with this provider.

Parameters
destThe destination that the listener is interested in
listenerA reference to the listener object.

Implements gov::fnal::cd::rms::provider::RmsConnection.

Definition at line 82 of file LocalhostConnection.cpp.

References _destinationList.

83  {
84  ListenerContainer newListener(dest, listener);
85 
86  _destinationList.push_back(newListener);
87 }
void gov::fnal::cd::rms::provider::LocalhostConnection::close ( )
virtual

Close this provider, and free any resources it may have allocated.

Implements gov::fnal::cd::rms::provider::RmsConnection.

Definition at line 113 of file LocalhostConnection.cpp.

113  {
114  return;
115 }
base::RmsDestination gov::fnal::cd::rms::provider::RmsConnection::getMessageSource ( )
inlineinherited

Get a copy of the message source.

Returns
A destination object that contains the source of messages for this connection.

Definition at line 112 of file RmsConnection.h.

References gov::fnal::cd::rms::provider::RmsConnection::_messageSource.

112  {
113  return _messageSource;
114  }
const std::string gov::fnal::cd::rms::provider::RmsConnection::getUUID ( )
inlineinherited

Get a new human readbale UUID from the UUID generator.

Returns
A new UUID.

Definition at line 121 of file RmsConnection.h.

References gov::fnal::cd::rms::provider::RmsConnection::_uuidGenerator, gov::fnal::cd::rms::provider::RmsConnection::close(), and gov::fnal::cd::rms::util::UUIDGenerator::getUUIDHex().

121  {
122  return _uuidGenerator->getUUIDHex();
123  }
bool gov::fnal::cd::rms::provider::LocalhostConnection::ping ( const base::RmsDestination &  pingDestination)
virtual

Ping a destination to see if it is up.

Returns
This always returns true.

Implements gov::fnal::cd::rms::provider::RmsConnection.

Definition at line 106 of file LocalhostConnection.cpp.

106  {
107  return true;
108 }
void gov::fnal::cd::rms::provider::LocalhostConnection::removeListener ( const base::RmsDestination &  dest,
ProviderListener listener 
)
virtual

Remove a listener from this provider.

Parameters
destThe destination to remove.
listenerThe listener to remove.
Bug:
implement

Implements gov::fnal::cd::rms::provider::RmsConnection.

Definition at line 97 of file LocalhostConnection.cpp.

97  {
98  return;
99 }
void gov::fnal::cd::rms::provider::LocalhostConnection::sendMessage ( const base::RmsDestination &  dest,
const base::RmsMessage &  message 
)
virtual

Send an RmsMessage to a particular destination.

Parameters
destThe destination to send a message to.
messageThe RmsMessage to send.

Implements gov::fnal::cd::rms::provider::RmsConnection.

Definition at line 71 of file LocalhostConnection.cpp.

References sendString().

72  {
73  sendString(dest, message.serialize());
74 }
void sendString(const base::RmsDestination &dest, const std::string &messageString)
void gov::fnal::cd::rms::provider::LocalhostConnection::sendString ( const base::RmsDestination &  dest,
const std::string messageString 
)
virtual

Send a string to a particular destination.

Parameters
destThe destination to send a message to.
messageStringThe string to send.

Implements gov::fnal::cd::rms::provider::RmsConnection.

Definition at line 50 of file LocalhostConnection.cpp.

References _destinationList, gov::fnal::cd::rms::provider::LocalhostConnection::ListenerContainer::getDestination(), gov::fnal::cd::rms::provider::LocalhostConnection::ListenerContainer::getListener(), MECModelEnuComparisons::i, gov::fnal::cd::rms::provider::LocalhostConnection::ListenerContainer::setDestination(), gov::fnal::cd::rms::provider::LocalhostConnection::ListenerContainer::setListener(), string, and gov::fnal::cd::rms::provider::ProviderListener::textReceived().

Referenced by sendMessage().

51  {
52  ListenerContainer aListener;
53  boost::shared_ptr<std::string> messagePtr (new std::string(messageString));
54 
55  for (unsigned int i = 0; i < _destinationList.size(); i++) {
56  aListener.setDestination(_destinationList.at(i).getDestination());
57  aListener.setListener(_destinationList.at(i).getListener());
58 
59  if (aListener.getDestination().equals(dest)) {
60  aListener.getListener()->textReceived(messagePtr);
61  }
62  }
63 }
enum BeamMode string
bool gov::fnal::cd::rms::provider::LocalhostConnection::supportsDestination ( const base::RmsDestination &  candidateDestination)
virtual

Determine whether this provider supports a particular destination.

Returns
True as this provider supports all destinations.

Implements gov::fnal::cd::rms::provider::RmsConnection.

Definition at line 40 of file LocalhostConnection.cpp.

40  {
41  return true;
42 }

Member Data Documentation

std::vector<ListenerContainer> gov::fnal::cd::rms::provider::LocalhostConnection::_destinationList
private

A list of destinations and listeners that have been associated with this provider.

Definition at line 138 of file LocalhostConnection.h.

Referenced by addListener(), and sendString().

base::RmsDestination gov::fnal::cd::rms::provider::RmsConnection::_messageSource
protectedinherited

A destination to hold the application name and application partition that is passed into the constructor.

Definition at line 141 of file RmsConnection.h.

Referenced by gov::fnal::cd::rms::provider::EpicsConnection::EpicsConnection(), gov::fnal::cd::rms::provider::RmsConnection::getMessageSource(), and LocalhostConnection().

util::UUIDGenerator* gov::fnal::cd::rms::provider::RmsConnection::_uuidGenerator
protectedinherited

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