ConfigNotifications.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef _CONFIG_NOTIFICATIONS_HPP_
  14. #define _CONFIG_NOTIFICATIONS_HPP_
  15. #include "jiface.hpp"
  16. #include "jhash.ipp"
  17. #include "jutil.hpp"
  18. namespace CONFIGURATOR
  19. {
  20. enum ENotificationType
  21. {
  22. eInformational = 1,
  23. eAlert,
  24. eWarning,
  25. eError,
  26. eCritical,
  27. eUnknown // needs to be last, and all enumaration element indexes must be sequential
  28. };
  29. static const char NotificationTypeNames[eUnknown][1024] = { "Informational",
  30. "Alert",
  31. "Warning",
  32. "Error",
  33. "Critical",
  34. "Unknown" };
  35. class CNotification;
  36. class CNotificationManager;
  37. class CNotificationManager : public CInterface
  38. {
  39. public:
  40. static CNotificationManager* getInstance();
  41. virtual ~CNotificationManager(){}
  42. int getNumberOfNotificationTypes() const
  43. {
  44. return eUnknown-1;
  45. }
  46. const char* getNotificationTypeName(int idx)
  47. {
  48. if (idx >= 0 && idx < eUnknown)
  49. return NotificationTypeNames[idx];
  50. else
  51. return NULL;
  52. }
  53. int getNumberOfNotifications(enum ENotificationType eNotifyType) const;
  54. const char* getNotification(enum ENotificationType eNotifyType, int idx) const;
  55. void setNotification(const CXSDNodeBase *pNodeBase, enum ENotificationType eNotifyType, const char* pNotificationText);
  56. void resetNotifications(const CXSDNodeBase *pNodeBase);
  57. protected:
  58. CNotificationManager();
  59. typedef MapStringToMyClass<CNotification> MapStringToCNotification;
  60. MapStringToCNotification m_EnvXPathToNotification;
  61. private:
  62. static CNotificationManager *s_pNotificationManager;
  63. };
  64. class CNotification : public CInterfaceOf<IInterface>
  65. {
  66. friend class CNotificationManager;
  67. public:
  68. CNotification()
  69. {
  70. }
  71. virtual ~CNotification()
  72. {
  73. }
  74. StringArray m_NotificationMessagesArrays[eUnknown];
  75. };
  76. }
  77. #endif // _CONFIG_NOTIFICATIONS_HPP_