RmsConnection.h
Go to the documentation of this file.
1 #ifndef _RMS_CONNECTION_H
2 #define _RMS_CONNECTION_H
3 
4 /**
5  * @package gov.fnal.cd.rms.provider
6  *
7  * @brief Provider-specific classes and interfaces.
8  *
9  * This package contains classes and interfaces for interacting with
10  * third-party messaging providers.
11  */
12 
13 #include <rms/base/RmsDestination.h>
14 #include <rms/base/RmsMessage.h>
15 #include <rms/provider/ProviderListener.h>
16 #include <rms/util/UUIDGenerator.h>
17 
18 #include <string>
19 
20 namespace gov {
21 
22 namespace fnal {
23 
24 namespace cd {
25 
26 namespace rms {
27 
28 namespace provider {
29 
30 /**
31  * This is the interface that every provider must
32  * implement in order to work with RMS.
33  *
34  * @author Kurt Biery
35  * @author Steve Foulkes
36  * @version $Revision: 1.2.18.1 $ $Date: 2019/09/27 00:07:31 $
37  */
38 
40  public:
41  /**
42  * Virtual destructor to suppress compiler warnings.
43  */
44  virtual ~RmsConnection() {
45  return;
46  }
47 
48  /**
49  * Determine if this provider supports a particular destination.
50  *
51  * @param candidateDestination The destination to be checked to see
52  * if this provider can send messages to it.
53  *
54  * @return True if messages can be sent to the destination, false
55  * otherwise.
56  */
57  virtual bool supportsDestination(const base::RmsDestination&
58  candidateDestination) = 0;
59 
60  /**
61  * Send a string to a particular destination.
62  *
63  * @param dest The destination to send the message to.
64  * @param messageString The message to send to the destination.
65  */
66  virtual void sendString(const base::RmsDestination& dest,
67  const std::string& messageString) = 0;
68 
69  /**
70  * Send an RmsMessage to a particular destination.
71  *
72  * @param dest The destination to send the message to.
73  * @param message The message to be sent to the destination.
74  */
75  virtual void sendMessage(const base::RmsDestination& dest,
76  const base::RmsMessage& message) = 0;
77 
78  /**
79  * Add a listener to this provider. Whenever the provider receives
80  * messages to this destination, the message will be passed to the
81  * listener.
82  *
83  * @param dest The destination that messages will be going to.
84  * @param listener A reference to the listener that will be called
85  * when a message is received by the destination.
86  */
87  virtual void addListener(const base::RmsDestination& dest,
88  ProviderListener *listener) = 0;
89 
90  /**
91  * Remove a listener from this provider.
92  *
93  * @param dest The destination instance to be removed.
94  * @param listener The listener instance to be removed.
95  */
96  virtual void removeListener(const base::RmsDestination& dest,
97  ProviderListener *listener) = 0;
98 
99  /**
100  * Ping a destination to see if it is up.
101  *
102  * @return True if the destination is up, false otherwise.
103  */
104  virtual bool ping(const base::RmsDestination& pingDestination) = 0;
105 
106  /**
107  * Get a copy of the message source.
108  *
109  * @return A destination object that contains the source of messages
110  * for this connection.
111  */
112  base::RmsDestination getMessageSource() {
113  return _messageSource;
114  }
115 
116  /**
117  * Get a new human readbale UUID from the UUID generator.
118  *
119  * @return A new UUID.
120  */
122  return _uuidGenerator->getUUIDHex();
123  }
124 
125  /**
126  * Close down the provider and free up any resources
127  * that have been allocated.
128  */
129  virtual void close() = 0;
130 
131  protected:
132  /**
133  * All providers will need to generate UUIDs.
134  */
136 
137  /**
138  * A destination to hold the application name and application partition
139  * that is passed into the constructor.
140  */
141  base::RmsDestination _messageSource;
142 };
143 
144 } // end of namespace provider
145 
146 } // end of namespace rms
147 
148 } // end of namespace cd
149 
150 } // end of namespace fnal
151 
152 } // end of namespace gov
153 
154 #endif
virtual bool ping(const base::RmsDestination &pingDestination)=0
virtual void addListener(const base::RmsDestination &dest, ProviderListener *listener)=0
virtual void removeListener(const base::RmsDestination &dest, ProviderListener *listener)=0
Definition: fnal.py:1
virtual bool supportsDestination(const base::RmsDestination &candidateDestination)=0
c cd(1)
virtual void sendString(const base::RmsDestination &dest, const std::string &messageString)=0
virtual void sendMessage(const base::RmsDestination &dest, const base::RmsMessage &message)=0
enum BeamMode string