1 /* Copyright (c) 2015, 2017 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 list 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 
30 #ifndef __IDATAITEMSUBSCRIPTION_H__
31 #define __IDATAITEMSUBSCRIPTION_H__
32 
33 #include  <list>
34 #include  <DataItemId.h>
35 
36 namespace loc_core
37 {
38 class IDataItemObserver;
39 
40 /**
41  * @brief IDataItemSubscription interface
42  * @details IDataItemSubscription interface;
43  *          Defines an interface for operations such as subscribe,
44  *          unsubscribe data items by their IDs.
45  *          Must be implemented by OS dependent code.
46  */
47 class IDataItemSubscription {
48 
49 public:
50     /**
51      * @brief Subscribe for data items by their IDs
52      * @details Subscribe for data items by their IDs;
53      *          An IDataItemObserver implementer invokes this method to subscribe
54      *          for a list of DataItems by passing in their Ids.
55      *          A symbolic invocation of this method in the following order
56      *          subscribe ( {1,2,3}, &obj), subscribe ( {2,3,4,5}, &obj)
57      *          where the numbers enclosed in braces indicate a list of data item Ids
58      *          will cause this class implementer to update its subscription list for
59      *          &obj to only contain the following Data Item Ids 1,2,3,4,5.
60      *
61      * @param l List of DataItemId
62      * @param o Pointer to an instance of IDataItemObserver
63      */
64     virtual void subscribe (const std :: list <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
65 
66     /**
67      * @brief Update subscription for Data items
68      * @details Update subscription for Data items;
69      *          An IDataItemObserver implementer invokes this method to update their
70      *          subscription for a list of DataItems by passing in their Ids
71      *          A symbolic invocation of this method in the following order
72      *          updateSubscription ( {1,2,3}, &obj),updateSubscription ( {2,3,4,5}, &obj)
73      *          where the numbers enclosed in braces indicate a list of data item Ids
74      *          will cause this class implementer to update its subscription list for
75      *          &obj to only contain the following Data Item Ids 2,3,4,5.
76      *          Note that this method may or may not be called.
77      *
78      * @param l List of DataItemId
79      * @param o Pointer to an instance of IDataItemObserver
80      */
81     virtual void updateSubscription (const std :: list <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
82 
83     /**
84      * @brief Request Data
85      * @details Request Data
86      *
87      * @param l List of DataItemId
88      * @param o Pointer to an instance of IDataItemObserver
89      */
90     virtual void requestData (const std :: list <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
91 
92     /**
93      * @brief Unsubscribe Data items
94      * @details Unsubscrbe Data items;
95      *          An IDataItemObserver implementer invokes this method to unsubscribe their
96      *          subscription for a list of DataItems by passing in their Ids
97      *          Suppose this class implementor has a currently active subscription list
98      *          containing 1,2,3,4,5,6,7 for &obj then a symbolic invocation of this
99      *          method in the following order
100      *          unsubscribe ( {1,2,3}, &obj), unsubscribe (  {1,2,3,4}, &obj),
101      *          unsubscribe ( {7}, &obj)
102      *          where the numbers enclosed in braces indicate a list of data item Ids
103      *          will cause this class implementer to update its subscription list for
104      *          &obj to only contain the following data item id 5,6.
105      *
106      * @param l List of DataItemId
107      * @param o Pointer to an instance of IDataItemObserver
108      */
109     virtual void unsubscribe (const std :: list <DataItemId> & l, IDataItemObserver * o = NULL) = 0;
110 
111     /**
112      * @brief Unsubscribe all data items
113      * @details Unsubscribe all data items
114      *
115      * @param o Pointer to an instance of IDataItemObserver
116      */
117     virtual void unsubscribeAll (IDataItemObserver * o = NULL) = 0;
118 
119     /**
120      * @brief Destructor
121      * @details Destructor
122      */
~IDataItemSubscription()123     virtual ~IDataItemSubscription () {}
124 };
125 
126 } // namespace loc_core
127 
128 #endif // #ifndef __IDATAITEMSUBSCRIPTION_H__
129 
130