Apama  10.0.0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sag_connectivity_plugins.hpp
Go to the documentation of this file.
1 /*
2  * Title: sag_connectivity_plugins.hpp
3  * Description: C++ API for writing connectivity plugins
4  * $Copyright (c) 2015-2017 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.$
5  * Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG
6  * @Version: $Id: sag_connectivity_plugins.hpp 302070 2017-02-13 15:27:24Z cree $
7  */
8 
17 #ifndef _SAG_CONNECTIVITY_PLUGINS_HPP_
18 #define _SAG_CONNECTIVITY_PLUGINS_HPP_
19 
20 #include <sag_connectivity_cpp.hpp>
21 #include <sag_plugin_logging.hpp>
22 #include <memory>
23 
24 // must define __STDC_FORMAT_MACROS before first include of inttypes else printf macros won't be defined
25 #ifndef __STDC_FORMAT_MACROS
26 #define __STDC_FORMAT_MACROS 1
27 #endif
28 #include <inttypes.h>
29 
30 namespace com {
31 namespace softwareag {
32 namespace connectivity {
33 
37 enum class Direction {
41  TOWARDS_HOST = 1,
46 };
47 
52 class PluginHost {
53  friend class Plugin;
54 public:
55  typedef std::unique_ptr<PluginHost> ptr_t;
56 
71  void enableReliability(Direction direction) {
72  if (SAG_ERROR_OK != sag_enable_reliability(chain, static_cast<int>(direction))) {
73  throw std::runtime_error("An error occurred while setting chain reliability");
74  }
75  }
76 
78  bool isShuttingDown() {
79  bool isShuttingDown = false;
80  if (SAG_ERROR_OK != sag_is_host_shutting_down(chain, isShuttingDown)) {
81  throw std::runtime_error("An error occurred while checking if host is shutting down");
82  }
83  return isShuttingDown;
84  }
85 private:
89  PluginHost(void* chain = NULL) :chain(chain) {}
90  void* chain;
91 };
92 
93 // forward decl for parameters friend
94 class Plugin;
95 
106 {
107  // for constructor access to connectivityManager
108  friend class Plugin;
109 
110 public:
112 
114 
118  const map_t &getConfig() const { return config; }
119 
123  const std::string &getChainId() const { return chainId; }
124 
128  const std::string &getPluginName() const { return pluginName; }
129 
130 protected:
134  PluginConstructorParameters(const std::string &pluginName, const std::string &chainId, const map_t &config, void* connectivityManager, void* chain)
135  : chainId(chainId), pluginName(pluginName), config(config.copy()), connectivityManager(connectivityManager), chain(chain)
136  {}
137 
138 private:
139  std::string chainId;
140  std::string pluginName;
141  map_t config;
143  void* connectivityManager;
145  void* chain;
146 };
147 
150 {
151 public:
155  TransportConstructorParameters(const std::string &pluginName, const std::string &chainId, const map_t &config, void* connectivityManager, void* reserved)
156  : PluginConstructorParameters(pluginName, chainId, config, connectivityManager, reserved)
157  {}
158 };
159 
162 {
163 public:
167  CodecConstructorParameters(const std::string &pluginName, const std::string &chainId, const map_t &config, void* connectivityManager, void* reserved)
168  : PluginConstructorParameters(pluginName, chainId, config, connectivityManager, reserved)
169  {}
170 };
171 
172 
187 {
188 public:
189 
193  static const char* STATUS_ONLINE() { return "ONLINE"; }
197  static const char* STATUS_STARTING() { return "STARTING"; }
201  static const char* STATUS_FAILED() { return "FAILED"; }
202 
203 
214  {
215  friend class StatusReporter;
216  public:
217 
218  ~StatusItem()
219  {
220  sag_delete_user_status_item(connectivityManager, underlying);
221  underlying.item = 0; // use nullptr when compiler supports it
222  }
223 
229  void setStatus(const std::string &value)
230  {
231  if (!underlying.item) throw std::runtime_error("Cannot call setStatus after StatusItem has been deleted!");
232 
233  if (value == lastValue) return; // no-op this case
234  lastValue = value;
235 
236  sag_set_user_status_item(underlying, value.c_str());
237  }
238 
247  void setStatus(int64_t value)
248  {
249  intValue = value;
250  setStatus(toString(value));
251  }
252 
258  std::string getStatus() { return lastValue; }
259 
267  void increment(int64_t incrementValue = 1)
268  {
269  intValue += incrementValue;
270  setStatus(intValue);
271  }
272 
275  const std::string &key() { return mkey; }
276 
277 
278  private:
279 
280  static const std::string toString(int64_t value)
281  {
282  // stringstream is very slow when called from multiple threads concurrently, so doing this
283  // to avoid introducing a bottleneck on the critical path
284  char result[25];
285 #if defined(_WIN32) || defined(__WIN32) || defined(WIN32)
286  // snprintf will be supported in VS 2015, but until then:
287  _snprintf_s(result, sizeof(result), _TRUNCATE, "%" PRId64, value);
288 #else
289  snprintf(result, sizeof(result), "%" PRId64, value);
290 #endif
291  return std::string(result);
292  }
293 
294  StatusItem(const StatusItem& other) = delete; // non construction-copyable
295  StatusItem& operator=(const StatusItem&) = delete; // non copyable
296 
297  StatusItem(void* connectivityManager, const std::string &key, const std::string &initialValue, const int64_t intValue)
298  : intValue(intValue),
299  mkey(key),
300  lastValue(initialValue),
301  connectivityManager(connectivityManager),
302  underlying(sag_create_user_status_item(connectivityManager, key.c_str(), initialValue.c_str()))
303  {
304  if (!underlying.item)
305  {
306  std::ostringstream oss;
307  oss << "Failed to create status item '" << key << "' (ensure the key is unique and that this plug-in has not been shutdown already)";
308  throw std::runtime_error(oss.str());
309  }
310  }
311 
312  int64_t intValue;
313  const std::string mkey;
314  std::string lastValue;
315  void* connectivityManager;
316  sag_status_item_t underlying;
317  };
318 
332  std::unique_ptr<StatusItem> createStatusItem(const std::string &key, const std::string &initialValue)
333  {
334  return std::unique_ptr<StatusItem>(new StatusItem(connectivityManager, key, initialValue, 0));
335  }
336 
350  std::unique_ptr<StatusItem> createStatusItem(const std::string &key, int64_t initialValue)
351  {
352  std::ostringstream oss;
353  oss << initialValue;
354  return std::unique_ptr<StatusItem>(new StatusItem(connectivityManager, key, oss.str(), initialValue));
355  }
356 
367  void setStatus(const map_t &statusmap)
368  {
369  sag_set_user_status_map(connectivityManager, reinterpret_cast<const sag_underlying_map_t&>(statusmap));
370  // keep track of what keys we've added so we can automatically remove them when we're destroyed
371  for (auto it = statusmap.cbegin(); it != statusmap.cend(); it++)
372  if (it->first.type_tag() == SAG_DATA_STRING) // ignore invalid ones
373  {
374  if (it->second.empty())
375  mapKeysToCleanup.erase(it->first);
376  else
377  mapKeysToCleanup.insert(it->first.copy(), std::move(data_t()));
378  }
379  }
380 
381 
382 
386  ~StatusReporter()
387  {
388  if (!mapKeysToCleanup.empty())
389  sag_set_user_status_map(connectivityManager, reinterpret_cast<const sag_underlying_map_t&>(mapKeysToCleanup));
390  }
391 
395  explicit StatusReporter(void *connectivityManager) : connectivityManager(connectivityManager), mapKeysToCleanup()
396  {
397  }
398 
399 private:
400  void* connectivityManager;
401  map_t mapKeysToCleanup;
402 
403 
404  StatusReporter() = delete;
405 
406  // non-copyable, due to the cleanup code we don't want people to shoot themselves in the foot by having multiple copies
407  StatusReporter(const StatusReporter& other) = delete;
408  StatusReporter& operator=(const StatusReporter&) = delete;
409 
410 };
411 
419 class Plugin
420 {
421 public:
422  /* Legacy constructor [DEPRECATED].
423  @deprecated This constructor signature is deprecated, please use the alternative constructor.
424  */
425  Plugin(const std::string &pluginName, const std::string &chainId, const map_t &config)
426  : name(pluginName), pluginName(pluginName), chainId(chainId), config(config.copy()), host(new PluginHost()), LOGGER(pluginName + "." + chainId), logger(name + "." + chainId), statusReporter()
427  {
428  logger.info("The %s connectivity plug-in in chain '%s' is using the deprecated legacy (std::string&,std::string&,map_t&) constructor. We recommend changing to use the recommended (PluginConstructorParameters&) constructor instead.",
429  pluginName.c_str(), chainId.c_str());
430  }
431 
432  /* Constructor.
433  * @since 9.12.0.1
434  */
435  Plugin(const PluginConstructorParameters &params)
436  : name(params.getPluginName()), pluginName(params.getPluginName()), chainId(params.getChainId()), config(params.getConfig().copy()),
437  host(new PluginHost(params.chain)), LOGGER(params.getPluginName() + "." + params.getChainId()), logger(pluginName + "." + chainId),
438  statusReporter(new StatusReporter(params.connectivityManager))
439  {
440  }
441 
447  virtual ~Plugin() {}
448 
459  virtual void start() {}
460 
468  virtual void hostReady() {}
469 
492  virtual void shutdown() {}
494  const std::string &getName() const { return name; }
495 protected:
498  const std::string name;
501  const std::string pluginName;
503  const std::string chainId;
511  const PluginHost::ptr_t host;
519  if (statusReporter) return *statusReporter;
520  throw std::runtime_error("Cannot call getStatusReporter when using the legacy constructor");
521  }
522 
523 public:
530 
535 private:
536  std::unique_ptr<StatusReporter> statusReporter;
537 };
538 
543 class HostSide
544 {
545 public:
547  virtual ~HostSide() {}
549  typedef std::auto_ptr<HostSide> ptr_t;
566  virtual void sendBatchTowardsHost(Message *start, Message *end) = 0;
567 };
568 
574 {
575 public:
576  RemoteHostSide(sag_plugin_t other, sag_send_fn_t fn): other(other), fn(fn) {}
577  virtual ~RemoteHostSide() {}
578  virtual void sendBatchTowardsHost(Message *start, Message *end);
579 private:
580  sag_plugin_t other;
581  sag_send_fn_t fn;
582 };
583 
589 {
590 public:
592  virtual ~TransportSide() {}
594  typedef std::auto_ptr<TransportSide> ptr_t;
611  virtual void sendBatchTowardsTransport(Message *start, Message *end) = 0;
612 };
613 
619 {
620 public:
621  RemoteTransportSide(sag_plugin_t other, sag_send_fn_t fn): other(other), fn(fn) {}
622  virtual ~RemoteTransportSide() {}
623  virtual void sendBatchTowardsTransport(Message *start, Message *end);
624 private:
625  sag_plugin_t other;
626  sag_send_fn_t fn;
627 };
628 
629 
654 class AbstractCodec: public Plugin, public HostSide, public TransportSide
655 {
656 public:
658 
674  AbstractCodec(const std::string &pluginName, const std::string &chainId, const map_t &config)
675  : Plugin(pluginName, chainId, config)
676  {}
677 
687  : Plugin(params)
688  {}
689 
690  // these methods do not need to show up in doxygen
691  /* Called between construction and start() to set the hostSide field */
692  virtual void setNextTowardsHost(HostSide::ptr_t &&host)
693  {
694  hostSide = std::move(host);
695  }
696  /* Called between construction and start() to set the transportSide field */
697  virtual void setNextTowardsTransport(TransportSide::ptr_t &&transport)
698  {
699  transportSide = std::move(transport);
700  }
701 protected:
707 
713 };
714 
747 {
748 public:
750 
765  AbstractTransport(const std::string &name, const std::string &chainId, const map_t &config)
766  : Plugin(name, chainId, config)
767  {}
768 
778  : Plugin(params)
779  {}
780 
781  // this method does not need to show up in doxygen
782  /* Called between construction and start() to set the hostSide field */
783  virtual void setNextTowardsHost(HostSide::ptr_t &&host)
784  {
785  hostSide = std::move(host);
786  }
787 
788 protected:
794 };
795 
812 {
813 public:
814 
829  AbstractSimpleTransport(const std::string &name, const std::string &chainId, const map_t &config)
830  : AbstractTransport(name, chainId, config)
831  {}
832 
842  : AbstractTransport(params)
843  {}
844 
845 
851  {
852  for (Message *it = start; it != end; ++it) {
853  try {
854  if (it->getPayload().empty()) {
856  } else {
858  }
859  } catch (...) {
860  handleException(*it);
861  }
862  }
863  }
865  virtual void deliverMessageTowardsTransport(Message &msg) = 0;
868  {
869  // do nothing
870  }
871 
890  virtual void handleException(Message &m)
891  {
892  try {
893  throw;
894  } catch (const std::exception &e) {
895  logger.warn("Caught exception delivering message: %s", e.what());
896  } catch (...) {
897  logger.warn("Caught unknown exception delivering message: %s");
898  }
899  }
900 };
901 
921 {
922 public:
937  AbstractSimpleCodec(const std::string &name, const std::string &chainId, const map_t &config)
938  : AbstractCodec(name, chainId, config)
939  {}
940 
950  : AbstractCodec(params)
951  {}
952 
959  {
960  Message *curr = start;
961  for (Message *it = start; it != end; ++it) {
962  bool rv;
963  try {
964  if (it->getPayload().empty()) {
966  } else {
967  rv = transformMessageTowardsHost(*it);
968  }
969  } catch (...) {
970  rv = handleException(*it, false);
971  }
972  // if we keep it (and it didn't throw) swap it with the accumulator
973  if (rv) {
974  if (it != curr) it->swap(std::move(*curr)); // don't self-swap
975  ++curr;
976  }
977  }
978  if (hostSide.get()) hostSide->sendBatchTowardsHost(start, curr);
979  }
986  {
987  Message *curr = start;
988  for (Message *it = start; it != end; ++it) {
989  bool rv;
990  try {
991  // process the message
992  if (it->getPayload().empty()) {
994  } else {
996  }
997  } catch (...) {
998  rv = handleException(*it, true);
999  }
1000  // if we keep it (and it didn't throw) swap it with the accumulator
1001  if (rv) {
1002  if (it != curr) it->swap(std::move(*curr)); // don't self-swap
1003  ++curr;
1004  }
1005  }
1006  if (transportSide.get()) transportSide->sendBatchTowardsTransport(start, curr);
1007  }
1008 
1012  virtual bool transformMessageTowardsHost(Message &msg) = 0;
1016  virtual bool transformMessageTowardsTransport(Message &msg) = 0;
1021  {
1022  // do nothing
1023  return true;
1024  }
1029  {
1030  // do nothing
1031  return true;
1032  }
1054  virtual bool handleException(Message &m, bool towardsTransport)
1055  {
1056  try {
1057  throw;
1058  } catch (const std::exception &e) {
1059  logger.warn("Caught exception transforming message: %s", e.what());
1060  } catch (...) {
1061  logger.warn("Caught unknown exception transforming message");
1062  }
1063  return false;
1064  }
1065 };
1066 
1067 }}} // com.softwareag.connectivity
1068 
1069 // internal implementation included from these files
1070 #include <sag_internal/exception.hpp>
1071 #include <sag_internal/remote_plugins.hpp>
1072 #include <sag_internal/plugin_macros.hpp>
1073 
1083 #define SAG_DECLARE_CONNECTIVITY_TRANSPORT_CLASS(Class) _SAG_DECLARE_CONNECTIVITY_TRANSPORT_CLASS(Class)
1084 
1096 #define SAG_DECLARE_CONNECTIVITY_TRANSPORT(Class) _SAG_DECLARE_CONNECTIVITY_TRANSPORT_LEGACY(Class)
1097 
1107 #define SAG_DECLARE_CONNECTIVITY_CODEC_CLASS(Class) _SAG_DECLARE_CONNECTIVITY_CODEC_CLASS(Class)
1108 
1119 #define SAG_DECLARE_CONNECTIVITY_CODEC(Class) _SAG_DECLARE_CONNECTIVITY_CODEC_LEGACY(Class)
1120 
1121 #endif // _SAG_CONNECTIVITY_PLUGINS_HPP_
A container for parameters passed to the constructor of a codec plug-in.
Definition: sag_connectivity_plugins.hpp:161
Logger LOGGER
Legacy logging for writing to the host log file [DEPRECATED].
Definition: sag_connectivity_plugins.hpp:529
bool empty() const
Returns true if the map is empty (size() == 0)
Definition: sag_connectivity_cpp.hpp:249
const std::string pluginName
The name used for this plug-in in the configuration file.
Definition: sag_connectivity_plugins.hpp:501
Base class that simplifies implementation of codec plug-ins that deal only with individual messages n...
Definition: sag_connectivity_plugins.hpp:920
AbstractTransport(const PluginConstructorParameters::TransportConstructorParameters &params)
Constructor.
Definition: sag_connectivity_plugins.hpp:777
Base class that simplifies implementation of transport plug-ins that deal only with individual messag...
Definition: sag_connectivity_plugins.hpp:811
Wrap the next plugin in order as a TransportSide object.
Definition: sag_connectivity_plugins.hpp:618
void increment(int64_t incrementValue=1)
Set an integer status value by incrementing the previous integer value that was set by this object...
Definition: sag_connectivity_plugins.hpp:267
HostSide::ptr_t hostSide
The next plug-in in the chain towards host.
Definition: sag_connectivity_plugins.hpp:706
An interface to the next component (plugin or host) towards the host.
Definition: sag_connectivity_plugins.hpp:543
virtual void sendBatchTowardsHost(Message *start, Message *end)=0
Abstract method that must be implemented to handle delivery of a batch of messages heading towards th...
map_t config
The configuration of this plug-in.
Definition: sag_connectivity_plugins.hpp:505
Direction
The enumeration indicating the direction of message flow - towards the transport or towards the host...
Definition: sag_connectivity_plugins.hpp:37
void warn(const char *format, ARGS...args) const
Log a message at WARN level.
Definition: sag_plugin_logging.hpp:153
Class for writing to the system logger.
Definition: sag_plugin_logging.hpp:72
const PluginHost::ptr_t host
Interface to support miscellaneous requests from this plug-in to the host system. ...
Definition: sag_connectivity_plugins.hpp:511
StatusReporter & getStatusReporter()
Allows reporting status information from this plug-in, such as connected/disconnected status and numb...
Definition: sag_connectivity_plugins.hpp:518
A map class which implements many of the functions on std::map.
Definition: map_t.hpp:36
Contains the C++ implementation of the underlying datatypes used by connectivity plugins and their ac...
void setStatus(const map_t &statusmap)
Set multiple related string status values at the same time (atomically).
Definition: sag_connectivity_plugins.hpp:367
virtual void sendBatchTowardsTransport(Message *start, Message *end)
Implements batch sending, calling deliverMessageTowardsTransport(Message&) for each message individua...
Definition: sag_connectivity_plugins.hpp:850
Base of the inheritance tree for Connectivity plugins.
Definition: sag_connectivity_plugins.hpp:419
TransportSide::ptr_t transportSide
The next plug-in in the chain towards transport.
Definition: sag_connectivity_plugins.hpp:712
virtual void sendBatchTowardsTransport(Message *start, Message *end)=0
Abstract method that must be implemented to handle delivery of a batch of messages heading towards th...
void setStatus(const std::string &value)
Set a string status value.
Definition: sag_connectivity_plugins.hpp:229
Definition: sag_connectivity_threading.h:178
std::auto_ptr< TransportSide > ptr_t
Pointers to TransportSides should always be this ptr_t type, which is a std::auto_ptr.
Definition: sag_connectivity_plugins.hpp:594
AbstractSimpleTransport(const PluginConstructorParameters::TransportConstructorParameters &params)
Constructor.
Definition: sag_connectivity_plugins.hpp:841
Logger logger
Logging for writing to the host log file.
Definition: sag_connectivity_plugins.hpp:534
void info(const char *format, ARGS...args) const
Log a message at INFO level.
Definition: sag_plugin_logging.hpp:155
virtual bool transformNullPayloadTowardsTransport(Message &msg)
Transform a message with a null payload in a transport-wards direction.
Definition: sag_connectivity_plugins.hpp:1028
virtual void start()
Called when an entire chain has been created and the plugin is allowed to start up (after all plugins...
Definition: sag_connectivity_plugins.hpp:459
std::unique_ptr< StatusItem > createStatusItem(const std::string &key, const std::string &initialValue)
Creates a StatusItem instance that can be used to report status for a given key.
Definition: sag_connectivity_plugins.hpp:332
A class allowing a plug-in to report status values to the host.
Definition: sag_connectivity_plugins.hpp:186
size_t erase(const data_t &k)
Remove the item with the specified key.
virtual ~TransportSide()
Ensure virtual destruction.
Definition: sag_connectivity_plugins.hpp:592
Base class for transport plug-ins.
Definition: sag_connectivity_plugins.hpp:746
static const char * STATUS_ONLINE()
Returns a constant that should be used as the status value when a component is online, operational, connected, and ready to handles messages.
Definition: sag_connectivity_plugins.hpp:193
const_iterator cbegin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:241
AbstractSimpleTransport(const std::string &name, const std::string &chainId, const map_t &config)
Legacy constructor [DEPRECATED].
Definition: sag_connectivity_plugins.hpp:829
bool isShuttingDown()
Check if host is shutting down.
Definition: sag_connectivity_plugins.hpp:78
const_iterator cend() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:243
virtual void handleException(Message &m)
Handle an exception thrown while delivering a message towards the transport.
Definition: sag_connectivity_plugins.hpp:890
Wrap the next plugin in order as a HostSide object.
Definition: sag_connectivity_plugins.hpp:573
const std::string name
The name used for this plug-in in the configuration file [DEPRECATED].
Definition: sag_connectivity_plugins.hpp:498
static const char * STATUS_FAILED()
Returns a constant that should be used as the status value when a component is not currently operatio...
Definition: sag_connectivity_plugins.hpp:201
virtual ~HostSide()
Ensure virtual destruction.
Definition: sag_connectivity_plugins.hpp:547
AbstractSimpleCodec(const PluginConstructorParameters::CodecConstructorParameters &params)
Constructor.
Definition: sag_connectivity_plugins.hpp:949
virtual void hostReady()
Called some time after start(), when the host is ready to start receiving input (sends will be queued...
Definition: sag_connectivity_plugins.hpp:468
std::pair< iterator, bool > insert(const std::pair< data_t &&, data_t && > &v)
Insert a new key/value pair into the map.
Base class for codec plug-ins.
Definition: sag_connectivity_plugins.hpp:654
No error.
Definition: sag_connectivity_c.h:62
static const char * STATUS_STARTING()
Returns a constant that should be used as the status value when a component is still starting...
Definition: sag_connectivity_plugins.hpp:197
std::unique_ptr< StatusItem > createStatusItem(const std::string &key, int64_t initialValue)
Creates a StatusItem instance that can be used to report status for a given key, using an integral in...
Definition: sag_connectivity_plugins.hpp:350
virtual bool transformMessageTowardsTransport(Message &msg)=0
Abstract method that must be implemented to handle transformation of an individual message in a trans...
AbstractSimpleCodec(const std::string &name, const std::string &chainId, const map_t &config)
Legacy constructor [DEPRECATED].
Definition: sag_connectivity_plugins.hpp:937
void setStatus(int64_t value)
Set an integer status value.
Definition: sag_connectivity_plugins.hpp:247
virtual bool transformMessageTowardsHost(Message &msg)=0
Abstract method that must be implemented to handle transformation of an individual message...
A map class which implements many of the functions on std::map.
Definition: sag_connectivity_cpp.hpp:37
const std::string & key()
Get the unique key specified when this status item was created.
Definition: sag_connectivity_plugins.hpp:275
const std::string & getPluginName() const
Get the name used in the configuration file for this plug-in.
Definition: sag_connectivity_plugins.hpp:128
A class that can be used to efficiently update the value associated with a single status key...
Definition: sag_connectivity_plugins.hpp:213
A container for an payload and associated metadata.
Definition: sag_connectivity_cpp.hpp:28
virtual void shutdown()
Stop processing messages and terminate and join any background threads.
Definition: sag_connectivity_plugins.hpp:492
virtual void sendBatchTowardsHost(Message *start, Message *end)
Implements batch sending, calling transformMessageTowardsHost(Message &) for each message individuall...
Definition: sag_connectivity_plugins.hpp:958
An interface to the next component (plugin or host) towards the transport.
Definition: sag_connectivity_plugins.hpp:588
AbstractCodec(const PluginConstructorParameters::CodecConstructorParameters &params)
Constructor.
Definition: sag_connectivity_plugins.hpp:686
virtual void deliverMessageTowardsTransport(Message &msg)=0
Abstract method that must be implemented to handle delivery of an individual message.
virtual void deliverNullPayloadTowardsTransport(Message &msg)
Deliver a message with a null payload.
Definition: sag_connectivity_plugins.hpp:867
void enableReliability(Direction direction)
Enable reliable messaging for the chain that this plug-in belongs to, in a particular direction i...
Definition: sag_connectivity_plugins.hpp:71
Contains the headers needed to implement your own Connectivity Plugins.
AbstractCodec(const std::string &pluginName, const std::string &chainId, const map_t &config)
Legacy constructor [DEPRECATED].
Definition: sag_connectivity_plugins.hpp:674
A container for parameters passed to the constructor of a transport plug-in.
Definition: sag_connectivity_plugins.hpp:149
The direction of messages flowing towards the host (from the transport).
map_t copy() const
Return a deep copy of this map.
Definition: sag_connectivity_cpp.hpp:197
AbstractTransport(const std::string &name, const std::string &chainId, const map_t &config)
Legacy constructor [DEPRECATED].
Definition: sag_connectivity_plugins.hpp:765
const std::string & getChainId() const
Get the identifier used for the chain this plug-in is part of.
Definition: sag_connectivity_plugins.hpp:123
Interface to support miscellaneous requests from a particular plug-in to the host system...
Definition: sag_connectivity_plugins.hpp:52
A base interface for parameters passed to the constructor of transport or codec plug-ins.
Definition: sag_connectivity_plugins.hpp:105
virtual bool handleException(Message &m, bool towardsTransport)
Handle an exception thrown while delivering a message.
Definition: sag_connectivity_plugins.hpp:1054
utf8-encoded const char*
Definition: sag_connectivity_c.h:46
virtual void sendBatchTowardsHost(Message *start, Message *end)
Abstract method that must be implemented to handle delivery of a batch of messages heading towards th...
const std::string chainId
The identifier used for the chain this plug-in is part of.
Definition: sag_connectivity_plugins.hpp:503
The direction of messages flowing towards the transport (from the host).
std::string getStatus()
Return the value this status item was set to most recently by this class.
Definition: sag_connectivity_plugins.hpp:258
A variant type which can be one of the following:
Definition: sag_connectivity_cpp.hpp:43
const map_t & getConfig() const
Get the configuration for this plug-in.
Definition: sag_connectivity_plugins.hpp:118
virtual void sendBatchTowardsTransport(Message *start, Message *end)
Implements batch sending, calling transformMessageTowardsTransport(Message &) for each message indivi...
Definition: sag_connectivity_plugins.hpp:985
std::auto_ptr< HostSide > ptr_t
Pointers to HostSides should always be this ptr_t type, which is a std::auto_ptr. ...
Definition: sag_connectivity_plugins.hpp:549
virtual ~Plugin()
This destructor must be virtual.
Definition: sag_connectivity_plugins.hpp:447
HostSide::ptr_t hostSide
The next plug-in in the chain towards host.
Definition: sag_connectivity_plugins.hpp:793
virtual void sendBatchTowardsTransport(Message *start, Message *end)
Abstract method that must be implemented to handle delivery of a batch of messages heading towards th...
const std::string & getName() const
Return the name of this plugin instance.
Definition: sag_connectivity_plugins.hpp:494
virtual bool transformNullPayloadTowardsHost(Message &msg)
Transform a message with a null payload in a host-wards direction.
Definition: sag_connectivity_plugins.hpp:1020