Apama  9.10.0.4.289795
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
engine_client_cpp.hpp
Go to the documentation of this file.
1 /*
2  * engine_client_cpp.hpp
3  *
4  * $Copyright(c) 2002-2012 Progress Software Corporation and/or its subsidiaries and affiliates. All rights reserved.$
5  * $Copyright (c) 2013-2016 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.$
6  * Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG
7  *
8  * $Id: engine_client_cpp.hpp 274995 2016-02-08 17:08:39Z shd $
9  */
10 
15 #ifndef ENGINE_CLIENT_CPP_HPP
16 #define ENGINE_CLIENT_CPP_HPP
17 
18 #include <AP_Types.h>
19 #include <AP_Platform.h>
20 #include <iostream>
21 #include <sstream>
22 #include <exception>
23 #include <iterator>
24 #include <algorithm>
25 #include <utility>
26 #include <string>
27 #include <assert.h>
28 #include <engine_client_c.h>
29 #include <iomanip>
30 
31 
32 using std::pair;
33 
34 #undef ERROR
35 
36 namespace com {
37 
39 namespace apama {
40 
45  class AP_ENGINE_CLIENT_API EngineException : public std::exception
46  {
47  public:
49  EngineException(const char *message);
52 
54  EngineException& operator= (const EngineException& ce) {
55  EngineException(ce).swap(*this);
56  return *this;
57  }
58 
60  virtual ~EngineException() throw();
61 
68  virtual const char* what() const throw() { return m_message; }
69 
77  virtual const char* const* getWarnings() const { return m_warnings; }
78 
79  protected:
81  void swap(EngineException &);
83  const char* const* m_warnings;
84 
85  private:
87  char *m_message;
88  };
89 
90 
92  typedef enum {
102  } LogLevel;
103 
104 
110  AP_ENGINE_CLIENT_API void setLogLevel(LogLevel level);
111 
122  AP_ENGINE_CLIENT_API void setLogFile(const AP_char8* filename, bool truncate, bool utf8 = false);
123 
129  AP_ENGINE_CLIENT_API void setLogFD(int fd);
130 
135  AP_ENGINE_CLIENT_API void setLogMutex(void *mutex);
136 
141  AP_ENGINE_CLIENT_API void reOpenLog();
142 
143 
145  AP_ENGINE_CLIENT_API AP_char8* convertToUTF8(const AP_char8* s);
146 
148  AP_ENGINE_CLIENT_API AP_char8* convertFromUTF8(const AP_char8* s);
149 
153  AP_ENGINE_CLIENT_API void char8free(char *string);
154 
158  namespace event {
159 
168  class AP_ENGINE_CLIENT_API Event
169  {
170  friend AP_ENGINE_CLIENT_API Event* createEvent(const char* eventString, const char* channelString);
171  friend AP_ENGINE_CLIENT_API void deleteEvent(Event* ev);
172 
173  public:
180  virtual const char* getText() const = 0;
181 
190  virtual const char* getChannel() const = 0;
191 
202  virtual double getTime() const = 0;
203 
205  inline friend std::ostream& operator << (std::ostream& stream, const Event& obj) {
206  stream << obj.getText();
207  return stream;
208  }
210  inline friend std::ostream& operator << (std::ostream& stream, const Event* obj) {
211  stream << obj->getText();
212  return stream;
213  }
214 
215  private:
217  Event(const Event&);
219  Event& operator= (const Event&);
220 
221  protected:
223  Event();
225  virtual ~Event();
226  };
227 
228 
240  class AP_ENGINE_CLIENT_API EventSupplier
241  {
242  friend AP_ENGINE_CLIENT_API void deleteEventSupplier(EventSupplier* evsup);
243 
244  public:
254  virtual void disconnect() = 0;
255 
256  protected:
258  EventSupplier();
260  virtual ~EventSupplier();
261 
262  private:
266  EventSupplier& operator= (const EventSupplier&);
267  };
268 
269 
280  class AP_ENGINE_CLIENT_API EventConsumer
281  {
282  public:
295  virtual void sendEvents(const Event* const* events) = 0;
296 
297  protected:
299  EventConsumer();
301  virtual ~EventConsumer();
302 
303  private:
307  EventConsumer& operator= (const EventConsumer&);
308  };
309 
313  class AP_ENGINE_CLIENT_API DisconnectableEventConsumer : public EventConsumer
314  {
315  public:
323  virtual void disconnect(const char* reason) = 0;
324 
325  protected:
329  virtual ~DisconnectableEventConsumer();
330 
331  private:
336  };
337 
338 
349  AP_ENGINE_CLIENT_API Event* createEvent(const char* eventString, const char* channelString);
350 
356  AP_ENGINE_CLIENT_API void deleteEvent(Event* ev);
357 
358 
367  AP_ENGINE_CLIENT_API void deleteEventSupplier(EventSupplier* evsup);
368 
369  } // namespace event
370 
372  namespace engine {
373 
382  class AP_ENGINE_CLIENT_API MonitorScript
383  {
384  friend AP_ENGINE_CLIENT_API MonitorScript* createMonitorScript(const char* monitorString);
385  friend AP_ENGINE_CLIENT_API void deleteMonitorScript(MonitorScript* mon);
386 
387  public:
395  virtual const char* getText() const = 0;
396 
398  inline friend std::ostream& operator << (std::ostream& stream, const MonitorScript& obj) {
399  stream << obj.getText();
400  return stream;
401  }
403  inline friend std::ostream& operator << (std::ostream& stream, const MonitorScript* obj) {
404  stream << obj->getText();
405  return stream;
406  }
407 
408  private:
412  MonitorScript& operator= (const MonitorScript&);
413 
414  protected:
416  MonitorScript();
418  virtual ~MonitorScript();
419  };
420 
426  class AP_ENGINE_CLIENT_API EngineStatus
427  {
428  friend class EngineManagement; /* getStatus */
429 
430  public:
431 
437 #ifdef _MSC_VER
438 // needed or MSVC complains about the use of pair<string> here, even though it's all inlined
439 #pragma warning (disable : 4251)
440 #endif
441  class AP_ENGINE_CLIENT_API StatusIterator : public std::iterator<std::forward_iterator_tag, int>
442  {
443  public:
445  typedef pair<std::string, std::string> pair_t;
446 
448  explicit StatusIterator(const EngineStatus &es, bool end=false);
451  m_status(0),
452  m_opaqueState(0),
453  iterPair()
454  {}
457  {
458  if (m_status && m_opaqueState) m_status->disposeIterator(m_opaqueState);
459  }
461  StatusIterator operator++(int dummy/*@unused@*/)
462  {
463  StatusIterator current(*this);
464  ++(*this); //this->operator++() // prefix ++
465  return current;
466  }
468  StatusIterator& operator++();
470  bool operator==(const StatusIterator& ref) const
471  {
472  return (m_status == ref.m_status) &&
473  (((0 == m_opaqueState) && (0 == ref.m_opaqueState)) ||
474  (iterPair.first == ref.iterPair.first));
475  }
477  bool operator!=(const StatusIterator& ref) const { return !((*this)==ref); }
479  pair_t &operator*() { return iterPair; }
481  pair_t *operator->() { return &iterPair; }
483  bool valid() { return 0 != m_opaqueState; }
484 
487  : m_status(ref.m_status),
488  m_opaqueState(m_status->copyIterator(ref.m_opaqueState)),
489  iterPair(ref.iterPair)
490  {}
493  {
494  StatusIterator(other).swap(*this);
495  return *this;
496  }
497 
498  private:
500  void step();
502  void swap(StatusIterator &other)
503  {
504  std::swap(m_status, other.m_status);
505  std::swap(m_opaqueState, other.m_opaqueState);
506  std::swap(iterPair, other.iterPair);
507  }
508 
510  const EngineStatus *m_status;
512  void *m_opaqueState;
514  pair_t iterPair;
515  };
516 
521 
527  AP_uint64 getUptime() const {
528  return getStatusIntValue("uptime");
529  }
530 
536  AP_uint32 getNumContexts() const {
537  return (AP_uint32) getStatusIntValue("numContexts");
538  }
539 
545  AP_uint32 getNumMonitors() const {
546  return (AP_uint32) getStatusIntValue("numMonitors");
547  }
548 
555  AP_uint32 getNumProcesses() const {
556  return (AP_uint32) getStatusIntValue("numProcesses");
557  }
558 
564  AP_uint32 getNumJavaApplications() const {
565  return (AP_uint32) getStatusIntValue("numJavaApplications");
566  }
567 
573  AP_uint32 getNumListeners() const {
574  return (AP_uint32) getStatusIntValue("numListeners");
575  }
576 
582  AP_uint32 getNumEventTypes() const {
583  return (AP_uint32) getStatusIntValue("numEventTypes");
584  }
585 
592  AP_uint32 getNumQueuedFastTrack() const {
593  return (AP_uint32) getStatusIntValue("numQueuedFastTrack");
594  }
595 
602  AP_uint32 getNumQueuedInput() const {
603  return (AP_uint32) getStatusIntValue("numQueuedInput");
604  }
605 
611  AP_uint64 getNumReceived() const {
612  return getStatusIntValue("numReceived");
613  }
614 
620  AP_uint64 getNumFastTracked() const {
621  return getStatusIntValue("numFastTracked");
622  }
623 
629  AP_uint32 getNumConsumers() const {
630  return (AP_uint32) getStatusIntValue("numConsumers");
631  }
632 
638  AP_uint32 getNumOutEventsQueued() const {
639  return (AP_uint32) getStatusIntValue("numOutEventsQueued");
640  }
641 
648  AP_uint64 getNumOutEventsCreated() const {
649  return getStatusIntValue("numEmits");
650  }
651 
659  AP_uint64 getNumOutEventsSent() const {
660  return getStatusIntValue("numOutEventsSent");
661  }
662 
668  AP_uint32 getNumInputQueuedInput() const {
669  return (AP_uint32) getStatusIntValue("numInputQueuedInput");
670  }
671 
677  const AP_char8* getMostBackedUpInput() const {
678  return (*this)["mostBackedUpInputContext"];
679  }
680 
686  const AP_char8 *getSlowestReceiver() const {
687  return (*this)["slowestReceiver"];
688  }
689 
695  AP_uint32 getSlowestReceiverQueueSize() const {
696  return (AP_uint32) getStatusIntValue("slowestReceiverQueueSize");
697  }
698 
704  AP_uint32 getMostBackedUpQueueSize() const {
705  return (AP_uint32) getStatusIntValue("mostBackedUpQueueSize");
706  }
707 
713  AP_uint32 getNumSubListeners() const {
714  return (AP_uint32) getStatusIntValue("numSubListeners");
715  }
716 
723  AP_uint64 getNumProcessed() const {
724  return getStatusIntValue("numProcessed");
725  }
732  const_iterator begin() const {
733  return StatusIterator(*this);
734  }
735 
742  const_iterator end() const {
743  return StatusIterator(*this, true);
744  }
745 
749  const AP_char8* operator[] (const char *ref) const {
750  return getStatusValue(ref);
751  }
752 
756  const AP_char8* operator[] (std::string &ref) const {
757  return this->operator[](ref.c_str());
758  }
759 
766  AP_int64 getUserInt(const char* key) {
767  return userInt(key);
768  }
769 
776  AP_int64 getUserIntOr(const char* key, int alt) {
777  return userIntOr(key, alt);
778  }
779 
786  AP_float64 getUserFloat(const char* key) {
787  return userFloat(key);
788  }
789 
796  AP_float64 getUserFloatOr(const char* key, float alt) {
797  return userFloatOr(key, alt);
798  }
799 
806  AP_bool getUserBool(const char* key) {
807  return userBool(key);
808  }
809 
816  AP_bool getUserBoolOr(const char* key, bool alt) {
817  return userBoolOr(key, alt);
818  }
819 
826  const AP_char8* getUserString(const char* key) {
827  return userString(key);
828  }
829 
836  const AP_char8* getUserStringOr(const char* key, const char* alt) {
837  return userStringOr(key, alt);
838  }
839 
845  std::string getAllStatusValues() {
846  std::ostringstream ost;
847  ost << getStandardStatusValues();
848  for (EngineStatus::StatusIterator it = begin(); it != end(); ++it) {
849  if (it->first.find("user-") != std::string::npos)
850  ost << std::setw(32) << setiosflags(std::ios_base::left) << it->first.append(":") << it->second << std::endl;
851  }
852  return ost.str();
853  }
854 
860  std::string getStandardStatusValues() {
861  std::ostringstream ost;
862  ost
863  << "Uptime(ms): " << getUptime() << std::endl
864  << "Number of contexts: " << getNumContexts() << std::endl
865  << "Number of monitors: " << getNumMonitors() << std::endl
866  << "Number of sub-monitors: " << getNumProcesses() << std::endl
867  << "Number of java applications: " << getNumJavaApplications() << std::endl
868  << "Number of listeners: " << getNumListeners() << std::endl
869  << "Number of sub-listeners: " << getNumSubListeners() << std::endl
870  << "Number of event types: " << getNumEventTypes() << std::endl
871  << "Events on input queue: " << getNumQueuedInput() << std::endl
872  << "Events received: " << getNumReceived() << std::endl
873  << "Events processed: " << getNumProcessed() << std::endl
874  << "Events on internal queue: " << getNumQueuedFastTrack() << std::endl
875  << "Events routed internally: " << getNumFastTracked() << std::endl
876  << "Number of consumers: " << getNumConsumers() << std::endl
877  << "Events on output queue: " << getNumOutEventsQueued() << std::endl
878  << "Output events created: " << getNumOutEventsCreated() << std::endl
879  << "Output events sent: " << getNumOutEventsSent() << std::endl
880  << "Events on input context queues: " << getNumInputQueuedInput() << std::endl
881  << "Slowest context name: " << getMostBackedUpInput() << std::endl
882  << "Slowest context queue size: " << getMostBackedUpQueueSize() << std::endl
883  << "Slowest receiver name: " << getSlowestReceiver() << std::endl
884  << "Slowest receiver queue size: " << getSlowestReceiverQueueSize() << std::endl;
885  return ost.str();
886  }
887 
893  static std::string getRawHeader() {
894  std::ostringstream ost;
895  ost << "Uptime (ms),# Contexts,# Monitors,# Sub-monitors,# Java apps,# Listeners,";
896  ost << "# Sub-listeners,# Event types,Input queue,# Received events,";
897  ost << "Route queue,# Routed events,# Consumers,Output queue,";
898  ost << "# Created output events,# Sent output events,# Processed events,";
899  ost << "Slowest context name,Slowest context queue size,Slowest receiver,Slowest receiver queue";
900  return ost.str();
901  }
902 
908  std::string getRawHeaderAll() {
909  std::ostringstream ost;
910  ost << getRawHeader();
911  for (EngineStatus::StatusIterator it = begin(); it != end(); ++it) {
912  if (it->first.find("user-") != std::string::npos)
913  ost << "," << it->first;
914  }
915  return ost.str();
916  }
917 
924  std::ostringstream ost;
925  ost << getUptime()
926  << "," << getNumContexts()
927  << "," << getNumMonitors()
928  << "," << getNumProcesses()
929  << "," << getNumJavaApplications()
930  << "," << getNumListeners()
931  << "," << getNumSubListeners()
932  << "," << getNumEventTypes()
933  << "," << getNumQueuedInput()
934  << "," << getNumReceived()
935  << "," << getNumQueuedFastTrack()
936  << "," << getNumFastTracked()
937  << "," << getNumConsumers()
938  << "," << getNumOutEventsQueued()
939  << "," << getNumOutEventsCreated()
940  << "," << getNumOutEventsSent()
941  << "," << getNumProcessed()
942  << "," << getMostBackedUpInput()
943  << "," << getMostBackedUpQueueSize()
944  << "," << getSlowestReceiver()
945  << "," << getSlowestReceiverQueueSize();
946  return ost.str();
947  }
948 
954  std::string getAllStatusValuesRaw() {
955  std::ostringstream ost;
956  ost << getStandardStatusValuesRaw();
957  for (EngineStatus::StatusIterator it = begin(); it != end(); ++it) {
958  if (it->first.find("user-") != std::string::npos)
959  ost << "," << it->second;
960  }
961  return ost.str();
962  }
963 
967  inline friend std::ostream& operator << (std::ostream& stream, const EngineStatus& obj) {
968  std::ostringstream ost;
969  ost
970  << "Uptime(ms): " << obj.getUptime() << std::endl
971  << "Number of contexts: " << obj.getNumContexts() << std::endl
972  << "Number of monitors: " << obj.getNumMonitors() << std::endl
973  << "Number of sub-monitors: " << obj.getNumProcesses() << std::endl
974  << "Number of java applications: " << obj.getNumJavaApplications() << std::endl
975  << "Number of listeners: " << obj.getNumListeners() << std::endl
976  << "Number of sub-listeners: " << obj.getNumSubListeners() << std::endl
977  << "Number of event types: " << obj.getNumEventTypes() << std::endl
978  << "Events on input queue: " << obj.getNumQueuedInput() << std::endl
979  << "Events received: " << obj.getNumReceived() << std::endl
980  << "Events processed: " << obj.getNumProcessed() << std::endl
981  << "Events on internal queue: " << obj.getNumQueuedFastTrack() << std::endl
982  << "Events routed internally: " << obj.getNumFastTracked() << std::endl
983  << "Number of consumers: " << obj.getNumConsumers() << std::endl
984  << "Events on output queue: " << obj.getNumOutEventsQueued() << std::endl
985  << "Output events created: " << obj.getNumOutEventsCreated() << std::endl
986  << "Output events sent: " << obj.getNumOutEventsSent() << std::endl
987  << "Events on input context queues: " << obj.getNumInputQueuedInput() << std::endl
988  << "Slowest context name: " << obj.getMostBackedUpInput() << std::endl
989  << "Slowest context queue size: " << obj.getMostBackedUpQueueSize() << std::endl
990  << "Slowest receiver name: " << obj.getSlowestReceiver() << std::endl
991  << "Slowest receiver queue size: " << obj.getSlowestReceiverQueueSize() << std::endl;
992  stream << ost.str();
993  return stream;
994  }
995 
999  inline friend std::ostream& operator << (std::ostream& stream, const EngineStatus* obj) {
1000  stream << *obj;
1001  return stream;
1002  }
1003 
1008  {
1009  if (c_status) {
1010  c_status->functions->deleteStatus(reinterpret_cast<AP_EngineStatus *>(c_status));
1011  }
1012  }
1015  : c_status(other.c_status ? reinterpret_cast<AP_EngineStatus_API*>(other.c_status->functions->copyStatus(reinterpret_cast<AP_EngineStatus *>(other.c_status))) : 0)
1016  {}
1019  {
1020  EngineStatus(other).swap(*this);
1021  return *this;
1022  }
1026  EngineStatus(): c_status(0) {}
1027  private:
1029  EngineStatus(AP_EngineStatus_API *api): c_status(api) {}
1031  void swap(EngineStatus &other) {
1032  std::swap(c_status, other.c_status);
1033  }
1035  void getNext(const char *&name, const char *&value, void *&opaqueState) const {
1036  if (c_status)
1037  c_status->functions->getNextStatusItem(reinterpret_cast<AP_EngineStatus *>(c_status), &name, &value, &opaqueState);
1038  }
1040  const AP_char8* getStatusValue(const char *name) const {
1041  return c_status->functions->getStatusValue(reinterpret_cast<AP_EngineStatus *>(c_status), name);
1042  }
1044  AP_uint64 getStatusIntValue(const char *name) const {
1045  return c_status->functions->getStatusIntValue(reinterpret_cast<AP_EngineStatus *>(c_status), name);
1046  }
1048  void disposeIterator(void *opaqueState) const {
1049  c_status->functions->disposeIterator(reinterpret_cast<AP_EngineStatus *>(c_status), opaqueState);
1050  }
1052  void *copyIterator(void *opaqueState) const {
1053  return c_status->functions->copyIterator(reinterpret_cast<AP_EngineStatus *>(c_status), opaqueState);
1054  }
1055 
1057  AP_int64 userIntOr(const char* key, AP_int64 alt) {
1058  return c_status->functions->getUserIntOr(reinterpret_cast<AP_EngineStatus *>(c_status), key, alt);
1059  }
1061  AP_float64 userFloatOr(const char* key, AP_float64 alt) {
1062  return c_status->functions->getUserFloatOr(reinterpret_cast<AP_EngineStatus *>(c_status), key, alt);
1063  }
1065  AP_bool userBoolOr(const char* key, AP_bool alt) {
1066  return c_status->functions->getUserBoolOr(reinterpret_cast<AP_EngineStatus *>(c_status), key, alt);
1067  }
1069  const AP_char8* userStringOr(const char* key, const AP_char8* alt) {
1070  return c_status->functions->getUserStringOr(reinterpret_cast<AP_EngineStatus *>(c_status), key, alt);
1071  }
1073  AP_int64 userInt(const char* key) {
1074  return c_status->functions->getUserInt(reinterpret_cast<AP_EngineStatus *>(c_status), key);
1075  }
1077  AP_float64 userFloat(const char* key) {
1078  return c_status->functions->getUserFloat(reinterpret_cast<AP_EngineStatus *>(c_status), key);
1079  }
1081  AP_bool userBool(const char* key) {
1082  return c_status->functions->getUserBool(reinterpret_cast<AP_EngineStatus *>(c_status), key);
1083  }
1085  const AP_char8* userString(const char* key) {
1086  return c_status->functions->getUserString(reinterpret_cast<AP_EngineStatus *>(c_status), key);
1087  }
1089  AP_EngineStatus_API *c_status;
1090  };
1091 
1092  inline EngineStatus::StatusIterator::StatusIterator(const EngineStatus &es, bool end):
1093  m_status(&es),
1094  m_opaqueState(0),
1095  iterPair()
1096  {
1097  if (!end) step(); // get the first item in the map
1098  }
1099 
1102  {
1103  if (m_opaqueState) step();// don't step past the end
1104  return *this;
1105  }
1106 
1107  inline void EngineStatus::StatusIterator::step()
1108  {
1109  const char *name = 0;
1110  const char *value = 0;
1111 
1112  /* get the next item from the library map */
1113  m_status->getNext(name, value, m_opaqueState );
1114  if(!name || !value) {
1115  assert(!m_opaqueState);
1116  } else {
1117  iterPair = pair_t(name, value);
1118  }
1119  }
1120 
1131  class AP_ENGINE_CLIENT_API NameInfo
1132  {
1133  public:
1137  virtual const char* getName() const = 0;
1138 
1143  virtual const char* getPackage() const = 0;
1144 
1148  virtual const char* getFullyQualifiedName() const = 0;
1149 
1150  private:
1152  NameInfo(const NameInfo&);
1154  NameInfo& operator= (const NameInfo&);
1155 
1156  protected:
1158  NameInfo();
1160  virtual ~NameInfo();
1161  };
1162 
1167  class AP_ENGINE_CLIENT_API NamedMonitorInfo : public NameInfo
1168  {
1169  public:
1173  virtual unsigned int getNumSubMonitors() const = 0;
1174 
1175  private:
1180 
1181  protected:
1183  NamedMonitorInfo();
1185  virtual ~NamedMonitorInfo();
1186  };
1187 
1192  class AP_ENGINE_CLIENT_API NamedJavaApplicationInfo : public NameInfo {
1193 
1194  public:
1198  virtual unsigned int getNumListeners() const = 0;
1199 
1200  private:
1205 
1206  protected:
1210  virtual ~NamedJavaApplicationInfo();
1211  };
1212 
1217  class AP_ENGINE_CLIENT_API NamedContextInfo : public NameInfo {
1218 
1219  public:
1223  virtual unsigned int getNumSubMonitors() const = 0;
1224 
1228  virtual unsigned int getQueueSize() const = 0;
1229 
1233  virtual char const *const *getChannels() const = 0;
1234 
1235  private:
1240 
1241  protected:
1243  NamedContextInfo();
1245  virtual ~NamedContextInfo();
1246  };
1247 
1248 
1253  class AP_ENGINE_CLIENT_API NamedReceiverInfo : public NameInfo {
1254 
1255  public:
1259  virtual unsigned int getQueueSize() const = 0;
1260 
1264  virtual char const *const *getChannels() const = 0;
1265 
1269  virtual const AP_char8 *getAddress() const = 0;
1270 
1271  private:
1276 
1277  protected:
1281  virtual ~NamedReceiverInfo();
1282  };
1283 
1284 
1289  class AP_ENGINE_CLIENT_API NamedPluginReceiverInfo : public NameInfo {
1290 
1291  public:
1295  virtual unsigned int getQueueSize() const = 0;
1296 
1300  virtual char const *const *getChannels() const = 0;
1301 
1302  private:
1307 
1308  protected:
1312  virtual ~NamedPluginReceiverInfo();
1313  };
1314 
1319  class AP_ENGINE_CLIENT_API NamedEventTypeInfo : public NameInfo {
1320 
1321  public:
1325  virtual unsigned int getNumEventTemplates() const = 0;
1326 
1327  private:
1332 
1333  protected:
1337  virtual ~NamedEventTypeInfo();
1338  };
1339 
1344  class AP_ENGINE_CLIENT_API NamedTimerInfo : public NameInfo {
1345 
1346  public:
1350  virtual unsigned int getNumTimers() const = 0;
1351 
1352  private:
1357 
1358  protected:
1360  NamedTimerInfo();
1362  virtual ~NamedTimerInfo();
1363  };
1364 
1370  class AP_ENGINE_CLIENT_API NamedAggregateInfo : public NameInfo {
1371 
1372  private:
1377 
1378  protected:
1382  virtual ~NamedAggregateInfo();
1383  };
1384 
1397  class AP_ENGINE_CLIENT_API EngineInfo
1398  {
1399  friend AP_ENGINE_CLIENT_API void deleteInfo(EngineInfo* info);
1400 
1401  public:
1405  virtual unsigned int getNumMonitors() const = 0;
1406 
1410  virtual unsigned int getNumJavaApplications() const = 0;
1411 
1415  virtual unsigned int getNumEventTypes() const = 0;
1416 
1420  virtual unsigned int getNumTimers() const = 0;
1421 
1425  virtual unsigned int getNumAggregates() const = 0;
1426 
1434  virtual NamedMonitorInfo** getMonitors() const = 0;
1435 
1443  virtual NamedJavaApplicationInfo** getJavaApplications() const = 0;
1444 
1452  virtual NamedEventTypeInfo** getEventTypes() const = 0;
1453 
1461  virtual NamedTimerInfo** getTimers() const = 0;
1462 
1470  virtual NamedAggregateInfo** getAggregates() const = 0;
1471 
1475  virtual unsigned int getNumContexts() const = 0;
1476 
1484  virtual NamedContextInfo** getContexts() const = 0;
1485 
1489  virtual unsigned int getNumReceivers() const = 0;
1490 
1498  virtual NamedReceiverInfo **getReceivers() const = 0;
1499 
1503  virtual unsigned int getNumPluginReceivers() const = 0;
1504 
1512  virtual NamedPluginReceiverInfo **getPluginReceivers() const = 0;
1513 
1514  private:
1516  EngineInfo(const EngineInfo&);
1518  EngineInfo& operator= (const EngineInfo&);
1519 
1520  protected:
1522  EngineInfo();
1524  virtual ~EngineInfo();
1525  };
1526 
1527 
1544  class AP_ENGINE_CLIENT_API EngineManagement : public com::apama::event::EventConsumer
1545  {
1546  public:
1551  };
1558  virtual void injectMonitorScript(MonitorScript& script) = 0;
1559 
1575  virtual const char* const* injectMonitorScriptWithWarnings(MonitorScript& script) = 0;
1576 
1593  virtual const char* const* injectMonitorScriptWithWarningsFilename(MonitorScript& script, const char *filename) = 0;
1594 
1601  virtual void deleteName(const char * name) = 0;
1602 
1609  virtual void forceDeleteName(const char * name) = 0;
1610 
1617  virtual void killName(const char * name) = 0;
1618 
1622  virtual void deleteAll() = 0;
1623 
1632  virtual void injectJava(const AP_uint8* jarbytes, AP_uint32 size) = 0;
1633 
1650  virtual const char* const* injectJavaWithWarnings(const AP_uint8* jarbytes, AP_uint32 size) = 0;
1651 
1666  virtual const char* const* injectJavaWithWarningsFilename(const AP_uint8* jarbytes, AP_uint32 size, const char *filename) = 0;
1667 
1668 
1678  virtual void injectCDP(const AP_uint8* cdpbytes, AP_uint32 size, const char *filename=NULL) = 0;
1679 
1696  virtual const char* const* injectCDPWithWarnings(const AP_uint8* cdpbytes, AP_uint32 size) = 0;
1697 
1712  virtual const char* const* injectCDPWithWarningsFilename(const AP_uint8* cdpbytes, AP_uint32 size, const char *filename) = 0;
1713 
1719  {
1720  char *errmsg = 0;
1721  AP_EngineStatus *es_api = engineManagement_getStatusOpaque(this, &errmsg);
1722  if (errmsg) {
1723  com::apama::EngineException e(errmsg);
1724  free(errmsg);
1725  throw e;
1726  }
1727 
1728  return EngineStatus(reinterpret_cast<AP_EngineStatus_API *>(es_api));
1729  }
1730 
1752  virtual com::apama::event::EventSupplier* connectEventConsumer(com::apama::event::EventConsumer* consumer, const char* const* channels, bool disconnectSlow = false) = 0;
1753 
1776  virtual bool attachAsEventConsumerTo(EngineManagement* target, const char* const* channels, bool disconnectSlow = false, ConnectMode mode = CONNECT_LEGACY) = 0;
1777 
1778 
1802  virtual bool attachAsEventConsumerTo(const char* host, int port, const char* const* channels, bool disconnectSlow = false, ConnectMode mode = CONNECT_LEGACY) = 0;
1803 
1804 
1821  virtual void detachAsEventConsumerFrom(EngineManagement* target, const char* const* channels, ConnectMode mode = CONNECT_LEGACY) = 0;
1822 
1840  virtual void detachAsEventConsumerFrom(const char* host, int port, const char* const* channels, ConnectMode mode = CONNECT_LEGACY) = 0;
1841 
1852  virtual void sendEvents(const com::apama::event::Event* const* events) = 0;
1853 
1861  virtual void sendEventsNoBatching(const com::apama::event::Event* const* events) = 0;
1862 
1866  virtual void flushEvents() = 0;
1867 
1876  virtual EngineInfo* inspectEngine() = 0;
1877 
1894  virtual void ping() = 0;
1895 
1901  virtual bool isConnected() = 0;
1902 
1903  protected:
1905  EngineManagement();
1907  virtual ~EngineManagement();
1908 
1909  private:
1914  };
1915 
1916 
1923  AP_ENGINE_CLIENT_API void engineInit(const char* processName = "C++ Client");
1924 
1925 
1932  AP_ENGINE_CLIENT_API void engineInitMessaging(const char *processName, bool initMessaging=true);
1933 
1939  AP_ENGINE_CLIENT_API void engineShutdown();
1940 
1941 
1954  AP_ENGINE_CLIENT_API EngineManagement* connectToEngine(const char* host, unsigned short port);
1955 
1968  AP_ENGINE_CLIENT_API EngineManagement* connectToEngineReceiveOnly(const char* host, unsigned short port);
1969 
1981  AP_ENGINE_CLIENT_API EngineManagement* connectToEngineMonitorOnly(const char* host, unsigned short port);
1982 
1992  AP_ENGINE_CLIENT_API void disconnectFromEngine(EngineManagement* corr);
1993 
2000  AP_ENGINE_CLIENT_API MonitorScript* createMonitorScript(const char* monitorString);
2001 
2007  AP_ENGINE_CLIENT_API void deleteMonitorScript(MonitorScript* mon);
2008 
2018  AP_ENGINE_CLIENT_API void deleteInfo(EngineInfo* info);
2019 
2020 
2028  AP_ENGINE_CLIENT_API void deleteWarnings(const char* const* warnings);
2029 
2042  AP_ENGINE_CLIENT_API void setEngineParams(const char* params);
2043 
2044  } // namespace engine
2045 
2046 } // namespace apama
2047 
2048 } // namespace com
2049 
2050 
2051 #endif // ENGINE_CLIENT_CPP_HPP
AP_ENGINE_CLIENT_API void deleteInfo(EngineInfo *info)
This function allows deletion of an EngineInfo object.
AP_ENGINE_CLIENT_API void setLogLevel(LogLevel level)
Sets the level at which the client library will log information.
AP_ENGINE_CLIENT_API void setEngineParams(const char *params)
Set custom parameters for this instance of the client library.
Derived class from EventConsumer which implements the disconnect API.
Definition: engine_client_cpp.hpp:313
Base class for a named object (i.e.
Definition: engine_client_cpp.hpp:1131
const AP_char8 * getMostBackedUpInput() const
Get the name of the most backed up context.
Definition: engine_client_cpp.hpp:677
An EventConsumer can connect to the Engine through an EventSupplier and register to receive events...
Definition: engine_client_cpp.hpp:280
This is the header file for the Apama Engine C SDK.
AP_float64 getUserFloatOr(const char *key, float alt)
Get a user value of type AP_float64 or the alt value if it cannot be found.
Definition: engine_client_cpp.hpp:796
AP_ENGINE_CLIENT_API EngineManagement * connectToEngineMonitorOnly(const char *host, unsigned short port)
Attempt to establish a monitor-only connection to an Engine listening on the named host and port...
virtual const char * getText() const =0
Retrieve the event's type and its contents as a string.
AP_uint32 getNumConsumers() const
Get the number of event consumers connected to the engine.
Definition: engine_client_cpp.hpp:629
AP_ENGINE_CLIENT_API void engineInit(const char *processName="C++ Client")
This function must be called once per process first before any other Engine operations are carried ou...
AP_ENGINE_CLIENT_API EngineManagement * connectToEngineReceiveOnly(const char *host, unsigned short port)
Attempt to establish a receive-only connection to an Engine listening on the named host and port...
AP_uint32 getNumInputQueuedInput() const
Get the total number of events on input contexts' queues.
Definition: engine_client_cpp.hpp:668
virtual const char * getText() const =0
Retrieve the text of a MonitorScript fragment as a string.
~EngineStatus()
Destroy the underlying status data.
Definition: engine_client_cpp.hpp:1007
AP_uint32 getNumSubListeners() const
Get the number of active sub-listeners.
Definition: engine_client_cpp.hpp:713
EngineStatus getStatus()
Get the Engine's current operational status.
Definition: engine_client_cpp.hpp:1718
AP_int64 getUserIntOr(const char *key, int alt)
Get a user value of type AP_int64 or the alt value if it cannot be found.
Definition: engine_client_cpp.hpp:776
AP_uint64 getNumReceived() const
Get the number of events received since the Engine started.
Definition: engine_client_cpp.hpp:611
The Engine Management class acts as the interface to the Engine, and allows operations to be carried ...
Definition: engine_client_cpp.hpp:1544
bool operator==(const StatusIterator &ref) const
Returns true if two iterators point to the same item.
Definition: engine_client_cpp.hpp:470
pair< std::string, std::string > pair_t
element type
Definition: engine_client_cpp.hpp:445
Fatal messages.
Definition: engine_client_cpp.hpp:96
AP_ENGINE_CLIENT_API void deleteMonitorScript(MonitorScript *mon)
This function allows deletion of MonitorScript objects.
AP_int64 getUserInt(const char *key)
Get a user value of type AP_int64.
Definition: engine_client_cpp.hpp:766
Nothing logged.
Definition: engine_client_cpp.hpp:93
AP_bool getUserBool(const char *key)
Get a user value of type AP_bool.
Definition: engine_client_cpp.hpp:806
AP_uint32 getNumJavaApplications() const
Get the number of Java (JMon) Applications defined in the Engine.
Definition: engine_client_cpp.hpp:564
Definition: sag_connectivity_cpp.hpp:35
StatusIterator & operator=(const StatusIterator &other)
Copy assignment.
Definition: engine_client_cpp.hpp:492
Information about a timer type returned by an engine inspection.
Definition: engine_client_cpp.hpp:1344
AP_ENGINE_CLIENT_API AP_char8 * convertFromUTF8(const AP_char8 *s)
Convert a string in UTF-8 to the local encoding, since most of the Apama API returns UTF-8...
AP_uint32 getNumContexts() const
Get the number of contexts active in the Engine.
Definition: engine_client_cpp.hpp:536
Information about a context returned by an engine inspection.
Definition: engine_client_cpp.hpp:1217
StatusIterator operator++(int dummy)
(postfix) increment this iterator
Definition: engine_client_cpp.hpp:461
pair_t & operator*()
Return a reference to the element pointed to.
Definition: engine_client_cpp.hpp:479
std::string getStandardStatusValues()
Get the standard status values, formatted for terminal output.
Definition: engine_client_cpp.hpp:860
AP_ENGINE_CLIENT_API void engineInitMessaging(const char *processName, bool initMessaging=true)
This function (or engineInit) must be called once per process first before any other Engine operation...
Startup and other important messages.
Definition: engine_client_cpp.hpp:94
AP_uint32 getNumQueuedFastTrack() const
Get the total number of events waiting on the route queues (value of 'rq' in the correlator status li...
Definition: engine_client_cpp.hpp:592
EngineStatus & operator=(const EngineStatus &other)
Copy assignment.
Definition: engine_client_cpp.hpp:1018
AP_ENGINE_CLIENT_API MonitorScript * createMonitorScript(const char *monitorString)
This function allows creation of MonitorScript objects.
StatusIterator const_iterator
Iterator type for const EngineStatus.
Definition: engine_client_cpp.hpp:520
An EventSupplier represents the resources created by the Engine to service a connection to an externa...
Definition: engine_client_cpp.hpp:240
static std::string getRawHeader()
Get a header for the raw output, useful for indentifying values.
Definition: engine_client_cpp.hpp:893
const AP_char8 * getSlowestReceiver() const
Get the name of the slowest receiver.
Definition: engine_client_cpp.hpp:686
For backwards compatibility, single serial connection.
Definition: engine_client_cpp.hpp:1549
Information about a monitor returned by an engine inspection.
Definition: engine_client_cpp.hpp:1167
Allow parallel connections on multiple channels.
Definition: engine_client_c.h:1478
Information about a receiver returned by an engine inspection.
Definition: engine_client_cpp.hpp:1253
std::string getRawHeaderAll()
Get a header for the raw output, useful for indentifying values.
Definition: engine_client_cpp.hpp:908
AP_ENGINE_CLIENT_API void setLogFile(const AP_char8 *filename, bool truncate, bool utf8=false)
Sets the file to which the client library should log information.
ConnectMode
The mode that attachAsEventConsumerTo and detachAsEventConsumerFrom operate in.
Definition: engine_client_cpp.hpp:1548
For backwards compatibility, single serial connection.
Definition: engine_client_c.h:1477
AP_ENGINE_CLIENT_API EngineManagement * connectToEngine(const char *host, unsigned short port)
This function attempts to establish a connection to an Engine.
EngineStatus()
Create a default-constructed (empty) EngineStatus.
Definition: engine_client_cpp.hpp:1026
Information messages (default)
Definition: engine_client_cpp.hpp:99
Information about an aggregate function returned by an engine inspection.
Definition: engine_client_cpp.hpp:1370
EngineStatus.
Definition: engine_client_c.h:696
virtual const char *const * getWarnings() const
Retrieve the set of warnings associated with the exception.
Definition: engine_client_cpp.hpp:77
AP_uint32 getSlowestReceiverQueueSize() const
Get the queue size of the slowest receiver.
Definition: engine_client_cpp.hpp:695
Information about the monitors and types currently in an engine.
Definition: engine_client_cpp.hpp:1397
AP_ENGINE_CLIENT_API void engineShutdown()
This function must be called once per process before the application closes down. ...
Information about a java application returned by an engine inspection.
Definition: engine_client_cpp.hpp:1192
AP_ENGINE_CLIENT_API void disconnectFromEngine(EngineManagement *corr)
This function allows disconnection from an Engine.
const AP_char8 * getUserString(const char *key)
Get a user value of type AP_char8*.
Definition: engine_client_cpp.hpp:826
An Event object represents an event instance.
Definition: engine_client_cpp.hpp:168
AP_uint32 getNumMonitors() const
Get the number of monitors defined in the Engine.
Definition: engine_client_cpp.hpp:545
Critical messages.
Definition: engine_client_cpp.hpp:95
AP_uint32 getMostBackedUpQueueSize() const
Get the queue size of the most backed up context.
Definition: engine_client_cpp.hpp:704
pair_t * operator->()
Return a pointer to the element pointed to.
Definition: engine_client_cpp.hpp:481
AP_uint64 getUptime() const
Get the time in ms that the Engine has been running for.
Definition: engine_client_cpp.hpp:527
const_iterator begin() const
Returns an instance of the StatusIterator which allows to iterate over all status items...
Definition: engine_client_cpp.hpp:732
std::string getAllStatusValuesRaw()
Get all the status values available, formatted for parsers (values seperated by ,).
Definition: engine_client_cpp.hpp:954
AP_ENGINE_CLIENT_API void reOpenLog()
Re-opens the log file.
AP_uint32 getNumOutEventsQueued() const
Get the number of events waiting on the output queue.
Definition: engine_client_cpp.hpp:638
AP_uint32 getNumEventTypes() const
Get the number of event types defined in the Engine.
Definition: engine_client_cpp.hpp:582
LogLevel
Available logging levels.
Definition: engine_client_cpp.hpp:92
Information about a receiver returned by an engine inspection.
Definition: engine_client_cpp.hpp:1289
std::string getAllStatusValues()
Get all the status values available, formatted for terminal output.
Definition: engine_client_cpp.hpp:845
EngineStatus(const EngineStatus &other)
Copy constructor.
Definition: engine_client_cpp.hpp:1014
AP_uint32 getNumQueuedInput() const
Get the total number of events waiting on the input queues (value of 'iq' in the correlator status li...
Definition: engine_client_cpp.hpp:602
AP_uint64 getNumOutEventsSent() const
This is the number of output events sent out by the correlator process.
Definition: engine_client_cpp.hpp:659
AP_ENGINE_CLIENT_API void deleteWarnings(const char *const *warnings)
This function allows deletion of the lists of warnings returned by injectMonitorScriptWithWarnings()...
const_iterator end() const
Returns an instance of the StatusIterator which allows to iterate over all status items...
Definition: engine_client_cpp.hpp:742
EngineStatus represents the operational status of the Engine.
Definition: engine_client_cpp.hpp:426
AP_uint32 getNumListeners() const
Get the number of active listeners.
Definition: engine_client_cpp.hpp:573
AP_uint64 getNumOutEventsCreated() const
Get the number of output events which have been put onto the output queue.
Definition: engine_client_cpp.hpp:648
Warning messages.
Definition: engine_client_cpp.hpp:98
AP_ENGINE_CLIENT_API AP_char8 * convertToUTF8(const AP_char8 *s)
Convert a string in local encoding to UTF-8, as required by most of the Apama API.
StatusIterator & operator++()
(prefix) increment this iterator
Definition: engine_client_cpp.hpp:1101
bool valid()
Returns true if this is a valid iterator over status data.
Definition: engine_client_cpp.hpp:483
const AP_char8 * getUserStringOr(const char *key, const char *alt)
Get a user value of type AP_char8* or the alt value if it cannot be found.
Definition: engine_client_cpp.hpp:836
AP_ENGINE_CLIENT_API Event * createEvent(const char *eventString, const char *channelString)
This function allows creation of an Event object.
Debugging messages.
Definition: engine_client_cpp.hpp:100
AP_float64 getUserFloat(const char *key)
Get a user value of type AP_float64.
Definition: engine_client_cpp.hpp:786
bool operator!=(const StatusIterator &ref) const
Returns false if two iterators point to the same item.
Definition: engine_client_cpp.hpp:477
Information about a event type returned by an engine inspection.
Definition: engine_client_cpp.hpp:1319
std::string getStandardStatusValuesRaw()
Get the standard status values, formatted for parsers (values seperated by ,).
Definition: engine_client_cpp.hpp:923
StatusIterator()
Default-constructed status iterator. Use EngineStatus::begin() to get a valid iterator.
Definition: engine_client_cpp.hpp:450
An EngineException is thrown by methods in this library if any problems are encountered.
Definition: engine_client_cpp.hpp:45
More-verbose debug messages.
Definition: engine_client_cpp.hpp:101
A MonitorScript object encapsulates a MonitorScript code fragment, containing package, event and monitor definitions to be injected into an Engine.
Definition: engine_client_cpp.hpp:382
AP_ENGINE_CLIENT_API void setLogFD(int fd)
Sets the file descriptor to which the client library should log information.
AP_ENGINE_CLIENT_API void char8free(char *string)
Free any char* string returned from the client API.
A class used for the iterating through all status items.
Definition: engine_client_cpp.hpp:441
AP_ENGINE_CLIENT_API void deleteEvent(Event *ev)
This function allows deletion of an Event object.
StatusIterator iterator
Iterator type.
Definition: engine_client_cpp.hpp:518
AP_ENGINE_CLIENT_API void deleteEventSupplier(EventSupplier *evsup)
This function disconnects and deletes an EventSupplier object.
AP_uint32 getNumProcesses() const
Get the number of monitor processes or active sub-monitors.
Definition: engine_client_cpp.hpp:555
AP_uint64 getNumProcessed() const
Get the number of events taken off the input queue and processed since the engine started...
Definition: engine_client_cpp.hpp:723
~StatusIterator()
Destroy underling status iterator.
Definition: engine_client_cpp.hpp:456
Error messages.
Definition: engine_client_cpp.hpp:97
StatusIterator(const StatusIterator &ref)
Copy constructor.
Definition: engine_client_cpp.hpp:486
AP_uint64 getNumFastTracked() const
Get the number of events received on the internal input queue since the Engine started.
Definition: engine_client_cpp.hpp:620
AP_bool getUserBoolOr(const char *key, bool alt)
Get a user value of type AP_bool or the alt value if it cannot be found.
Definition: engine_client_cpp.hpp:816