IDataItemSubscription.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* Copyright (c) 2015, 2017, 2020 The Linux Foundation. All rights reserved.
  2. *
  3. * Redistribution and use in source and binary forms, with or without
  4. * modification, are permitted provided that the following conditions are
  5. * met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above
  9. * copyright notice, this unordered_set of conditions and the following
  10. * disclaimer in the documentation and/or other materials provided
  11. * with the distribution.
  12. * * Neither the name of The Linux Foundation, nor the names of its
  13. * contributors may be used to endorse or promote products derived
  14. * from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  17. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  19. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  20. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  22. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  23. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  24. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  25. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  26. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *
  28. */
  29. #ifndef __IDATAITEMSUBSCRIPTION_H__
  30. #define __IDATAITEMSUBSCRIPTION_H__
  31. #include <unordered_set>
  32. #include <DataItemId.h>
  33. namespace loc_core
  34. {
  35. class IDataItemObserver;
  36. /**
  37. * @brief IDataItemSubscription interface
  38. * @details IDataItemSubscription interface;
  39. * Defines an interface for operations such as subscribe,
  40. * unsubscribe data items by their IDs.
  41. * Must be implemented by OS dependent code.
  42. */
  43. class IDataItemSubscription {
  44. public:
  45. /**
  46. * @brief Subscribe for data items by their IDs
  47. * @details Subscribe for data items by their IDs;
  48. * An IDataItemObserver implementer invokes this method to subscribe
  49. * for a unordered_set of DataItems by passing in their Ids.
  50. * A symbolic invocation of this method in the following order
  51. * subscribe ( {1,2,3}, &obj), subscribe ( {2,3,4,5}, &obj)
  52. * where the numbers enclosed in braces indicate a unordered_set of data item Ids
  53. * will cause this class implementer to update its subscription unordered_set for
  54. * &obj to only contain the following Data Item Ids 1,2,3,4,5.
  55. *
  56. * @param l Set of DataItemId
  57. * @param o Pointer to an instance of IDataItemObserver
  58. */
  59. virtual void subscribe (const std::unordered_set<DataItemId> & l, IDataItemObserver * o = NULL) = 0;
  60. /**
  61. * @brief Update subscription for Data items
  62. * @details Update subscription for Data items;
  63. * An IDataItemObserver implementer invokes this method to update their
  64. * subscription for a unordered_set of DataItems by passing in their Ids
  65. * A symbolic invocation of this method in the following order
  66. * updateSubscription ( {1,2,3}, &obj),updateSubscription ( {2,3,4,5}, &obj)
  67. * where the numbers enclosed in braces indicate a unordered_set of data item Ids
  68. * will cause this class implementer to update its subscription unordered_set for
  69. * &obj to only contain the following Data Item Ids 2,3,4,5.
  70. * Note that this method may or may not be called.
  71. *
  72. * @param l Set of DataItemId
  73. * @param o Pointer to an instance of IDataItemObserver
  74. */
  75. virtual void updateSubscription (const std :: unordered_set <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
  76. /**
  77. * @brief Request Data
  78. * @details Request Data
  79. *
  80. * @param l Set of DataItemId
  81. * @param o Pointer to an instance of IDataItemObserver
  82. */
  83. virtual void requestData (const std :: unordered_set <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
  84. /**
  85. * @brief Unsubscribe Data items
  86. * @details Unsubscrbe Data items;
  87. * An IDataItemObserver implementer invokes this method to unsubscribe their
  88. * subscription for a unordered_set of DataItems by passing in their Ids
  89. * Suppose this class implementor has a currently active subscription unordered_set
  90. * containing 1,2,3,4,5,6,7 for &obj then a symbolic invocation of this
  91. * method in the following order
  92. * unsubscribe ( {1,2,3}, &obj), unsubscribe ( {1,2,3,4}, &obj),
  93. * unsubscribe ( {7}, &obj)
  94. * where the numbers enclosed in braces indicate a unordered_set of data item Ids
  95. * will cause this class implementer to update its subscription unordered_set for
  96. * &obj to only contain the following data item id 5,6.
  97. *
  98. * @param l Set of DataItemId
  99. * @param o Pointer to an instance of IDataItemObserver
  100. */
  101. virtual void unsubscribe (const std :: unordered_set <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
  102. /**
  103. * @brief Unsubscribe all data items
  104. * @details Unsubscribe all data items
  105. *
  106. * @param o Pointer to an instance of IDataItemObserver
  107. */
  108. virtual void unsubscribeAll (IDataItemObserver * o = NULL) = 0;
  109. /**
  110. * @brief Destructor
  111. * @details Destructor
  112. */
  113. virtual ~IDataItemSubscription () {}
  114. };
  115. } // namespace loc_core
  116. #endif // #ifndef __IDATAITEMSUBSCRIPTION_H__